VulnerabilityConnector { public boolean isMoreRecent(Vulnerability vulnerability, Vulnerability other) { if (Strings.isNullOrEmpty(vulnerability.getLastExternalUpdate()) || Strings.isNullOrEmpty(other.getLastExternalUpdate())) { return true; } return vulnerability.getLastExternalUpdate().compareTo(other.getLastExternalUpdate()) > 0; } VulnerabilityConnector(); Optional<Release> getRelease(String releaseId); Optional<Component> getComponent(String componentId); Optional<Project> getProject(String projectId); List<Release> getAllReleases(); boolean isMoreRecent(Vulnerability vulnerability, Vulnerability other); RequestStatus addOrUpdate(ReleaseVulnerabilityRelation partiallyFilledRelation); UpdateType addOrUpdate(Vulnerability vulnerability, ReleaseVulnerabilityRelation partiallyFilledRelation); VulnerabilityUpdateStatus addOrUpdate(Vulnerability vulnerability,
                                                 ReleaseVulnerabilityRelation partiallyFilledRelation,
                                                 VulnerabilityUpdateStatus currentVulnerabilityUpdateStatus); Map<UpdateType, List<Vulnerability>> addOrUpdateVulnerabilityAndSetId(
            Vulnerability vulnerability,
            Map<UpdateType, List<Vulnerability>> statusToVulnerabilities); Map<UpdateType, List<Vulnerability>> addOrUpdateVulnerabilitiesAndSetIds(List<Vulnerability> vulnerabilities); RequestStatus addReleaseVulnerabilityRelationsIfNecessary(String releaseId, List<String> vulnerabilityIds); RequestStatus addReleaseVulnerabilityRelationsIfNecessary(String releaseId, Map<String,List<String>> needleToVulnerabilityIds);  }
@Test public void testIsMoreRecentEmpty() throws Exception { Vulnerability v1 = new Vulnerability(); Vulnerability v2 = new Vulnerability(); assertThat(vulnerabilityConnector.isMoreRecent(v1, v2), is(true)); }
@Test public void testIsMoreRecentFirstNull() throws Exception { Vulnerability v1 = new Vulnerability(); Vulnerability v2 = new Vulnerability().setLastExternalUpdate("2016"); assertThat(vulnerabilityConnector.isMoreRecent(v1, v2), is(true)); }
@Test public void testIsMoreRecentSecondNull() throws Exception { Vulnerability v1 = new Vulnerability().setLastExternalUpdate("2016"); Vulnerability v2 = new Vulnerability(); assertThat(vulnerabilityConnector.isMoreRecent(v1, v2), is(true)); }
@Test public void testIsMoreRecentFirstEmpty() throws Exception { Vulnerability v1 = new Vulnerability().setLastExternalUpdate(""); Vulnerability v2 = new Vulnerability().setLastExternalUpdate("2016"); assertThat(vulnerabilityConnector.isMoreRecent(v1, v2), is(true)); }
@Test public void testIsMoreRecentSecondEmpty() throws Exception { Vulnerability v1 = new Vulnerability().setLastExternalUpdate("2016"); Vulnerability v2 = new Vulnerability().setLastExternalUpdate(""); assertThat(vulnerabilityConnector.isMoreRecent(v1, v2), is(true)); }
@Test public void testIsMoreRecentFirstOlder() throws Exception { Vulnerability v1 = new Vulnerability().setLastExternalUpdate("2015"); Vulnerability v2 = new Vulnerability().setLastExternalUpdate("2016"); assertThat(vulnerabilityConnector.isMoreRecent(v1, v2), is(false)); }
@Test public void testIsMoreRecentSecondOlder() throws Exception { Vulnerability v1 = new Vulnerability().setLastExternalUpdate("2016"); Vulnerability v2 = new Vulnerability().setLastExternalUpdate("2015"); assertThat(vulnerabilityConnector.isMoreRecent(v1, v2), is(true)); }