use of uk.ac.bbsrc.tgac.miso.core.data.impl.UserImpl in project miso-lims by miso-lims.
the class DefaultAuthorizationManager method getCurrentUser.
@Override
public User getCurrentUser() throws IOException {
Authentication auth = securityContextHolderStrategy.getContext().getAuthentication();
if (auth == null) {
return null;
}
User user = userService.getByLoginName(auth.getName());
if (user == null && auth.isAuthenticated()) {
user = new UserImpl();
user.setAdmin(true);
user.setActive(true);
}
return user;
}
use of uk.ac.bbsrc.tgac.miso.core.data.impl.UserImpl in project miso-lims by miso-lims.
the class HibernateSampleDaoIT method testCreate.
@Test
public void testCreate() throws Exception {
Sample sample = new SampleImpl();
String sampleName = "latestSample32";
sample.setName(sampleName);
sample.setAlias("alias32LK");
sample.setProject(dao.get(1L).getProject());
sample.setSampleType("GENOMIC");
ScientificName scientificName = (ScientificName) currentSession().get(ScientificName.class, 1L);
sample.setScientificName(scientificName);
User user = new UserImpl();
user.setId(1L);
Date now = new Date();
sample.setCreator(user);
sample.setCreationTime(now);
sample.setLastModifier(user);
sample.setLastModified(now);
int sizeBefore = dao.list().size();
long id = dao.create(sample);
clearSession();
Sample retrieved = dao.get(id);
assertEquals("did not insert sample", sizeBefore + 1, dao.list().size());
assertEquals("sample name does not match", sampleName, retrieved.getName());
}
use of uk.ac.bbsrc.tgac.miso.core.data.impl.UserImpl in project miso-lims by miso-lims.
the class HibernateSampleNumberPerProjectDaoIT method testNextNumberPaddingDecreasesTest.
@Test
public void testNextNumberPaddingDecreasesTest() throws Exception {
Project project = new ProjectImpl();
project.setId(1L);
User user = new UserImpl();
user.setId(1L);
String s1 = sampleNumberPerProjectDao.nextNumber(project, user, PRO1_PARTIAL_ALIAS);
assertEquals("0002", s1);
String s2 = sampleNumberPerProjectDao.nextNumber(project, user, PRO1_PARTIAL_ALIAS);
assertEquals("0003", s2);
String s3 = sampleNumberPerProjectDao.nextNumber(project, user, PRO1_PARTIAL_ALIAS);
assertEquals("0004", s3);
String s4 = sampleNumberPerProjectDao.nextNumber(project, user, PRO1_PARTIAL_ALIAS);
assertEquals("0005", s4);
String s5 = sampleNumberPerProjectDao.nextNumber(project, user, PRO1_PARTIAL_ALIAS);
assertEquals("0006", s5);
String s6 = sampleNumberPerProjectDao.nextNumber(project, user, PRO1_PARTIAL_ALIAS);
assertEquals("0007", s6);
String s7 = sampleNumberPerProjectDao.nextNumber(project, user, PRO1_PARTIAL_ALIAS);
assertEquals("0008", s7);
String s8 = sampleNumberPerProjectDao.nextNumber(project, user, PRO1_PARTIAL_ALIAS);
assertEquals("0009", s8);
String s9 = sampleNumberPerProjectDao.nextNumber(project, user, PRO1_PARTIAL_ALIAS);
assertEquals("0010", s9);
String s10 = sampleNumberPerProjectDao.nextNumber(project, user, PRO1_PARTIAL_ALIAS);
assertEquals("0011", s10);
String s11 = sampleNumberPerProjectDao.nextNumber(project, user, PRO1_PARTIAL_ALIAS);
assertEquals("0012", s11);
}
use of uk.ac.bbsrc.tgac.miso.core.data.impl.UserImpl in project miso-lims by miso-lims.
the class HibernateSampleNumberPerProjectDaoIT method testExceedPadding.
@Test
public void testExceedPadding() throws Exception {
Project project = new ProjectImpl();
project.setId(3L);
User user = new UserImpl();
user.setId(1L);
String s = sampleNumberPerProjectDao.nextNumber(project, user, PRO3_PARTIAL_ALIAS);
assertEquals("10000", s);
String s2 = sampleNumberPerProjectDao.nextNumber(project, user, PRO3_PARTIAL_ALIAS);
assertEquals("10001", s2);
}
use of uk.ac.bbsrc.tgac.miso.core.data.impl.UserImpl in project miso-lims by miso-lims.
the class HibernateSampleNumberPerProjectDaoIT method testNextNumberMultipleIncrements.
@Test
public void testNextNumberMultipleIncrements() throws Exception {
Project project = new ProjectImpl();
project.setId(1L);
User user = new UserImpl();
user.setId(1L);
String s1 = sampleNumberPerProjectDao.nextNumber(project, user, PRO1_PARTIAL_ALIAS);
assertEquals("0002", s1);
String s2 = sampleNumberPerProjectDao.nextNumber(project, user, PRO1_PARTIAL_ALIAS);
assertEquals("0003", s2);
String s3 = sampleNumberPerProjectDao.nextNumber(project, user, PRO1_PARTIAL_ALIAS);
assertEquals("0004", s3);
}
Aggregations