PullRequestInfo { public String getBody() { if (this.image == null && this.tag == null) { return OLD_CONSTANT_BODY; } return String.format(BODY_TEMPLATE, image, image, tag, image + ":" + tag); } PullRequestInfo(String title, String image, String tag); String getTitle(); String getBody(); static final String BODY_TEMPLATE; static final String DEFAULT_TITLE; static final String OLD_CONSTANT_BODY; }
@Test public void testGetBody() { String imageAndTag = IMAGE + ":" + TAG; PullRequestInfo pullRequestInfo = new PullRequestInfo(TITLE, IMAGE, TAG); assertEquals(pullRequestInfo.getBody(), String.format(BODY_TEMPLATE, IMAGE, IMAGE, TAG, imageAndTag)); }
@Test public void testGetBodyIsOldConstantIfImageAndTagNull() { PullRequestInfo pullRequestInfo = new PullRequestInfo(TITLE, null, null); assertEquals(pullRequestInfo.getBody(), OLD_CONSTANT_BODY); }