Search in sources :

Example 66 with SneakyThrows

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);
}
Also used : FishingActivityQuery(eu.europa.ec.fisheries.ers.service.search.FishingActivityQuery) ArrayList(java.util.ArrayList) SearchFilter(eu.europa.ec.fisheries.uvms.activity.model.schemas.SearchFilter) FACatchDetailsDTO(eu.europa.ec.fisheries.ers.service.dto.fareport.summary.FACatchDetailsDTO) EnumMap(java.util.EnumMap) GroupCriteria(eu.europa.ec.fisheries.uvms.activity.model.schemas.GroupCriteria) Test(org.junit.Test) SneakyThrows(lombok.SneakyThrows)

Example 67 with SneakyThrows

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);
}
Also used : ArrayList(java.util.ArrayList) SearchFilter(eu.europa.ec.fisheries.uvms.activity.model.schemas.SearchFilter) GroupCriteria(eu.europa.ec.fisheries.uvms.activity.model.schemas.GroupCriteria) FishingActivityQuery(eu.europa.ec.fisheries.ers.service.search.FishingActivityQuery) FaCatchSummaryCustomProxy(eu.europa.ec.fisheries.ers.fa.dao.proxy.FaCatchSummaryCustomProxy) FACatchSummaryDTO(eu.europa.ec.fisheries.ers.service.dto.fareport.summary.FACatchSummaryDTO) ArrayList(java.util.ArrayList) List(java.util.List) EnumMap(java.util.EnumMap) Test(org.junit.Test) SneakyThrows(lombok.SneakyThrows)

Example 68 with SneakyThrows

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);
}
Also used : FishingActivityQuery(eu.europa.ec.fisheries.ers.service.search.FishingActivityQuery) FishingTripResponse(eu.europa.ec.fisheries.uvms.activity.model.schemas.FishingTripResponse) SearchFilter(eu.europa.ec.fisheries.uvms.activity.model.schemas.SearchFilter) SortKey(eu.europa.ec.fisheries.ers.service.search.SortKey) EnumMap(java.util.EnumMap) Test(org.junit.Test) SneakyThrows(lombok.SneakyThrows)

Example 69 with SneakyThrows

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));
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test) SneakyThrows(lombok.SneakyThrows)

Example 70 with SneakyThrows

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());
}
Also used : FishingTripIdentifierEntity(eu.europa.ec.fisheries.ers.fa.entities.FishingTripIdentifierEntity) CronologyTripDTO(eu.europa.ec.fisheries.ers.service.dto.fishingtrip.CronologyTripDTO) Test(org.junit.Test) SneakyThrows(lombok.SneakyThrows)

Aggregations

SneakyThrows (lombok.SneakyThrows)706 lombok.val (lombok.val)314 Test (org.junit.Test)91 ArrayList (java.util.ArrayList)75 HashMap (java.util.HashMap)63 List (java.util.List)53 Cleanup (lombok.Cleanup)38 Map (java.util.Map)35 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)34 Collectors (java.util.stream.Collectors)34 LinkedHashMap (java.util.LinkedHashMap)30 File (java.io.File)28 Path (java.nio.file.Path)28 IOException (java.io.IOException)26 InputStream (java.io.InputStream)24 Slf4j (lombok.extern.slf4j.Slf4j)24 URL (java.net.URL)22 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)22 Collection (java.util.Collection)18 FishingActivityQuery (eu.europa.ec.fisheries.ers.service.search.FishingActivityQuery)17