SW360ReleaseAdapterUtils { public static SW360Release validateRelease(SW360Release release) { if (StringUtils.isEmpty(release.getName())) { throw new IllegalArgumentException("Invalid release: missing property 'name'."); } if (StringUtils.isEmpty(release.getVersion())) { throw new IllegalArgumentException("Invalid release: missing property 'version'."); } return release; } private  SW360ReleaseAdapterUtils(); static SW360Release validateRelease(SW360Release release);  }
@Test public void validateReleaseWithValidRelease() { SW360Release release = new SW360Release() .setName("releaseName") .setVersion("1.0-SNAPSHOT"); assertThat(SW360ReleaseAdapterUtils.validateRelease(release)).isSameAs(release); }
@Test public void ValidateReleaseNoName() { SW360Release release = new SW360Release(); release.setVersion("1.1"); try { SW360ReleaseAdapterUtils.validateRelease(release); fail("Invalid release not detected!"); } catch (IllegalArgumentException e) { assertThat(e.getMessage()).contains("missing property 'name'"); } }
@Test public void testIsValidReleaseEmptyName() { SW360Release release = new SW360Release(); release.setVersion("1.2"); release.setName(""); try { SW360ReleaseAdapterUtils.validateRelease(release); fail("Invalid release not detected!"); } catch (IllegalArgumentException e) { assertThat(e.getMessage()).contains("missing property 'name'"); } }
@Test public void testIsValidReleaseNoVersion() { SW360Release release = new SW360Release(); release.setName("myRelease"); try { SW360ReleaseAdapterUtils.validateRelease(release); fail("Invalid release not detected!"); } catch (IllegalArgumentException e) { assertThat(e.getMessage()).contains("missing property 'version'"); } }
@Test public void testIsValidReleaseEmptyVersion() { SW360Release release = new SW360Release(); release.setName("releaseName"); release.setVersion(""); try { SW360ReleaseAdapterUtils.validateRelease(release); fail("Invalid release not detected!"); } catch (IllegalArgumentException e) { assertThat(e.getMessage()).contains("missing property 'version'"); } }