use of org.eclipse.sw360.datahandler.couchdb.DatabaseConnector in project sw360portal by sw360.
the class ProjectDatabaseHandlerTest method setUp.
@Before
public void setUp() throws Exception {
assertTestString(dbName);
assertTestString(attachmentsDbName);
List<Project> projects = new ArrayList<>();
Project p1 = new Project().setId("P1").setName("Project1").setBusinessUnit("AB CD EF").setCreatedBy("user1").setReleaseIdToUsage(ImmutableMap.<String, ProjectReleaseRelationship>builder().put("r1", new ProjectReleaseRelationship(ReleaseRelationship.CONTAINED, MainlineState.MAINLINE)).put("r2", new ProjectReleaseRelationship(ReleaseRelationship.CONTAINED, MainlineState.MAINLINE)).put("r3", new ProjectReleaseRelationship(ReleaseRelationship.CONTAINED, MainlineState.MAINLINE)).put("r4", new ProjectReleaseRelationship(ReleaseRelationship.CONTAINED, MainlineState.MAINLINE)).put("r5", new ProjectReleaseRelationship(ReleaseRelationship.CONTAINED, MainlineState.MAINLINE)).put("r6", new ProjectReleaseRelationship(ReleaseRelationship.CONTAINED, MainlineState.MAINLINE)).build());
projects.add(p1);
Project p2 = new Project().setId("P2").setName("Project2").setBusinessUnit("AB CD FE").setCreatedBy("user2").setReleaseIdToUsage(ImmutableMap.<String, ProjectReleaseRelationship>builder().put("r1", new ProjectReleaseRelationship(ReleaseRelationship.CONTAINED, MainlineState.MAINLINE)).put("r2", new ProjectReleaseRelationship(ReleaseRelationship.CONTAINED, MainlineState.MAINLINE)).put("r3", new ProjectReleaseRelationship(ReleaseRelationship.CONTAINED, MainlineState.MAINLINE)).build());
projects.add(p2);
projects.get(1).addToContributors("user1");
projects.add(new Project().setId("P3").setName("Project3").setBusinessUnit("AB CD EF").setCreatedBy("user3"));
Project p4 = new Project().setId("P4").setName("Project4").setBusinessUnit("AB CD EF").setCreatedBy("user1").setVisbility(Visibility.PRIVATE).setReleaseIdToUsage(ImmutableMap.<String, ProjectReleaseRelationship>builder().put("r1", new ProjectReleaseRelationship(ReleaseRelationship.CONTAINED, MainlineState.MAINLINE)).put("r2", new ProjectReleaseRelationship(ReleaseRelationship.CONTAINED, MainlineState.MAINLINE)).build()).setLinkedProjects(ImmutableMap.<String, ProjectRelationship>builder().put("P5", ProjectRelationship.CONTAINED).build());
projects.add(p4);
projects.add(new Project().setId("P5").setName("Project5").setBusinessUnit("AB CD EF").setCreatedBy("user1"));
List<Release> releases = new ArrayList<>();
releases.add(new Release().setId("r1").setComponentId("c1"));
releases.add(new Release().setId("r2").setComponentId("c1"));
releases.add(new Release().setId("r3").setComponentId("c1"));
releases.add(new Release().setId("r4").setComponentId("c1"));
releases.add(new Release().setId("r5").setComponentId("c1"));
releases.add(new Release().setId("r6").setComponentId("c1"));
// Create the database
TestUtils.createDatabase(DatabaseSettings.getConfiguredHttpClient(), dbName);
// Prepare the database
DatabaseConnector databaseConnector = new DatabaseConnector(DatabaseSettings.getConfiguredHttpClient(), dbName);
for (Project project : projects) {
databaseConnector.add(project);
}
for (Release r : releases) {
databaseConnector.add(r);
}
databaseConnector.add(new Component("comp1").setId("c1"));
componentHandler = new ComponentDatabaseHandler(DatabaseSettings.getConfiguredHttpClient(), dbName, attachmentsDbName);
handler = new ProjectDatabaseHandler(DatabaseSettings.getConfiguredHttpClient(), dbName, attachmentDbName, moderator, componentHandler);
}
use of org.eclipse.sw360.datahandler.couchdb.DatabaseConnector in project sw360portal by sw360.
the class AttachmentHandlerTest method setUp.
@Before
public void setUp() throws Exception {
// Create the database
TestUtils.createDatabase(DatabaseSettings.getConfiguredHttpClient(), dbName);
TestUtils.createDatabase(DatabaseSettings.getConfiguredHttpClient(), DatabaseSettings.COUCH_DB_DATABASE);
DatabaseConnector databaseConnector = new DatabaseConnector(DatabaseSettings.getConfiguredHttpClient(), dbName);
databaseConnector.add(new AttachmentContent().setId("A1").setFilename("a.txt").setContentType("text"));
databaseConnector.add(new AttachmentContent().setId("A2").setFilename("b.jpg").setContentType("image"));
handler = new AttachmentHandler();
}
use of org.eclipse.sw360.datahandler.couchdb.DatabaseConnector in project sw360portal by sw360.
the class ComponentDatabaseHandlerTest method setUp.
@Before
public void setUp() throws Exception {
assertTestString(dbName);
assertTestString(attachmentsDbName);
// Set up vendors
vendors = new HashMap<>();
vendors.put("V1", new Vendor().setId("V1").setShortname("Microsoft").setFullname("Microsoft Corporation").setUrl("http://www.microsoft.com"));
vendors.put("V2", new Vendor().setId("V2").setShortname("Apache").setFullname("The Apache Software Foundation").setUrl("http://www.apache.org"));
vendors.put("V3", new Vendor().setId("V3").setShortname("Oracle").setFullname("Oracle Corporation Inc").setUrl("http://www.oracle.com"));
components = new ArrayList<>();
Component component1 = new Component().setId("C1").setName("component1").setDescription("d1").setCreatedBy(email1).setMainLicenseIds(new HashSet<>(Arrays.asList("lic1"))).setCreatedOn("2017-07-20");
component1.addToReleaseIds("R1A");
component1.addToReleaseIds("R1B");
components.add(component1);
Component component2 = new Component().setId("C2").setName("component2").setDescription("d2").setCreatedBy(email2).setMainLicenseIds(new HashSet<>(Arrays.asList("lic2"))).setCreatedOn("2017-07-21");
component2.addToReleaseIds("R2A");
component2.addToReleaseIds("R2B");
component2.addToReleaseIds("R2C");
components.add(component2);
Component component3 = new Component().setId("C3").setName("component3").setDescription("d3").setCreatedBy(email1).setMainLicenseIds(new HashSet<>(Arrays.asList("lic3"))).setCreatedOn("2017-07-22");
component3.addToSubscribers(email1);
component3.addToLanguages("E");
components.add(component3);
releases = new ArrayList<>();
Release release1a = new Release().setId("R1A").setComponentId("C1").setName("component1").setVersion("releaseA").setCreatedBy(email1).setVendorId("V1");
releases.add(release1a);
Release release1b = new Release().setId("R1B").setComponentId("C1").setName("component1").setVersion("releaseB").setCreatedBy(email2).setVendorId("V2");
release1b.setEccInformation(new EccInformation().setAL("AL"));
release1b.addToSubscribers(email1);
releases.add(release1b);
Release release2a = new Release().setId("R2A").setComponentId("C2").setName("component2").setVersion("releaseA").setCreatedBy(email1).setVendorId("V3");
releases.add(release2a);
Release release2b = new Release().setId("R2B").setComponentId("C2").setName("component2").setVersion("releaseB").setCreatedBy(email2).setVendorId("V1");
releases.add(release2b);
release2b.addToSubscribers(email2);
Release release2c = new Release().setId("R2C").setComponentId("C2").setName("component2").setVersion("releaseC").setCreatedBy(email1).setVendorId("V2");
releases.add(release2c);
// Create the database
TestUtils.createDatabase(DatabaseSettings.getConfiguredHttpClient(), dbName);
// Prepare the database
DatabaseConnector databaseConnector = new DatabaseConnector(DatabaseSettings.getConfiguredHttpClient(), dbName);
for (Vendor vendor : vendors.values()) {
databaseConnector.add(vendor);
}
for (Component component : components) {
databaseConnector.add(component);
}
for (Release release : releases) {
databaseConnector.add(release);
}
componentMap = ThriftUtils.getIdMap(components);
releaseMap = ThriftUtils.getIdMap(releases);
// Prepare the handler
handler = new ComponentDatabaseHandler(DatabaseSettings.getConfiguredHttpClient(), dbName, attachmentsDbName, moderator, releaseModerator);
}
use of org.eclipse.sw360.datahandler.couchdb.DatabaseConnector in project sw360portal by sw360.
the class ComponentSearchHandlerTest method setUp.
@Before
public void setUp() throws Exception {
assumeCanConnectTo(ThriftClients.BACKEND_URL + "/couchdblucene/");
components = new ArrayList<>();
Component component1 = new Component().setId("C1").setName("component1").setDescription("d1").setCreatedBy(email1);
component1.addToLanguages("C");
component1.addToCategories("library");
component1.addToOperatingSystems("linux");
component1.addToSoftwarePlatforms("boost");
component1.addToReleaseIds("R1A");
component1.addToReleaseIds("R1B");
component1.addToVendorNames("V1");
components.add(component1);
Component component2 = new Component().setId("C2").setName("component2").setDescription("d2").setCreatedBy(email2);
component2.addToLanguages("D");
component2.addToLanguages("C");
component2.addToCategories("test");
component2.addToOperatingSystems("test");
component2.addToSoftwarePlatforms("test");
component2.addToReleaseIds("R2A");
component2.addToReleaseIds("R2B");
component2.addToReleaseIds("R2C");
component1.addToVendorNames("V2");
components.add(component2);
Component component3 = new Component().setId("C3").setName("component3").setDescription("d3").setCreatedBy(email1);
component3.addToSubscribers(email1);
component3.addToLanguages("E");
components.add(component3);
// Create the database
TestUtils.createDatabase(DatabaseSettings.getConfiguredHttpClient(), dbName);
// Prepare the database
DatabaseConnector databaseConnector = new DatabaseConnector(DatabaseSettings.getConfiguredHttpClient(), dbName);
for (Component component : components) {
databaseConnector.add(component);
}
// Prepare the handler
searchHandler = new ComponentSearchHandler(DatabaseSettings.getConfiguredHttpClient(), dbName);
}
use of org.eclipse.sw360.datahandler.couchdb.DatabaseConnector in project sw360portal by sw360.
the class RemoteAttachmentDownloaderTest method setUp.
@Before
public void setUp() throws Exception {
DatabaseConnector databaseConnector = new DatabaseConnector(DatabaseSettings.getConfiguredHttpClient(), dbName);
attachmentConnector = new AttachmentConnector(DatabaseSettings.getConfiguredHttpClient(), dbName, downloadTimeout);
repository = new AttachmentRepository(databaseConnector);
garbage = new ArrayList<>();
}
Aggregations