Search in sources :

Example 1 with ValidationError

use of uk.ac.bbsrc.tgac.miso.core.service.exception.ValidationError in project miso-lims by miso-lims.

the class DefaultTransferServiceTest method validateSenderTypeChangeTwo.

@Test
public void validateSenderTypeChangeTwo() throws Exception {
    Transfer before = makeTransfer(makeGroup(1L), makeGroup(2L));
    Transfer updated = copyTransfer(before);
    updated.setSenderGroup(null);
    updated.setSenderLab(makeLab(1L));
    List<ValidationError> errors = validate(updated, before);
    assertError(errors, "Cannot change sender between internal (group) and external (lab)");
}
Also used : Transfer(uk.ac.bbsrc.tgac.miso.core.data.impl.transfer.Transfer) ValidationError(uk.ac.bbsrc.tgac.miso.core.service.exception.ValidationError) Test(org.junit.Test)

Example 2 with ValidationError

use of uk.ac.bbsrc.tgac.miso.core.service.exception.ValidationError in project miso-lims by miso-lims.

the class DefaultTransferServiceTest method testValidateFirstReceipt.

@Test
public void testValidateFirstReceipt() throws Exception {
    Transfer transfer = makeTransfer(makeLab(1L), makeGroup(1L));
    addTransferSample(transfer, makeSample(1L));
    List<ValidationError> errors = validate(transfer, null);
    assertTrue(errors.isEmpty());
}
Also used : Transfer(uk.ac.bbsrc.tgac.miso.core.data.impl.transfer.Transfer) ValidationError(uk.ac.bbsrc.tgac.miso.core.service.exception.ValidationError) Test(org.junit.Test)

Example 3 with ValidationError

use of uk.ac.bbsrc.tgac.miso.core.service.exception.ValidationError in project miso-lims by miso-lims.

the class DefaultTransferServiceTest method validateRecipientTypeChangeOne.

@Test
public void validateRecipientTypeChangeOne() throws Exception {
    Transfer before = makeTransfer(makeGroup(1L), makeGroup(2L));
    Transfer updated = copyTransfer(before);
    updated.setRecipientGroup(null);
    updated.setRecipient("Recipient");
    List<ValidationError> errors = validate(updated, before);
    assertError(errors, "Cannot change recipient between internal (group) and external (named)");
}
Also used : Transfer(uk.ac.bbsrc.tgac.miso.core.data.impl.transfer.Transfer) ValidationError(uk.ac.bbsrc.tgac.miso.core.service.exception.ValidationError) Test(org.junit.Test)

Example 4 with ValidationError

use of uk.ac.bbsrc.tgac.miso.core.service.exception.ValidationError in project miso-lims by miso-lims.

the class DefaultTransferServiceTest method testValidateSingleReceipt.

@Test
public void testValidateSingleReceipt() throws Exception {
    Sample sample = makeSample(1L);
    Transfer previousReceipt = makeTransfer(makeLab(1L), makeGroup(1L));
    previousReceipt.setId(1L);
    addTransferSample(previousReceipt, sample);
    Transfer transfer = makeTransfer(makeLab(1L), makeGroup(1L));
    addTransferSample(transfer, sample);
    List<ValidationError> errors = validate(transfer, null);
    assertError(errors, "Items can only have one receipt (external lab to internal group) transfer");
}
Also used : Sample(uk.ac.bbsrc.tgac.miso.core.data.Sample) TransferSample(uk.ac.bbsrc.tgac.miso.core.data.impl.transfer.TransferSample) Transfer(uk.ac.bbsrc.tgac.miso.core.data.impl.transfer.Transfer) ValidationError(uk.ac.bbsrc.tgac.miso.core.service.exception.ValidationError) Test(org.junit.Test)

Example 5 with ValidationError

use of uk.ac.bbsrc.tgac.miso.core.service.exception.ValidationError 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");
}
Also used : Group(com.eaglegenomics.simlims.core.Group) Transfer(uk.ac.bbsrc.tgac.miso.core.data.impl.transfer.Transfer) ValidationError(uk.ac.bbsrc.tgac.miso.core.service.exception.ValidationError) Test(org.junit.Test)

Aggregations

ValidationError (uk.ac.bbsrc.tgac.miso.core.service.exception.ValidationError)71 ValidationException (uk.ac.bbsrc.tgac.miso.core.service.exception.ValidationException)29 Transfer (uk.ac.bbsrc.tgac.miso.core.data.impl.transfer.Transfer)24 Test (org.junit.Test)22 ArrayList (java.util.ArrayList)16 ValidationResult (uk.ac.bbsrc.tgac.miso.core.service.exception.ValidationResult)12 List (java.util.List)9 IOException (java.io.IOException)8 HashSet (java.util.HashSet)8 Set (java.util.Set)8 Autowired (org.springframework.beans.factory.annotation.Autowired)8 Service (org.springframework.stereotype.Service)8 Transactional (org.springframework.transaction.annotation.Transactional)8 AuthorizationManager (uk.ac.bbsrc.tgac.miso.core.security.AuthorizationManager)7 NamingScheme (uk.ac.bbsrc.tgac.miso.core.service.naming.NamingScheme)7 DeletionStore (uk.ac.bbsrc.tgac.miso.core.store.DeletionStore)7 Group (com.eaglegenomics.simlims.core.Group)6 User (com.eaglegenomics.simlims.core.User)6 Collectors (java.util.stream.Collectors)6 Collection (java.util.Collection)5