Search in sources :

Example 1 with UserImpl

use of uk.ac.bbsrc.tgac.miso.core.data.impl.UserImpl in project miso-lims by miso-lims.

the class DefaultTransferServiceTest method setUser.

private void setUser(boolean isAdmin, Group... groups) throws IOException {
    User user = new UserImpl();
    user.setId(1L);
    Mockito.when(authorizationManager.getCurrentUser()).thenReturn(user);
    Mockito.when(authorizationManager.isAdminUser()).thenReturn(isAdmin);
    Mockito.when(authorizationManager.isGroupMember(Mockito.any())).thenReturn(false);
    if (groups.length > 0) {
        for (Group group : groups) {
            Mockito.when(authorizationManager.isGroupMember(group)).thenReturn(true);
        }
    }
}
Also used : Group(com.eaglegenomics.simlims.core.Group) User(com.eaglegenomics.simlims.core.User) UserImpl(uk.ac.bbsrc.tgac.miso.core.data.impl.UserImpl)

Example 2 with UserImpl

use of uk.ac.bbsrc.tgac.miso.core.data.impl.UserImpl in project miso-lims by miso-lims.

the class DefaultSampleServiceTest method testDeleteNote.

@Test
public void testDeleteNote() throws Exception {
    Sample paramSample = new SampleImpl();
    paramSample.setId(1L);
    paramSample.setAlias("paramSample");
    Sample dbSample = new SampleImpl();
    dbSample.setId(paramSample.getId());
    dbSample.setAlias("persistedSample");
    Note note = new Note();
    note.setId(3L);
    User owner = new UserImpl();
    owner.setId(5L);
    note.setOwner(owner);
    dbSample.addNote(note);
    Mockito.when(sampleStore.get(paramSample.getId())).thenReturn(dbSample);
    sut.deleteNote(paramSample, note.getId());
    Mockito.verify(authorizationManager).throwIfNonAdminOrMatchingOwner(owner);
    ArgumentCaptor<Sample> capture = ArgumentCaptor.forClass(Sample.class);
    Mockito.verify(sampleStore).update(capture.capture());
    Sample savedSample = capture.getValue();
    assertTrue(savedSample.getNotes().isEmpty());
}
Also used : User(com.eaglegenomics.simlims.core.User) DetailedSample(uk.ac.bbsrc.tgac.miso.core.data.DetailedSample) Sample(uk.ac.bbsrc.tgac.miso.core.data.Sample) Note(com.eaglegenomics.simlims.core.Note) UserImpl(uk.ac.bbsrc.tgac.miso.core.data.impl.UserImpl) SampleImpl(uk.ac.bbsrc.tgac.miso.core.data.impl.SampleImpl) Test(org.junit.Test)

Example 3 with UserImpl

use of uk.ac.bbsrc.tgac.miso.core.data.impl.UserImpl in project miso-lims by miso-lims.

the class Dtos method to.

public static User to(@Nonnull UserDto dto) {
    User user = new UserImpl();
    setLong(user::setId, dto.getId(), false);
    setString(user::setFullName, dto.getFullName());
    setString(user::setLoginName, dto.getLoginName());
    setString(user::setEmail, dto.getEmail());
    setBoolean(user::setAdmin, dto.isAdmin(), false);
    setBoolean(user::setInternal, dto.isInternal(), false);
    setBoolean(user::setActive, dto.isActive(), false);
    return user;
}
Also used : User(com.eaglegenomics.simlims.core.User) UserImpl(uk.ac.bbsrc.tgac.miso.core.data.impl.UserImpl)

Example 4 with UserImpl

use of uk.ac.bbsrc.tgac.miso.core.data.impl.UserImpl in project miso-lims by miso-lims.

the class HibernateLabDaoIT method testAddLab.

@Test
public void testAddLab() {
    Lab l = new LabImpl();
    l.setAlias("NewLab");
    User user = new UserImpl();
    user.setId(1L);
    l.setCreator(user);
    l.setLastModifier(user);
    Date now = new Date();
    l.setCreationTime(now);
    l.setLastModified(now);
    final long newId = dao.create(l);
    Lab saved = dao.get(newId);
    assertNotNull(saved);
    assertEquals(l.getAlias(), saved.getAlias());
}
Also used : User(com.eaglegenomics.simlims.core.User) UserImpl(uk.ac.bbsrc.tgac.miso.core.data.impl.UserImpl) LabImpl(uk.ac.bbsrc.tgac.miso.core.data.impl.LabImpl) Lab(uk.ac.bbsrc.tgac.miso.core.data.Lab) Date(java.util.Date) Test(org.junit.Test) AbstractDAOTest(uk.ac.bbsrc.tgac.miso.AbstractDAOTest)

Example 5 with UserImpl

use of uk.ac.bbsrc.tgac.miso.core.data.impl.UserImpl in project miso-lims by miso-lims.

the class HibernateLibraryAliquotDaoIT method testSaveNew.

@Test
public void testSaveNew() throws IOException {
    final LibraryAliquot ld = new LibraryAliquot();
    final Library lib = new LibraryImpl();
    UserImpl user = new UserImpl();
    user.setId(1L);
    user.setFullName("moi");
    lib.setId(1L);
    ld.setCreator(user);
    ld.setLastModifier(user);
    ld.setLibrary(lib);
    ld.setConcentration(new BigDecimal("12.5"));
    ld.setCreationDate(new Date());
    ld.setCreationTime(new Date());
    ld.setName("nom de plume");
    ld.setAlias("TEST");
    Long newId = dao.save(ld);
    final LibraryAliquot saved = dao.get(newId);
    assertNotNull(saved);
    assertEquals(new BigDecimal("12.5"), saved.getConcentration());
}
Also used : LibraryImpl(uk.ac.bbsrc.tgac.miso.core.data.impl.LibraryImpl) UserImpl(uk.ac.bbsrc.tgac.miso.core.data.impl.UserImpl) LibraryAliquot(uk.ac.bbsrc.tgac.miso.core.data.impl.LibraryAliquot) Library(uk.ac.bbsrc.tgac.miso.core.data.Library) BigDecimal(java.math.BigDecimal) Date(java.util.Date) AbstractDAOTest(uk.ac.bbsrc.tgac.miso.AbstractDAOTest) Test(org.junit.Test)

Aggregations

UserImpl (uk.ac.bbsrc.tgac.miso.core.data.impl.UserImpl)29 User (com.eaglegenomics.simlims.core.User)25 Test (org.junit.Test)17 AbstractDAOTest (uk.ac.bbsrc.tgac.miso.AbstractDAOTest)16 Project (uk.ac.bbsrc.tgac.miso.core.data.Project)10 ProjectImpl (uk.ac.bbsrc.tgac.miso.core.data.impl.ProjectImpl)10 Date (java.util.Date)7 Sample (uk.ac.bbsrc.tgac.miso.core.data.Sample)5 DetailedSample (uk.ac.bbsrc.tgac.miso.core.data.DetailedSample)4 SampleImpl (uk.ac.bbsrc.tgac.miso.core.data.impl.SampleImpl)4 BigDecimal (java.math.BigDecimal)3 Group (com.eaglegenomics.simlims.core.Group)2 Note (com.eaglegenomics.simlims.core.Note)2 Box (uk.ac.bbsrc.tgac.miso.core.data.Box)2 BoxSize (uk.ac.bbsrc.tgac.miso.core.data.BoxSize)2 BoxUse (uk.ac.bbsrc.tgac.miso.core.data.BoxUse)2 Library (uk.ac.bbsrc.tgac.miso.core.data.Library)2 BoxImpl (uk.ac.bbsrc.tgac.miso.core.data.impl.BoxImpl)2 LibraryImpl (uk.ac.bbsrc.tgac.miso.core.data.impl.LibraryImpl)2 PoolImpl (uk.ac.bbsrc.tgac.miso.core.data.impl.PoolImpl)2