Search in sources :

Example 6 with DatabaseConnector

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);
}
Also used : Project(org.eclipse.sw360.datahandler.thrift.projects.Project) DatabaseConnector(org.eclipse.sw360.datahandler.couchdb.DatabaseConnector) TestUtils.assertTestString(org.eclipse.sw360.datahandler.TestUtils.assertTestString) Component(org.eclipse.sw360.datahandler.thrift.components.Component) Release(org.eclipse.sw360.datahandler.thrift.components.Release) Before(org.junit.Before)

Example 7 with DatabaseConnector

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();
}
Also used : DatabaseConnector(org.eclipse.sw360.datahandler.couchdb.DatabaseConnector) AttachmentContent(org.eclipse.sw360.datahandler.thrift.attachments.AttachmentContent)

Example 8 with DatabaseConnector

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);
}
Also used : DatabaseConnector(org.eclipse.sw360.datahandler.couchdb.DatabaseConnector) ComponentDatabaseHandler(org.eclipse.sw360.datahandler.db.ComponentDatabaseHandler) Vendor(org.eclipse.sw360.datahandler.thrift.vendors.Vendor)

Example 9 with DatabaseConnector

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);
}
Also used : DatabaseConnector(org.eclipse.sw360.datahandler.couchdb.DatabaseConnector) Component(org.eclipse.sw360.datahandler.thrift.components.Component) ComponentSearchHandler(org.eclipse.sw360.datahandler.db.ComponentSearchHandler) Before(org.junit.Before)

Example 10 with DatabaseConnector

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<>();
}
Also used : DatabaseConnector(org.eclipse.sw360.datahandler.couchdb.DatabaseConnector) AttachmentConnector(org.eclipse.sw360.datahandler.couchdb.AttachmentConnector) Before(org.junit.Before)

Aggregations

DatabaseConnector (org.eclipse.sw360.datahandler.couchdb.DatabaseConnector)12 Before (org.junit.Before)7 Vendor (org.eclipse.sw360.datahandler.thrift.vendors.Vendor)4 Component (org.eclipse.sw360.datahandler.thrift.components.Component)3 Project (org.eclipse.sw360.datahandler.thrift.projects.Project)3 AttachmentConnector (org.eclipse.sw360.datahandler.couchdb.AttachmentConnector)2 ComponentDatabaseHandler (org.eclipse.sw360.datahandler.db.ComponentDatabaseHandler)2 AttachmentContent (org.eclipse.sw360.datahandler.thrift.attachments.AttachmentContent)2 Release (org.eclipse.sw360.datahandler.thrift.components.Release)2 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)1 TestUtils.assertTestString (org.eclipse.sw360.datahandler.TestUtils.assertTestString)1 ComponentSearchHandler (org.eclipse.sw360.datahandler.db.ComponentSearchHandler)1 ProjectDatabaseHandler (org.eclipse.sw360.datahandler.db.ProjectDatabaseHandler)1 SW360Exception (org.eclipse.sw360.datahandler.thrift.SW360Exception)1 ModerationRequest (org.eclipse.sw360.datahandler.thrift.moderation.ModerationRequest)1 TestObject (org.eclipse.sw360.testthrift.TestObject)1 CouchDbConnector (org.ektorp.CouchDbConnector)1 CouchDbInstance (org.ektorp.CouchDbInstance)1