Search in sources :

Example 1 with ExpenseClassValidationService

use of org.folio.service.finance.expenceclass.ExpenseClassValidationService in project mod-orders by folio-org.

the class ExpenseClassValidationServiceTest method testShouldNotThrowDuplicateKeyException.

@Test
@DisplayName("Should not throw DuplicateKeyException")
void testShouldNotThrowDuplicateKeyException() {
    CompositePoLine compositePoLine = getMockAsJson(COMP_PO_LINES_MOCK_DATA_PATH, ANOTHER_PO_LINE_ID_FOR_SUCCESS_CASE).mapTo(CompositePoLine.class);
    compositePoLine.getFundDistribution().clear();
    var fd = new FundDistribution().withFundId(UUID.randomUUID().toString()).withCode("ANY").withExpenseClassId(UUID.randomUUID().toString()).withDistributionType(FundDistribution.DistributionType.PERCENTAGE).withValue(100D);
    compositePoLine.getFundDistribution().add(fd);
    List<CompositePoLine> compositePoLineList = new ArrayList<>();
    compositePoLineList.add(compositePoLine);
    compositePoLineList.add(compositePoLine);
    ExpenseClassValidationService expenseClassValidationService = mock(ExpenseClassValidationService.class, CALLS_REAL_METHODS);
    RequestContext requestContext = new RequestContext(null, null);
    doReturn(completedFuture(null)).when(expenseClassValidationService).checkExpenseClassIsActiveByFundDistribution(any(), anyBoolean(), any());
    CompletableFuture<Void> response = expenseClassValidationService.validateExpenseClasses(compositePoLineList, true, requestContext);
    response.join();
    Assertions.assertTrue(response.isDone());
}
Also used : FundDistribution(org.folio.rest.jaxrs.model.FundDistribution) ArrayList(java.util.ArrayList) CompositePoLine(org.folio.rest.jaxrs.model.CompositePoLine) RequestContext(org.folio.rest.core.models.RequestContext) ExpenseClassValidationService(org.folio.service.finance.expenceclass.ExpenseClassValidationService) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Aggregations

ArrayList (java.util.ArrayList)1 RequestContext (org.folio.rest.core.models.RequestContext)1 CompositePoLine (org.folio.rest.jaxrs.model.CompositePoLine)1 FundDistribution (org.folio.rest.jaxrs.model.FundDistribution)1 ExpenseClassValidationService (org.folio.service.finance.expenceclass.ExpenseClassValidationService)1 DisplayName (org.junit.jupiter.api.DisplayName)1 Test (org.junit.jupiter.api.Test)1