use of lombok.SneakyThrows in project UVMS-ActivityModule-APP by UnionVMS.
the class FaCatchReportServiceBeanTest method testGetCatchesTableForCatchDetailsScreen.
@Test
@SneakyThrows
public void testGetCatchesTableForCatchDetailsScreen() throws ServiceException {
FishingActivityQuery query = new FishingActivityQuery();
List<GroupCriteria> groupByFields = new ArrayList<>();
groupByFields.add(GroupCriteria.DATE_DAY);
groupByFields.add(GroupCriteria.FAO_AREA);
groupByFields.add(GroupCriteria.TERRITORY);
groupByFields.add(GroupCriteria.EFFORT_ZONE);
groupByFields.add(GroupCriteria.GFCM_GSA);
groupByFields.add(GroupCriteria.GFCM_STAT_RECTANGLE);
groupByFields.add(GroupCriteria.ICES_STAT_RECTANGLE);
groupByFields.add(GroupCriteria.RFMO);
groupByFields.add(GroupCriteria.SPECIES);
query.setGroupByFields(groupByFields);
Map<SearchFilter, String> searchCriteriaMap = new EnumMap<SearchFilter, String>(SearchFilter.class);
searchCriteriaMap.put(SearchFilter.TRIP_ID, "NOR-TRP-20160517234053706");
query.setSearchCriteriaMap(searchCriteriaMap);
when(faCatchDao.getGroupedFaCatchData(query, Boolean.FALSE)).thenReturn(MapperUtil.getGroupedFaCatchSummaryCustomEntityData());
when(faCatchDao.getGroupedFaCatchData(query, Boolean.TRUE)).thenReturn(MapperUtil.getGroupedFaCatchSummaryCustomEntityData());
// when(vesselIdentifiersDao.getLatestVesselIdByTrip("NOR-TRP-20160517234053706")).thenReturn(MapperUtil.getVesselIdentifiersList());
// Trigger
FACatchDetailsDTO faCatchDetailsDTO = faCatchReportService.getCatchDetailsScreen("NOR-TRP-20160517234053706");
Mockito.verify(faCatchDao, Mockito.times(2)).getGroupedFaCatchData(Mockito.any(FishingActivityQuery.class), Mockito.any(Boolean.class));
// Verify
assertNotNull(faCatchDetailsDTO);
}
use of lombok.SneakyThrows in project UVMS-ActivityModule-APP by UnionVMS.
the class FaCatchReportServiceBeanTest method testGetCatchSummaryReport.
@Test
@SneakyThrows
public void testGetCatchSummaryReport() throws ServiceException {
FishingActivityQuery query = new FishingActivityQuery();
List<GroupCriteria> groupByFields = new ArrayList<>();
groupByFields.add(GroupCriteria.DATE_DAY);
groupByFields.add(GroupCriteria.FAO_AREA);
groupByFields.add(GroupCriteria.TERRITORY);
groupByFields.add(GroupCriteria.EFFORT_ZONE);
groupByFields.add(GroupCriteria.GFCM_GSA);
groupByFields.add(GroupCriteria.GFCM_STAT_RECTANGLE);
groupByFields.add(GroupCriteria.ICES_STAT_RECTANGLE);
groupByFields.add(GroupCriteria.RFMO);
groupByFields.add(GroupCriteria.SPECIES);
query.setGroupByFields(groupByFields);
Map<SearchFilter, String> searchCriteriaMap = new EnumMap<SearchFilter, String>(SearchFilter.class);
searchCriteriaMap.put(SearchFilter.TRIP_ID, "NOR-TRP-20160517234053706");
query.setSearchCriteriaMap(searchCriteriaMap);
Map<FaCatchSummaryCustomProxy, List<FaCatchSummaryCustomProxy>> groupedData = MapperUtil.getGroupedFaCatchSummaryCustomEntityData();
when((faCatchDao).getGroupedFaCatchData(any(FishingActivityQuery.class), any(Boolean.class))).thenReturn(groupedData);
// when(faCatchDao.getGroupedFaCatchData(query,true)).thenReturn(MapperUtil.getGroupedFaCatchSummaryCustomEntityData());
// when(vesselIdentifiersDao.getLatestVesselIdByTrip("NOR-TRP-20160517234053706")).thenReturn(MapperUtil.getVesselIdentifiersList());
// Trigger
FACatchSummaryDTO fACatchSummaryDTO = faCatchReportService.getCatchSummaryReport(query, false);
Mockito.verify(faCatchDao, Mockito.times(1)).getGroupedFaCatchData(Mockito.any(FishingActivityQuery.class), Mockito.any(Boolean.class));
// Verify
assertNotNull(fACatchSummaryDTO);
}
use of lombok.SneakyThrows in project UVMS-ActivityModule-APP by UnionVMS.
the class FishingTripServiceBeanTest method testBuildFishingTripSearchRespose.
@Test
@SneakyThrows
public void testBuildFishingTripSearchRespose() throws ServiceException, JsonProcessingException {
FishingActivityQuery query = new FishingActivityQuery();
Map<SearchFilter, String> searchCriteriaMap = new EnumMap<>(SearchFilter.class);
searchCriteriaMap.put(SearchFilter.TRIP_ID, "NOR-TRP-20160517234053706");
searchCriteriaMap.put(SearchFilter.FISHING_TRIP_SCHEME_ID, "EU_TRIP_ID");
query.setSearchCriteriaMap(searchCriteriaMap);
SortKey sortKey = new SortKey();
sortKey.setSortBy(SearchFilter.PERIOD_START);
sortKey.setReversed(false);
query.setSorting(sortKey);
when(fishingActivityDao.getFishingActivityListByQuery(any(FishingActivityQuery.class))).thenReturn(MapperUtil.getFishingActivityEntityList());
// Trigger
FishingTripResponse response = fishingTripService.buildFishingTripSearchRespose(MapperUtil.getFishingTripIdSet(), false);
assertNotNull(response);
}
use of lombok.SneakyThrows in project UVMS-ActivityModule-APP by UnionVMS.
the class FishingTripServiceBeanTest method testGetTripMapDetailsForTripId.
@Test
@SneakyThrows
public void testGetTripMapDetailsForTripId() throws ServiceException, JsonProcessingException {
String expected = "{\"type\":\"FeatureCollection\",\"features\":[{\"type\":\"Feature\",\"geometry\":{\"type\":\"MultiPoint\",\"coordinates\":[[-10,40],[-40,30],[-20,20],[-30,10]]},\"properties\":{}}]}";
when(faReportDocumentDao.getLatestFaReportDocumentsForTrip("NOR-TRP-20160517234053706")).thenReturn(Arrays.asList(MapperUtil.getFaReportDocumentEntity()));
// Trigger
ObjectNode node = fishingTripService.getTripMapDetailsForTripId("NOR-TRP-20160517234053706");
Mockito.verify(faReportDocumentDao, Mockito.times(1)).getLatestFaReportDocumentsForTrip(Mockito.any(String.class));
ObjectMapper objectMapper = new ObjectMapper();
// Verify
assertEquals(expected, objectMapper.writeValueAsString(node));
}
use of lombok.SneakyThrows 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());
}
Aggregations