use of eu.europa.ec.fisheries.ers.service.search.FishingActivityQuery 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 eu.europa.ec.fisheries.ers.service.search.FishingActivityQuery 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 eu.europa.ec.fisheries.ers.service.search.FishingActivityQuery 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 eu.europa.ec.fisheries.ers.service.search.FishingActivityQuery in project UVMS-ActivityModule-APP by UnionVMS.
the class FishingActivityRequestMapper method buildFishingActivityQueryFromRequest.
/**
* Backend API expects input as FishingActivityQuery. This method maps FACatchSummaryReportRequest to FishingActivityQuery object
* @param baseRequest
* @return FishingActivityQuery
* @throws ServiceException
*/
public static FishingActivityQuery buildFishingActivityQueryFromRequest(FACatchSummaryReportRequest baseRequest) throws ServiceException {
FishingActivityQuery query = new FishingActivityQuery();
query.setSearchCriteriaMap(extractFiltersAsMap(baseRequest.getSingleValueFilters()));
query.setSearchCriteriaMapMultipleValues(extractFiltersAsMapWithMultipleValues(baseRequest.getListValueFilters()));
query.setGroupByFields(baseRequest.getGroupCriterias());
return query;
}
use of eu.europa.ec.fisheries.ers.service.search.FishingActivityQuery in project UVMS-ActivityModule-APP by UnionVMS.
the class FishingActivityRequestMapper method buildFishingActivityQueryFromRequest.
public static FishingActivityQuery buildFishingActivityQueryFromRequest(FishingTripRequest baseRequest) throws ServiceException {
FishingActivityQuery query = new FishingActivityQuery();
query.setSearchCriteriaMap(extractFiltersAsMap(baseRequest.getSingleValueFilters()));
query.setSearchCriteriaMapMultipleValues(extractFiltersAsMapWithMultipleValues(baseRequest.getListValueFilters()));
return query;
}
Aggregations