use of org.eclipse.sw360.datahandler.thrift.components.Release in project sw360portal by sw360.
the class ComponentDatabaseHandlerTest method testDeleteReleaseNotModerator.
@Test
public void testDeleteReleaseNotModerator() throws Exception {
when(releaseModerator.deleteRelease(any(Release.class), eq(user1))).thenReturn(RequestStatus.SENT_TO_MODERATOR);
RequestStatus status = handler.deleteRelease("R1B", user1);
assertEquals(RequestStatus.SENT_TO_MODERATOR, status);
List<Release> releaseSummary = handler.getReleaseSummary();
assertEquals(5, releaseSummary.size());
assertTrue("Component NOT deleted", releasesContain(releaseSummary, "R1B"));
verify(releaseModerator).deleteRelease(any(Release.class), eq(user1));
}
use of org.eclipse.sw360.datahandler.thrift.components.Release in project sw360portal by sw360.
the class ComponentDatabaseHandlerTest method testAddRelease.
@Test
public void testAddRelease() throws Exception {
Release expected = new Release().setName("REL").setVersion("VER");
expected.setComponentId("C1");
String id = handler.addRelease(expected, "new@mail.com").getId();
assertNotNull(id);
Release actual = handler.getRelease(id, user1);
// Check that object was added correctly
assertEquals(expected.getName(), actual.getName());
assertEquals(expected.getVersion(), actual.getVersion());
// Check that the component was also updated
Component component = handler.getComponent("C1", user1);
assertTrue(releasesContain(component.getReleases(), id));
}
use of org.eclipse.sw360.datahandler.thrift.components.Release in project sw360portal by sw360.
the class ComponentDatabaseHandlerTest method testUpdateRelease.
@Test
public void testUpdateRelease() throws Exception {
Release expected = releases.get(1);
expected.setName("UPDATED");
RequestStatus status = handler.updateRelease(expected, user2, ThriftUtils.IMMUTABLE_OF_RELEASE);
Release actual = handler.getRelease("R1B", user1);
assertEquals(RequestStatus.SUCCESS, status);
assertEquals(expected.getId(), actual.getId());
assertEquals(expected.getName(), actual.getName());
assertEquals(expected.getVersion(), actual.getVersion());
assertEquals(expected.getComponentId(), actual.getComponentId());
assertEquals(email2, actual.getCreatedBy());
// Check releases
assertEquals(1, actual.getSubscribersSize());
assertTrue(actual.getSubscribers().contains(email1));
}
use of org.eclipse.sw360.datahandler.thrift.components.Release in project sw360portal by sw360.
the class ComponentDatabaseHandlerTest method addRelease.
private String addRelease(String componentId, Set<String> licenseIds) throws SW360Exception {
Release release = new Release().setName("REL").setVersion(nextReleaseVersion + "").setMainLicenseIds(licenseIds).setComponentId(componentId);
nextReleaseVersion++;
String id = handler.addRelease(release, user1.getEmail()).getId();
assertNotNull(id);
return id;
}
use of org.eclipse.sw360.datahandler.thrift.components.Release in project sw360portal by sw360.
the class SearchLevels method addGuessingSearchLevels.
private void addGuessingSearchLevels(CveSearchApi cveSearchApi, int vendorThreshold, int productThreshold, int cutoff) {
CveSearchGuesser cveSearchGuesser = new CveSearchGuesser(cveSearchApi);
cveSearchGuesser.setVendorThreshold(vendorThreshold);
cveSearchGuesser.setProductThreshold(productThreshold);
cveSearchGuesser.setCutoff(cutoff);
// Level 2. search by guessed vendors and products with version
searchLevels.add(release -> guessForRelease(cveSearchGuesser, release, true));
// Level 3. search by guessed vendors and products without version
searchLevels.add(release -> guessForRelease(cveSearchGuesser, release, false));
}
Aggregations