use of eu.europa.ec.fisheries.ers.service.dto.fishingtrip.CronologyTripDTO in project UVMS-ActivityModule-APP by UnionVMS.
the class FishingTripServiceBeanTest method getCronologyOfFishingTrip_OnlyCurrentAndSelected.
@Test
@SneakyThrows
public void getCronologyOfFishingTrip_OnlyCurrentAndSelected() {
// 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(5);
doReturn(previousTrips).when(fishingTripIdentifierDao).getPreviousTrips(any(String.class), any(String.class), any(String.class), any(Integer.class));
List<FishingTripIdentifierEntity> nextTrips = getNextTrips(5);
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, 1);
assertEquals(selectedTrip, cronology.getSelectedTrip());
assertEquals(fishingTripIdentifierEntity.getTripId(), cronology.getCurrentTrip());
assertEquals(0, cronology.getPreviousTrips().size());
assertEquals(0, cronology.getNextTrips().size());
}
use of eu.europa.ec.fisheries.ers.service.dto.fishingtrip.CronologyTripDTO 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 eu.europa.ec.fisheries.ers.service.dto.fishingtrip.CronologyTripDTO 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 eu.europa.ec.fisheries.ers.service.dto.fishingtrip.CronologyTripDTO in project UVMS-ActivityModule-APP by UnionVMS.
the class FishingTripServiceBean method getCronologyOfFishingTrip.
/**
* {@inheritDoc}
*/
@Override
public CronologyTripDTO getCronologyOfFishingTrip(String tripId, Integer count) throws ServiceException {
// Find the latest Vessel for the Trip for finding the trip of that vessel
List<VesselIdentifierEntity> latestVesselIdentifiers = vesselIdentifierDao.getLatestVesselIdByTrip(tripId);
CronologyTripDTO cronologyTripDTO = new CronologyTripDTO();
cronologyTripDTO.setCurrentTrip(getCurrentTrip(latestVesselIdentifiers));
cronologyTripDTO.setSelectedTrip(tripId);
List<String> previousTrips = new ArrayList<>(getPreviousTrips(tripId, count, latestVesselIdentifiers));
List<String> nextTrips = new ArrayList<>(getNextTrips(tripId, count, latestVesselIdentifiers));
Map<String, Integer> countMap = calculateTripCounts(count, previousTrips.size(), nextTrips.size());
log.info("Number of previous record to find : " + countMap.get(PREVIOUS));
log.info("Number of next record to find : " + countMap.get(NEXT));
cronologyTripDTO.setPreviousTrips(previousTrips.subList(previousTrips.size() - countMap.get(PREVIOUS), previousTrips.size()));
cronologyTripDTO.setNextTrips(nextTrips.subList(0, countMap.get(NEXT)));
return cronologyTripDTO;
}
use of eu.europa.ec.fisheries.ers.service.dto.fishingtrip.CronologyTripDTO in project UVMS-ActivityModule-APP by UnionVMS.
the class FishingTripServiceBeanTest method getCronologyOfFishingTrip_limitedRecordsFound.
@Test
@SneakyThrows
public void getCronologyOfFishingTrip_limitedRecordsFound() {
// 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(5);
doReturn(previousTrips).when(fishingTripIdentifierDao).getPreviousTrips(any(String.class), any(String.class), any(String.class), any(Integer.class));
List<FishingTripIdentifierEntity> nextTrips = getNextTrips(5);
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, 5);
// Assert
assertEquals(selectedTrip, cronology.getSelectedTrip());
assertEquals(fishingTripIdentifierEntity.getTripId(), cronology.getCurrentTrip());
List<String> previousIds = getIds(previousTrips);
assertEquals(previousIds.subList(3, previousIds.size()), cronology.getPreviousTrips());
List<String> nextIds = getIds(nextTrips);
assertEquals(nextIds.subList(0, 2), cronology.getNextTrips());
}
Aggregations