Search in sources :

Example 1 with PostGres

use of eu.europa.ec.fisheries.ers.service.util.PostGres in project UVMS-ActivityModule-APP by UnionVMS.

the class FluxMessageServiceBeanTest method testSaveFishingActivityReportDocuments.

@Test
@SneakyThrows
public void testSaveFishingActivityReportDocuments() throws ServiceException, ParseException, DatatypeConfigurationException {
    // Mock the APIs
    Mockito.doNothing().when(faReportDocumentDao).bulkUploadFaData(Mockito.any(List.class));
    Mockito.doNothing().when(faReportDocumentDao).updateAllFaData(Mockito.any(List.class));
    Mockito.doNothing().when(fluxFaReportMessageDao).saveFluxFaReportMessage(Mockito.any(FluxFaReportMessageEntity.class));
    Mockito.doReturn(getMockedAssets()).when(assetModule).getAssetGuids(Mockito.anyCollection());
    Mockito.doReturn(getMockedMovements()).when(movementModule).getMovement(Mockito.anyList(), Mockito.any(Date.class), Mockito.any(Date.class));
    Mockito.doReturn(getMockedFishingActivityReportEntity()).when(faReportDocumentDao).findFaReportByIdAndScheme(Mockito.any(String.class), Mockito.any(String.class));
    // Trigger
    fluxMessageService.setDialect(new PostGres());
    fluxMessageService.saveFishingActivityReportDocuments(fluxFaReportMessage, FaReportSourceEnum.FLUX);
    // Verify
    Mockito.verify(fluxFaReportMessageDao, Mockito.times(1)).saveFluxFaReportMessage(Mockito.any(FluxFaReportMessageEntity.class));
    Mockito.verify(faReportDocumentDao, Mockito.times(2)).findFaReportByIdAndScheme(Mockito.any(String.class), Mockito.any(String.class));
    Mockito.verify(faReportDocumentDao, Mockito.times(2)).updateAllFaData(captor.capture());
    // Test
    List<FaReportDocumentEntity> faReportDocumentEntities = captor.getValue();
    assertEquals(FaReportStatusEnum.getFaReportStatusEnum(Integer.parseInt(faReportDocuments.get(1).getRelatedFLUXReportDocument().getPurposeCode().getValue())).getStatus(), faReportDocumentEntities.get(0).getStatus());
}
Also used : FaReportDocumentEntity(eu.europa.ec.fisheries.ers.fa.entities.FaReportDocumentEntity) ArrayList(java.util.ArrayList) List(java.util.List) PostGres(eu.europa.ec.fisheries.ers.service.util.PostGres) FluxFaReportMessageEntity(eu.europa.ec.fisheries.ers.fa.entities.FluxFaReportMessageEntity) Date(java.util.Date) Test(org.junit.Test) SneakyThrows(lombok.SneakyThrows)

Example 2 with PostGres

use of eu.europa.ec.fisheries.ers.service.util.PostGres in project UVMS-ActivityModule-APP by UnionVMS.

the class FluxMessageServiceBean method init.

@PostConstruct
public void init() {
    initEntityManager();
    faReportDocumentDao = new FaReportDocumentDao(getEntityManager());
    fluxReportMessageDao = new FluxFaReportMessageDao(getEntityManager());
    dialect = new PostGres();
    if ("oracle".equals(properties.getProperty("database.dialect"))) {
        dialect = new Oracle();
    }
}
Also used : FaReportDocumentDao(eu.europa.ec.fisheries.ers.fa.dao.FaReportDocumentDao) PostGres(eu.europa.ec.fisheries.ers.service.util.PostGres) FluxFaReportMessageDao(eu.europa.ec.fisheries.ers.fa.dao.FluxFaReportMessageDao) Oracle(eu.europa.ec.fisheries.ers.service.util.Oracle) PostConstruct(javax.annotation.PostConstruct)

Aggregations

PostGres (eu.europa.ec.fisheries.ers.service.util.PostGres)2 FaReportDocumentDao (eu.europa.ec.fisheries.ers.fa.dao.FaReportDocumentDao)1 FluxFaReportMessageDao (eu.europa.ec.fisheries.ers.fa.dao.FluxFaReportMessageDao)1 FaReportDocumentEntity (eu.europa.ec.fisheries.ers.fa.entities.FaReportDocumentEntity)1 FluxFaReportMessageEntity (eu.europa.ec.fisheries.ers.fa.entities.FluxFaReportMessageEntity)1 Oracle (eu.europa.ec.fisheries.ers.service.util.Oracle)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 List (java.util.List)1 PostConstruct (javax.annotation.PostConstruct)1 SneakyThrows (lombok.SneakyThrows)1 Test (org.junit.Test)1