use of eu.europa.ec.fisheries.uvms.activity.model.schemas.SearchFilter 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.uvms.activity.model.schemas.SearchFilter 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.uvms.activity.model.schemas.SearchFilter 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.uvms.activity.model.schemas.SearchFilter in project UVMS-ActivityModule-APP by UnionVMS.
the class ActivityServiceBean method separateSingleVsMultipleFilters.
// Improve this part later on
private void separateSingleVsMultipleFilters(FishingActivityQuery query) throws ServiceException {
Map<SearchFilter, List<String>> searchMapWithMultipleValues = query.getSearchCriteriaMapMultipleValues();
if (searchMapWithMultipleValues == null || searchMapWithMultipleValues.size() == 0 || searchMapWithMultipleValues.get(SearchFilter.PURPOSE) == null)
throw new ServiceException("No purpose code provided for the Fishing activity filters! At least one needed!");
Map<SearchFilter, String> searchMap = query.getSearchCriteriaMap();
if (searchMap == null)
return;
validateInputFilters(searchMapWithMultipleValues);
Set<SearchFilter> filtersWhichSupportMultipleValues = FilterMap.getFiltersWhichSupportMultipleValues();
Iterator<Map.Entry<SearchFilter, String>> searchMapIterator = searchMap.entrySet().iterator();
while (searchMapIterator.hasNext()) {
Map.Entry<SearchFilter, String> e = searchMapIterator.next();
SearchFilter key = e.getKey();
String value = e.getValue();
if (value == null)
throw new ServiceException("Null value present for the key:" + key + " Please provide correct input.");
if (filtersWhichSupportMultipleValues.contains(key)) {
List<String> values = new ArrayList<>();
values.add(value);
searchMapWithMultipleValues.put(key, values);
searchMapIterator.remove();
}
}
query.setSearchCriteriaMapMultipleValues(searchMapWithMultipleValues);
query.setSearchCriteriaMap(searchMap);
}
use of eu.europa.ec.fisheries.uvms.activity.model.schemas.SearchFilter in project UVMS-ActivityModule-APP by UnionVMS.
the class ActivityServiceBean method validateInputFilters.
private void validateInputFilters(Map<SearchFilter, List<String>> searchMapWithMultipleValues) throws ServiceException {
if (MapUtils.isNotEmpty(searchMapWithMultipleValues)) {
Iterator<Map.Entry<SearchFilter, List<String>>> searchMapIterator = searchMapWithMultipleValues.entrySet().iterator();
while (searchMapIterator.hasNext()) {
Map.Entry<SearchFilter, List<String>> e = searchMapIterator.next();
SearchFilter key = e.getKey();
List<String> values = e.getValue();
if (values.contains(null) || values.contains("")) {
throw new ServiceException("Null value present for the key:" + key + " Please provide correct input.");
}
}
}
}
Aggregations