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());
}
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();
}
}
Aggregations