use of org.eclipse.sw360.datahandler.couchdb.DatabaseConnector in project sw360portal by sw360.
the class DatabaseTestSetup method main.
public static void main(String[] args) throws MalformedURLException {
DatabaseConnector db = new DatabaseConnector(DatabaseSettings.getConfiguredHttpClient(), DatabaseSettings.COUCH_DB_DATABASE);
Project project = new Project().setName("Test Project");
project.addToModerators("user1");
db.add(project);
ModerationRequest moderationRequest = new ModerationRequest();
moderationRequest.setDocumentId(project.id).setDocumentType(DocumentType.PROJECT);
moderationRequest.setRequestingUser("cedric.bodet@tngtech.com");
moderationRequest.addToModerators("cedric.bodet@tngtech.com");
db.add(moderationRequest);
}
use of org.eclipse.sw360.datahandler.couchdb.DatabaseConnector in project sw360portal by sw360.
the class ProjectHandlerTest method setUp.
@Before
public void setUp() throws Exception {
List<Project> projects = new ArrayList<>();
projects.add(new Project().setId("P1").setName("Project1").setBusinessUnit("AB CD EF").setCreatedBy("user1"));
projects.add(new Project().setId("P2").setName("Project2").setBusinessUnit("AB CD FE").setCreatedBy("user2"));
projects.get(1).addToContributors("user1");
projects.add(new Project().setId("P3").setName("Project3").setBusinessUnit("AB CD EF").setCreatedBy("user3"));
// 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);
}
// Create the connector
handler = new ProjectHandler();
}
use of org.eclipse.sw360.datahandler.couchdb.DatabaseConnector in project sw360portal by sw360.
the class DatabaseConnectorTest method setUp.
@Before
public void setUp() throws Exception {
// Create the test object
object = new TestObject();
object.setName("Test");
object.setText("This is some nice test text.");
// Initialize the mapper factory
factory = new MapperFactory(ImmutableList.<Class<?>>of(TestObject.class), Collections.<Class<?>>emptyList(), Maps.newHashMap());
// Default connector for testing
HttpClient httpClient = new StdHttpClient.Builder().url(COUCH_DB_URL).build();
CouchDbInstance dbInstance = new StdCouchDbInstance(httpClient);
// Create database if it does not exists
if (!dbInstance.checkIfDbExists(COUCH_DB_DATABASE)) {
dbInstance.createDatabase(COUCH_DB_DATABASE);
}
CouchDbConnector db = new StdCouchDbConnector(COUCH_DB_DATABASE, dbInstance, factory);
// Add the object
db.create(object);
// Save id and rev for teardown
id = object.getId();
rev = object.getRevision();
// Now create the actual database connector
connector = new DatabaseConnector(DatabaseTestProperties.getConfiguredHttpClient(), COUCH_DB_DATABASE, factory);
}
Aggregations