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);
}
}
}
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());
}
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;
}
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());
}
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());
}
Aggregations