use of org.jbei.ice.storage.model.Account in project ice by JBEI.
the class FolderDAOTest method testGetFolderContents.
@Test
public void testGetFolderContents() throws Exception {
Account account = AccountCreator.createTestAccount("testGetFolderContents", false);
String email = account.getEmail();
// create test folder
Folder folder = createFolderObject("testGetFolderContents");
folder = dao.create(folder);
Assert.assertNotNull(folder);
List<Entry> entries = new ArrayList<>();
EntryCreator creator = new EntryCreator();
// create 10 entries
for (int i = 0; i < 10; i += 1) {
Part part = new Part();
part.setName("name" + i);
part.setOwnerEmail(email);
part.setAlias("alias" + i);
part.setShortDescription("short description");
Entry entry = creator.createEntry(account, part, null);
entries.add(entry);
}
// add entries to folder
folder = dao.addFolderContents(folder, entries);
Assert.assertNotNull(folder);
}
use of org.jbei.ice.storage.model.Account in project ice by JBEI.
the class EntryDAOTest method testGet.
@Test
public void testGet() throws Exception {
Account account = AccountCreator.createTestAccount("testGet", false);
long id = TestEntryCreator.createTestPart(account.getEmail());
Entry entry = entryDAO.get(id);
Assert.assertNotNull(entry);
Assert.assertEquals(id, entry.getId());
}
use of org.jbei.ice.storage.model.Account in project ice by JBEI.
the class PartSequenceTest method testParseSequence.
@Test
public void testParseSequence() throws Exception {
Account account = AccountCreator.createTestAccount("PartSequenceTest.testParseSequence", false);
PartSequence partSequence = new PartSequence(account.getEmail(), EntryType.PART);
ByteArrayInputStream inputStream = new ByteArrayInputStream(fasta.getBytes());
SequenceInfo sequenceInfo = partSequence.parseSequenceFile(inputStream, "fasta.fa");
Assert.assertNotNull(sequenceInfo);
Assert.assertNotNull(sequenceInfo.getSequence());
}
use of org.jbei.ice.storage.model.Account in project ice by JBEI.
the class SampleServiceTest method testDelete.
@Test
public void testDelete() throws Exception {
Account account = AccountCreator.createTestAccount("testDelete", false);
String userId = account.getEmail();
// ----- CASE #1 -----
Strain strain1 = TestEntryCreator.createTestStrain(account);
PartSample partSample1 = new PartSample();
partSample1.setLabel("testForShelfScheme1");
// well
StorageLocation well = new StorageLocation();
well.setDisplay("well");
well.setType(SampleType.WELL);
// box
StorageLocation box = new StorageLocation();
box.setDisplay("box");
box.setType(SampleType.BOX_INDEXED);
box.setChild(well);
// shelf
StorageLocation shelf = new StorageLocation();
shelf.setDisplay("shelf");
shelf.setType(SampleType.SHELF);
shelf.setChild(box);
partSample1.setLocation(shelf);
partSample1 = service.createSample(userId, strain1.getRecordId(), partSample1, null);
Assert.assertNotNull(partSample1);
// fetch
List<PartSample> samples1 = service.retrieveEntrySamples(userId, Long.toString(strain1.getId()));
Assert.assertEquals(1, samples1.size());
StorageLocation location1 = samples1.get(0).getLocation();
// delete
Assert.assertTrue(service.delete(userId, strain1.getId(), samples1.get(0).getId()));
Assert.assertNull(DAOFactory.getStorageDAO().get(location1.getId()));
// ----- CASE 2 -----
Strain strain2 = TestEntryCreator.createTestStrain(account);
PartSample partSample2 = new PartSample();
partSample2.setLabel("testForPlateScheme2");
// tube2
StorageLocation tube2 = new StorageLocation();
tube2.setDisplay("tube2");
tube2.setType(SampleType.TUBE);
// well
StorageLocation well2 = new StorageLocation();
well2.setDisplay("well2");
well2.setType(SampleType.WELL);
well2.setChild(tube2);
// plate2
StorageLocation plate2 = new StorageLocation();
plate2.setDisplay("plate2");
plate2.setType(SampleType.PLATE96);
plate2.setChild(well2);
partSample2.setLocation(plate2);
partSample2 = service.createSample(userId, Long.toString(strain2.getId()), partSample2, null);
Assert.assertNotNull(partSample2);
// ----- CASE 3 -----
PartSample partSample3 = new PartSample();
partSample3.setLabel("testForPlateScheme3");
// tube2
StorageLocation tube3 = new StorageLocation();
tube3.setDisplay("tube3");
tube3.setType(SampleType.TUBE);
// well
StorageLocation well3 = new StorageLocation();
well3.setDisplay("well3");
well3.setType(SampleType.WELL);
well3.setChild(tube3);
// plate2
StorageLocation plate3 = new StorageLocation();
plate3.setDisplay("plate3");
plate3.setType(SampleType.PLATE96);
plate3.setChild(well3);
partSample3.setLocation(plate3);
partSample3 = service.createSample(userId, Long.toString(strain2.getId()), partSample3, null);
Assert.assertNotNull(partSample3);
// fetch
List<PartSample> samples3 = service.retrieveEntrySamples(userId, Long.toString(strain2.getId()));
Assert.assertEquals(2, samples3.size());
StorageLocation location3 = samples3.get(1).getLocation();
// delete #2 and #3 consequently
Assert.assertTrue(service.delete(userId, strain2.getId(), samples3.get(1).getId()));
Assert.assertNull(DAOFactory.getStorageDAO().get(location3.getId()));
List<PartSample> samples2 = service.retrieveEntrySamples(userId, Long.toString(strain2.getId()));
Assert.assertEquals(1, samples2.size());
StorageLocation location2 = samples2.get(0).getLocation();
Assert.assertTrue(service.delete(userId, strain2.getId(), samples2.get(0).getId()));
Assert.assertNull(DAOFactory.getStorageDAO().get(location2.getId()));
List<PartSample> samplesEmpty = service.retrieveEntrySamples(userId, Long.toString(strain2.getId()));
Assert.assertEquals(0, samplesEmpty.size());
}
use of org.jbei.ice.storage.model.Account in project ice by JBEI.
the class FolderControllerTest method testGetPublicFolders.
@Test
public void testGetPublicFolders() throws Exception {
Account account = AccountCreator.createTestAccount("testGetPublicFolders", false);
Assert.assertNotNull(account);
String userId = account.getEmail();
FolderDetails details = new FolderDetails();
details.setName("test1");
details = controller.createPersonalFolder(userId, details);
Assert.assertNotNull(details);
PermissionsController permissionsController = new PermissionsController();
AccessPermission accessPermission = new AccessPermission();
accessPermission.setArticle(AccessPermission.Article.GROUP);
long publicGroupId = new GroupController().createOrRetrievePublicGroup().getId();
accessPermission.setArticleId(publicGroupId);
accessPermission.setType(AccessPermission.Type.READ_FOLDER);
accessPermission.setTypeId(details.getId());
permissionsController.addPermission(userId, accessPermission);
ArrayList<FolderDetails> results = controller.getPublicFolders();
Assert.assertFalse(results.isEmpty());
Assert.assertEquals(details.getName(), results.get(0).getName());
}
Aggregations