Expand my Community achievements bar.

Who Me Too'd this topic

Avatar

Level 8

Hi All,

I have a sling model class, with four different dialog properties that I have as below. For example :

@Inject

    @Optional

    @Via("resource")

    private String videoType;

@Inject

    @Optional

    @Via("resource")

    private String videoId;

and similarly for the other 2 properties

private String videoUrl = StringUtils.EMPTY;

@PostConstruct

    public void init() {

videoUrl = Utility.getVideoUrl(videoType, videoId);

}

public String getVideoUrl() {

        return videoUrl;

    }

The utility class is as below :

    String videoUrl = StringUtils.EMPTY;

        if (videoType != null && id != null) {

            if (videoType.equals("youtube")) {

                videoUrl = Constants.youtube_link + id;

            } else {

                videoUrl = Constants.streamsite + id;

            }

        }

        return videoUrl;

    }

I need to write Junit classes for this utility method and model class. Went through multiple links and codes. but not able to get started on this.

If someone can tell me how to write Junit classes for this, would be really really helpful.

Who Me Too'd this topic