use of com.eaglegenomics.simlims.core.Group in project miso-lims by miso-lims.
the class DefaultTransferServiceTest method validateRecipientChangeAllowed.
@Test
public void validateRecipientChangeAllowed() throws Exception {
Group group1 = makeGroup(1L);
setUser(false, group1);
Transfer before = makeTransfer(group1, "Recipient");
Transfer updated = copyTransfer(before);
updated.setRecipient("Changed");
List<ValidationError> errors = validate(updated, before);
assertNoError(errors, "Only administrators and members of the sender group can change recipient");
}
use of com.eaglegenomics.simlims.core.Group in project miso-lims by miso-lims.
the class DefaultTransferServiceTest method validateRecipientGroupChangeAllowed.
@Test
public void validateRecipientGroupChangeAllowed() throws Exception {
Group group1 = makeGroup(1L);
setUser(false, group1);
Transfer before = makeTransfer(group1, makeGroup(2L));
Transfer updated = copyTransfer(before);
updated.setRecipientGroup(makeGroup(3L));
List<ValidationError> errors = validate(updated, before);
assertNoError(errors, "Only administrators and members of the sender group can change recipient group");
}
use of com.eaglegenomics.simlims.core.Group 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 com.eaglegenomics.simlims.core.Group in project miso-lims by miso-lims.
the class Dtos method to.
public static Transfer to(@Nonnull TransferDto from) {
Transfer to = new Transfer();
setLong(to::setId, from.getId(), false);
setString(to::setTransferRequestName, from.getTransferRequestName());
setDateTime(to::setTransferTime, from.getTransferTime());
setObject(to::setSenderLab, LabImpl::new, from.getSenderLabId());
setObject(to::setSenderGroup, Group::new, from.getSenderGroupId());
setString(to::setRecipient, from.getRecipient());
setObject(to::setRecipientGroup, Group::new, from.getRecipientGroupId());
addTransferItems(to::getSampleTransfers, from.getItems(), EntityType.SAMPLE, TransferSample::new, SampleImpl::new, SampleBoxPosition::new, Sample::setBoxPosition);
addTransferItems(to::getLibraryTransfers, from.getItems(), EntityType.LIBRARY, TransferLibrary::new, LibraryImpl::new, LibraryBoxPosition::new, Library::setBoxPosition);
addTransferItems(to::getLibraryAliquotTransfers, from.getItems(), EntityType.LIBRARY_ALIQUOT, TransferLibraryAliquot::new, LibraryAliquot::new, LibraryAliquotBoxPosition::new, LibraryAliquot::setBoxPosition);
addTransferItems(to::getPoolTransfers, from.getItems(), EntityType.POOL, TransferPool::new, PoolImpl::new, PoolBoxPosition::new, Pool::setBoxPosition);
return to;
}
use of com.eaglegenomics.simlims.core.Group in project miso-lims by miso-lims.
the class Dtos method toReceiptTransfer.
private static <T extends Boxable, R extends TransferItem<T>> R toReceiptTransfer(@Nonnull ReceivableDto<T, R> from, @Nonnull T item) {
if (isStringEmptyOrNull(from.getReceivedTime())) {
return null;
}
R transferItem = from.makeTransferItem();
transferItem.setItem(item);
setBoolean(transferItem::setReceived, from.isReceived(), true);
setBoolean(transferItem::setQcPassed, from.isReceiptQcPassed(), true);
setString(transferItem::setQcNote, from.getReceiptQcNote());
Transfer transfer = new Transfer();
transferItem.setTransfer(transfer);
from.getTransferItemsFunction().apply(transfer).add(transferItem);
setDateTime(transfer::setTransferTime, from.getReceivedTime());
setObject(transfer::setSenderLab, LabImpl::new, from.getSenderLabId());
setObject(transfer::setRecipientGroup, Group::new, from.getRecipientGroupId());
return transferItem;
}
Aggregations