use of org.jbei.ice.storage.model.Account in project ice by JBEI.
the class CustomFieldsTest method testGetPartsByFields.
@Test
public void testGetPartsByFields() throws Exception {
// create part
Account account = AccountCreator.createTestAccount("testGetPartsByFields", false);
final String userId = account.getEmail();
Strain strain = TestEntryCreator.createTestStrain(account);
Assert.assertNotNull(strain);
// create fields for strain
long strainId = strain.getId();
fields.createField(userId, strainId, new CustomField(strainId, "type", "promoter"));
fields.createField(userId, strainId, new CustomField(strainId, "strength", "weak"));
// search for strength:weak
List<CustomField> searchFields = new ArrayList<>();
searchFields.add(new CustomField("strength", "weak"));
List<PartData> results = fields.getPartsByFields(userId, searchFields);
Assert.assertEquals(1, results.size());
// create additional entry
Plasmid plasmid = TestEntryCreator.createTestPlasmid(account);
Assert.assertNotNull(plasmid);
long plasmidId = plasmid.getId();
fields.createField(userId, plasmidId, new CustomField(plasmidId, "type", "promoter"));
fields.createField(userId, plasmidId, new CustomField(plasmidId, "strength", "strong"));
searchFields.clear();
searchFields.add(new CustomField("strength", "strong"));
results = fields.getPartsByFields(userId, searchFields);
Assert.assertEquals(1, results.size());
Assert.assertEquals(plasmid.getId(), results.get(0).getId());
// search for type:promoter
searchFields.clear();
searchFields.add(new CustomField("type", "promoter"));
results = fields.getPartsByFields(userId, searchFields);
Assert.assertEquals(2, results.size());
Assert.assertTrue(strain.getId() == results.get(0).getId() || results.get(1).getId() == strain.getId());
// test two
searchFields.clear();
searchFields.add(new CustomField(strainId, "type", "promoter"));
searchFields.add(new CustomField(strainId, "strength", "weak"));
results = fields.getPartsByFields(userId, searchFields);
Assert.assertNotNull(results);
Assert.assertTrue(results.size() == 1);
Assert.assertEquals(strain.getId(), results.get(0).getId());
}
use of org.jbei.ice.storage.model.Account in project ice by JBEI.
the class CustomFieldsTest method testGetFieldsForPart.
@Test
public void testGetFieldsForPart() throws Exception {
Account account = AccountCreator.createTestAccount("testGetFieldsForPart", false);
Assert.assertNotNull(account);
final String userId = account.getEmail();
Strain strain = TestEntryCreator.createTestStrain(account);
Assert.assertNotNull(strain);
HashSet<Long> ids = new HashSet<>();
for (int i = 1; i <= 10; i += 1) {
CustomField field = new CustomField(strain.getId(), "name" + i, "value" + i);
long id = fields.createField(userId, strain.getId(), field).getId();
ids.add(id);
}
List<CustomField> result = fields.getFieldsForPart(userId, strain.getId());
Assert.assertNotNull(result);
Assert.assertTrue(result.size() == 10);
for (CustomField field : result) {
Assert.assertTrue(ids.contains(field.getId()));
}
}
use of org.jbei.ice.storage.model.Account in project ice by JBEI.
the class BulkUploadControllerTest method testAutoUpdateBulkUpload.
@Test
public void testAutoUpdateBulkUpload() throws Exception {
EntryType type = EntryType.STRAIN;
Account account = AccountCreator.createTestAccount("testAutoUpdateBulkUpload", false);
BulkUploadAutoUpdate autoUpdate = new BulkUploadAutoUpdate(EntryType.STRAIN);
autoUpdate.getKeyValue().put(EntryField.LINKS, "google");
// first auto update. expect it to create a new bulk upload and entry
autoUpdate = controller.autoUpdateBulkUpload(account.getEmail(), autoUpdate, type);
Assert.assertNotNull(autoUpdate);
long entryId = autoUpdate.getEntryId();
long bulkId = autoUpdate.getBulkUploadId();
Assert.assertTrue(entryId > 0);
Assert.assertTrue(bulkId > 0);
BulkUploadInfo bulkUploadInfo = controller.getBulkImport(account.getEmail(), bulkId, 0, 1000);
Assert.assertNotNull(bulkUploadInfo);
EntryDAO dao = DAOFactory.getEntryDAO();
Entry entry = dao.get(entryId);
Assert.assertNotNull(entry);
Assert.assertNotNull(entry.getLinks());
Assert.assertEquals(1, entry.getLinks().size());
autoUpdate = new BulkUploadAutoUpdate(EntryType.PLASMID);
// auto update: expect plasmid and bulk upload with no fields set
autoUpdate = controller.autoUpdateBulkUpload(account.getEmail(), autoUpdate, type);
Assert.assertNotNull(autoUpdate);
entryId = autoUpdate.getEntryId();
bulkId = autoUpdate.getBulkUploadId();
Assert.assertTrue(entryId > 0);
Assert.assertTrue(bulkId > 0);
entry = dao.get(entryId);
Assert.assertNotNull(entry);
}
use of org.jbei.ice.storage.model.Account in project ice by JBEI.
the class BulkUploadControllerTest method testRevertSubmitted.
@Test
public void testRevertSubmitted() throws Exception {
Account account = AccountCreator.createTestAccount("testRevertSubmitted", false);
Account admin = AccountCreator.createTestAccount("testRevertSubmitted+Admin", true);
BulkUploadAutoUpdate autoUpdate = new BulkUploadAutoUpdate(EntryType.ARABIDOPSIS);
autoUpdate.getKeyValue().put(EntryField.NAME, "JBEI-0001");
autoUpdate.getKeyValue().put(EntryField.SUMMARY, "this is a test");
autoUpdate.getKeyValue().put(EntryField.PI, "test");
autoUpdate.getKeyValue().put(EntryField.STATUS, StatusType.COMPLETE.toString());
autoUpdate.getKeyValue().put(EntryField.BIO_SAFETY_LEVEL, BioSafetyOption.LEVEL_TWO.getValue());
autoUpdate.getKeyValue().put(EntryField.SELECTION_MARKERS, "test");
autoUpdate = controller.autoUpdateBulkUpload(account.getEmail(), autoUpdate, EntryType.ARABIDOPSIS);
Assert.assertNotNull(autoUpdate);
Assert.assertTrue(autoUpdate.getEntryId() > 0);
Assert.assertTrue(autoUpdate.getBulkUploadId() > 0);
Assert.assertTrue(autoUpdate.getLastUpdate() != null);
Assert.assertNotNull(controller.getBulkImport(account.getEmail(), autoUpdate.getBulkUploadId(), 0, 0));
// try to revert. not submitted
Assert.assertFalse(controller.revertSubmitted(admin, autoUpdate.getBulkUploadId()));
// actual submission (update status)
BulkEntryCreator bulkEntryCreator = new BulkEntryCreator();
bulkEntryCreator.updateStatus(account.getEmail(), autoUpdate.getBulkUploadId(), BulkUploadStatus.PENDING_APPROVAL);
BulkUploadInfo info = controller.getBulkImport(account.getEmail(), autoUpdate.getBulkUploadId(), 0, 0);
Assert.assertNotNull(info);
Assert.assertTrue(controller.revertSubmitted(admin, autoUpdate.getBulkUploadId()));
}
use of org.jbei.ice.storage.model.Account in project ice by JBEI.
the class BulkUploadControllerTest method testApproveBulkImport.
@Test
public void testApproveBulkImport() throws Exception {
Account account = AccountCreator.createTestAccount("testApproveBulkImport", true);
//
// test strain with plasmid
//
// create bulk upload draft
String userId = account.getEmail();
BulkUploadInfo testInfo = new BulkUploadInfo();
testInfo.setName("testing");
testInfo.setType(EntryType.STRAIN.getName());
testInfo = controller.create(userId, testInfo);
Assert.assertNotNull(testInfo);
// create entry for upload
BulkEntryCreator creator = new BulkEntryCreator();
PartData strainData = new PartData(EntryType.STRAIN);
strainData.setName("testStrain");
ArrayList<String> selectionMarkers = new ArrayList<>();
selectionMarkers.add("Spectinomycin");
strainData.setSelectionMarkers(selectionMarkers);
strainData.setBioSafetyLevel(1);
strainData.setStatus("Complete");
strainData.setShortDescription("testing bulk upload");
strainData.setCreator(account.getFullName());
strainData.setCreatorEmail(account.getEmail());
strainData.setPrincipalInvestigator("PI");
PartData plasmidData = new PartData(EntryType.PLASMID);
plasmidData.setName("testPlasmid");
selectionMarkers.clear();
selectionMarkers.add("Spectinomycin");
plasmidData.setSelectionMarkers(selectionMarkers);
plasmidData.setBioSafetyLevel(1);
// plasmidData.setStatus("In Progress");
plasmidData.setShortDescription("testing bulk upload with strain with plasmid");
plasmidData.setCreator(account.getFullName());
plasmidData.setCreatorEmail(account.getEmail());
plasmidData.setPrincipalInvestigator("PI");
strainData.getLinkedParts().add(plasmidData);
PartData returnStrainData = creator.createEntry(userId, testInfo.getId(), strainData);
Assert.assertNotNull(returnStrainData);
plasmidData.setStatus("In Progress");
plasmidData = creator.updateEntry(userId, testInfo.getId(), returnStrainData.getLinkedParts().get(0).getId(), plasmidData);
Assert.assertNotNull(plasmidData);
// testInfo = controller.submitBulkImportDraft(userId, testInfo.getId());
// Assert.assertNotNull(testInfo);
// Assert.assertEquals(testInfo.getStatus(), BulkUploadStatus.PENDING_APPROVAL);
}
Aggregations