Search in sources :

Example 66 with Account

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);
}
Also used : Account(org.jbei.ice.storage.model.Account) Entry(org.jbei.ice.storage.model.Entry) EntryCreator(org.jbei.ice.lib.entry.EntryCreator) Part(org.jbei.ice.storage.model.Part) ArrayList(java.util.ArrayList) Folder(org.jbei.ice.storage.model.Folder) Test(org.junit.Test)

Example 67 with Account

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());
}
Also used : Account(org.jbei.ice.storage.model.Account) Entry(org.jbei.ice.storage.model.Entry) Test(org.junit.Test)

Example 68 with Account

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());
}
Also used : Account(org.jbei.ice.storage.model.Account) ByteArrayInputStream(java.io.ByteArrayInputStream) SequenceInfo(org.jbei.ice.lib.dto.entry.SequenceInfo) Test(org.junit.Test)

Example 69 with Account

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());
}
Also used : Account(org.jbei.ice.storage.model.Account) PartSample(org.jbei.ice.lib.dto.sample.PartSample) StorageLocation(org.jbei.ice.lib.dto.StorageLocation) Strain(org.jbei.ice.storage.model.Strain) Test(org.junit.Test)

Example 70 with Account

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());
}
Also used : Account(org.jbei.ice.storage.model.Account) GroupController(org.jbei.ice.lib.group.GroupController) AccessPermission(org.jbei.ice.lib.dto.access.AccessPermission) FolderDetails(org.jbei.ice.lib.dto.folder.FolderDetails) PermissionsController(org.jbei.ice.lib.access.PermissionsController) Test(org.junit.Test)

Aggregations

Account (org.jbei.ice.storage.model.Account)153 Test (org.junit.Test)71 Group (org.jbei.ice.storage.model.Group)24 Entry (org.jbei.ice.storage.model.Entry)21 Strain (org.jbei.ice.storage.model.Strain)20 PartData (org.jbei.ice.lib.dto.entry.PartData)18 Folder (org.jbei.ice.storage.model.Folder)18 ArrayList (java.util.ArrayList)16 UserGroup (org.jbei.ice.lib.dto.group.UserGroup)16 PermissionException (org.jbei.ice.lib.access.PermissionException)11 EntryCreator (org.jbei.ice.lib.entry.EntryCreator)10 Plasmid (org.jbei.ice.storage.model.Plasmid)10 AccountTransfer (org.jbei.ice.lib.account.AccountTransfer)8 AccessPermission (org.jbei.ice.lib.dto.access.AccessPermission)8 FolderDetails (org.jbei.ice.lib.dto.folder.FolderDetails)8 DAOException (org.jbei.ice.storage.DAOException)8 RemotePartner (org.jbei.ice.storage.model.RemotePartner)8 HibernateException (org.hibernate.HibernateException)7 HashSet (java.util.HashSet)6 Part (org.jbei.ice.storage.model.Part)6