use of lombok.SneakyThrows in project UVMS-ActivityModule-APP by UnionVMS.
the class FishingTripServiceBeanTest method getCronologyOfFishingTrip_OnlyPrevious.
@Test
@SneakyThrows
public void getCronologyOfFishingTrip_OnlyPrevious() {
// Mock the Dao
doReturn(getVesselIdentifiers()).when(vesselIdentifiersDao).getLatestVesselIdByTrip(any(String.class));
FishingTripIdentifierEntity fishingTripIdentifierEntity = getCurrentTrip();
doReturn(fishingTripIdentifierEntity).when(fishingTripIdentifierDao).getCurrentTrip(any(String.class), any(String.class));
List<FishingTripIdentifierEntity> previousTrips = getPreviousTrips(2);
doReturn(previousTrips).when(fishingTripIdentifierDao).getPreviousTrips(any(String.class), any(String.class), any(String.class), any(Integer.class));
List<FishingTripIdentifierEntity> nextTrips = getNextTrips(2);
doReturn(nextTrips).when(fishingTripIdentifierDao).getNextTrips(any(String.class), any(String.class), any(String.class), any(Integer.class));
// Trigger
String selectedTrip = "selected Trip";
CronologyTripDTO cronology = fishingTripService.getCronologyOfFishingTrip(selectedTrip, 2);
assertEquals(selectedTrip, cronology.getSelectedTrip());
assertEquals(fishingTripIdentifierEntity.getTripId(), cronology.getCurrentTrip());
List<String> previousIds = getIds(previousTrips);
assertEquals(previousIds.subList(1, previousIds.size()), cronology.getPreviousTrips());
}
use of lombok.SneakyThrows in project UVMS-ActivityModule-APP by UnionVMS.
the class FishingTripServiceBeanTest method getCronologyOfFishingTrip_All.
@Test
@SneakyThrows
public void getCronologyOfFishingTrip_All() {
// Mock the Dao
doReturn(getVesselIdentifiers()).when(vesselIdentifiersDao).getLatestVesselIdByTrip(any(String.class));
FishingTripIdentifierEntity fishingTripIdentifierEntity = getCurrentTrip();
doReturn(fishingTripIdentifierEntity).when(fishingTripIdentifierDao).getCurrentTrip(any(String.class), any(String.class));
List<FishingTripIdentifierEntity> previousTrips = getPreviousTrips(10);
doReturn(previousTrips).when(fishingTripIdentifierDao).getPreviousTrips(any(String.class), any(String.class), any(String.class), any(Integer.class));
List<FishingTripIdentifierEntity> nextTrips = getNextTrips(10);
doReturn(nextTrips).when(fishingTripIdentifierDao).getNextTrips(any(String.class), any(String.class), any(String.class), any(Integer.class));
// Trigger
String selectedTrip = "selected Trip";
CronologyTripDTO cronology = fishingTripService.getCronologyOfFishingTrip(selectedTrip, 0);
assertEquals(selectedTrip, cronology.getSelectedTrip());
assertEquals(fishingTripIdentifierEntity.getTripId(), cronology.getCurrentTrip());
List<String> previousIds = getIds(previousTrips);
assertEquals(previousIds, cronology.getPreviousTrips());
List<String> nextIds = getIds(nextTrips);
assertEquals(nextIds, cronology.getNextTrips());
}
use of lombok.SneakyThrows 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 lombok.SneakyThrows in project UVMS-ActivityModule-APP by UnionVMS.
the class FishingActivityViewMapperTest method initFishingActivityEntity.
@Before
@SneakyThrows
public void initFishingActivityEntity() {
FLUXFAReportMessage fluxfaReportMessage = getActivityDataFromXML();
FluxFaReportMessageEntity fluxRepMessageEntity = FluxFaReportMessageMapper.INSTANCE.mapToFluxFaReportMessage(fluxfaReportMessage, FaReportSourceEnum.FLUX, new FluxFaReportMessageEntity());
List<FaReportDocumentEntity> faReportDocuments = new ArrayList<>(fluxRepMessageEntity.getFaReportDocuments());
fishingActivity = faReportDocuments.get(0).getFishingActivities().iterator().next();
}
use of lombok.SneakyThrows in project UVMS-ActivityModule-APP by UnionVMS.
the class FishingActivityViewMapperTest method testActivityRelocationViewMapper.
@Test
@SneakyThrows
public void testActivityRelocationViewMapper() {
BaseActivityViewMapper mapperForView = ActivityViewMapperFactory.getMapperForView(ActivityViewEnum.RELOCATION);
FishingActivityEntity fishingActivityEntity = getFishingActivityEntity();
Set<FaCatchEntity> faCatches = generateFaCatches(fishingActivityEntity.getFaCatchs().iterator().next());
fishingActivityEntity.setFaCatchs(faCatches);
FishingActivityViewDTO fishingActivityViewDTO = mapperForView.mapFaEntityToFaDto(fishingActivityEntity);
assertNotNull(fishingActivityViewDTO.getActivityDetails());
assertNotNull(fishingActivityViewDTO.getReportDetails());
assertNull(ActivityArrivalViewMapper.INSTANCE.mapFaEntityToFaDto(null));
}
Aggregations