Search in sources :

Example 61 with SneakyThrows

use of lombok.SneakyThrows in project UVMS-ActivityModule-APP by UnionVMS.

the class FishingActivityDaoTest method testGetFishingActivityListByQuery.

@Test
@SneakyThrows
public void testGetFishingActivityListByQuery() throws Exception {
    dbSetupTracker.skipNextLaunch();
    FishingActivityQuery query = new FishingActivityQuery();
    Map<SearchFilter, String> searchCriteriaMap = new HashMap<>();
    Map<SearchFilter, List<String>> searchCriteriaMapMultiVal = new HashMap<>();
    List<String> activityTypeValues = new ArrayList<>();
    activityTypeValues.add("FISHING_OPERATION");
    activityTypeValues.add("DEPARTURE");
    searchCriteriaMapMultiVal.put(SearchFilter.ACTIVITY_TYPE, activityTypeValues);
    query.setSearchCriteriaMapMultipleValues(searchCriteriaMapMultiVal);
    searchCriteriaMap.put(SearchFilter.OWNER, "OWNER1");
    searchCriteriaMap.put(SearchFilter.PERIOD_START, "2012-05-27T07:47:31");
    searchCriteriaMap.put(SearchFilter.PERIOD_END, "2015-05-27T07:47:31");
    searchCriteriaMap.put(SearchFilter.VESSEL_NAME, "vessel1");
    searchCriteriaMap.put(SearchFilter.VESSEL_IDENTIFIRE, "CFR123");
    searchCriteriaMap.put(SearchFilter.REPORT_TYPE, "DECLARATION");
    searchCriteriaMap.put(SearchFilter.GEAR, "GEAR_TYPE");
    searchCriteriaMap.put(SearchFilter.SPECIES, "PLE");
    searchCriteriaMap.put(SearchFilter.MASTER, "MARK");
    searchCriteriaMap.put(SearchFilter.AREAS, "27.4.b");
    // searchCriteriaMap.put(SearchFilter.PORT, "GBR");
    searchCriteriaMap.put(SearchFilter.QUANTITY_MIN, "0");
    searchCriteriaMap.put(SearchFilter.QUANTITY_MAX, "25");
    query.setSearchCriteriaMap(searchCriteriaMap);
    PaginationDto pagination = new PaginationDto();
    pagination.setPageSize(2);
    pagination.setOffset(1);
    query.setPagination(pagination);
    SortKey sortingDto = new SortKey();
    sortingDto.setSortBy(SearchFilter.OCCURRENCE);
    sortingDto.setReversed(false);
    query.setSorting(sortingDto);
    List<FishingActivityEntity> finishingActivityList = dao.getFishingActivityListByQuery(query);
    System.out.println("done:" + finishingActivityList.size());
    assertNotNull(finishingActivityList);
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) PaginationDto(eu.europa.ec.fisheries.uvms.commons.rest.dto.PaginationDto) SearchFilter(eu.europa.ec.fisheries.uvms.activity.model.schemas.SearchFilter) SortKey(eu.europa.ec.fisheries.ers.service.search.SortKey) FishingActivityQuery(eu.europa.ec.fisheries.ers.service.search.FishingActivityQuery) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.Test) SneakyThrows(lombok.SneakyThrows)

Example 62 with SneakyThrows

use of lombok.SneakyThrows in project UVMS-ActivityModule-APP by UnionVMS.

the class FishingActivityDaoTest method testGetFishingActivityListByQuery_GetByFaReportID.

@Test
@SneakyThrows
public void testGetFishingActivityListByQuery_GetByFaReportID() throws Exception {
    dbSetupTracker.skipNextLaunch();
    FishingActivityQuery query = new FishingActivityQuery();
    Map<SearchFilter, String> searchCriteriaMap = new HashMap<>();
    Map<SearchFilter, List<String>> searchCriteriaMapMultiVal = new HashMap<>();
    List<String> activityTypeValues = new ArrayList<>();
    activityTypeValues.add("FISHING_OPERATION");
    activityTypeValues.add("DEPARTURE");
    searchCriteriaMapMultiVal.put(SearchFilter.ACTIVITY_TYPE, activityTypeValues);
    List<String> purposeCodeValues = new ArrayList<>();
    purposeCodeValues.add("5");
    purposeCodeValues.add("9");
    searchCriteriaMapMultiVal.put(SearchFilter.PURPOSE, purposeCodeValues);
    query.setSearchCriteriaMapMultipleValues(searchCriteriaMapMultiVal);
    searchCriteriaMap.put(SearchFilter.OWNER, "OWNER1");
    searchCriteriaMap.put(SearchFilter.PERIOD_START, "2012-05-27T07:47:31");
    searchCriteriaMap.put(SearchFilter.PERIOD_END, "2015-05-27T07:47:31");
    searchCriteriaMap.put(SearchFilter.VESSEL_NAME, "vessel1");
    searchCriteriaMap.put(SearchFilter.VESSEL_IDENTIFIRE, "CFR123");
    searchCriteriaMap.put(SearchFilter.REPORT_TYPE, "DECLARATION");
    searchCriteriaMap.put(SearchFilter.GEAR, "GEAR_TYPE");
    searchCriteriaMap.put(SearchFilter.SPECIES, "PLE");
    searchCriteriaMap.put(SearchFilter.MASTER, "MARK");
    searchCriteriaMap.put(SearchFilter.AREAS, "27.4.b");
    // searchCriteriaMap.put(SearchFilter.PORT, "GBR");
    searchCriteriaMap.put(SearchFilter.QUANTITY_MIN, "0");
    searchCriteriaMap.put(SearchFilter.QUANTITY_MAX, "25");
    searchCriteriaMap.put(SearchFilter.FA_REPORT_ID, "1");
    query.setSearchCriteriaMap(searchCriteriaMap);
    PaginationDto pagination = new PaginationDto();
    pagination.setPageSize(2);
    pagination.setOffset(1);
    query.setPagination(pagination);
    SortKey sortingDto = new SortKey();
    sortingDto.setSortBy(SearchFilter.OCCURRENCE);
    sortingDto.setReversed(false);
    query.setSorting(sortingDto);
    List<FishingActivityEntity> finishingActivityList = dao.getFishingActivityListByQuery(query);
    System.out.println("done:" + finishingActivityList.size());
    assertNotNull(finishingActivityList);
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) PaginationDto(eu.europa.ec.fisheries.uvms.commons.rest.dto.PaginationDto) SearchFilter(eu.europa.ec.fisheries.uvms.activity.model.schemas.SearchFilter) SortKey(eu.europa.ec.fisheries.ers.service.search.SortKey) FishingActivityQuery(eu.europa.ec.fisheries.ers.service.search.FishingActivityQuery) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.Test) SneakyThrows(lombok.SneakyThrows)

Example 63 with SneakyThrows

use of lombok.SneakyThrows in project UVMS-ActivityModule-APP by UnionVMS.

the class SearchQueryBuilderTest method testCreateSQL.

@Test
@SneakyThrows
public void testCreateSQL() throws ServiceException {
    FishingActivityQuery query = new FishingActivityQuery();
    Map<SearchFilter, String> searchCriteriaMap = new HashMap<>();
    /*  searchCriteriaMap.put(SearchFilter.OWNER, "OWNER1");
        searchCriteriaMap.put(SearchFilter.PERIOD_START, "2012-05-27 07:47:31");
        searchCriteriaMap.put(SearchFilter.PERIOD_END, "2015-05-27 07:47:31");
        searchCriteriaMap.put(SearchFilter.VESSEL_NAME, "vessel1");
        searchCriteriaMap.put(SearchFilter.VESSEL_IDENTIFIRE, "CFR123");
        searchCriteriaMap.put(SearchFilter.PURPOSE, "9");
        searchCriteriaMap.put(SearchFilter.REPORT_TYPE, "DECLARATION");
        searchCriteriaMap.put(SearchFilter.GEAR, "GEAR_TYPE");*/
    searchCriteriaMap.put(SearchFilter.ACTIVITY_TYPE, "DEPARTURE");
    /*    searchCriteriaMap.put(SearchFilter.SPECIES, "PLE");
        searchCriteriaMap.put(SearchFilter.MASTER, "MARK");
        searchCriteriaMap.put(SearchFilter.AREAS, "27.4.b");
        searchCriteriaMap.put(SearchFilter.PORT, "GBR");
        searchCriteriaMap.put(SearchFilter.QUANTITY_MIN, "0");
        searchCriteriaMap.put(SearchFilter.QUANTITY_MAX, "25");
        searchCriteriaMap.put(SearchFilter.WEIGHT_MEASURE, "TNE");
        searchCriteriaMap.put(SearchFilter.SOURCE, "FLUX");*/
    // query.setSortKey(new SortKey(SearchFilter.PURPOSE, SortOrder.ASC));
    query.setSearchCriteriaMap(searchCriteriaMap);
    PaginationDto pagination = new PaginationDto();
    pagination.setPageSize(2);
    pagination.setOffset(1);
    query.setPagination(pagination);
    SearchQueryBuilder search = new FishingActivitySearchBuilder();
    StringBuilder sql = search.createSQL(query);
    System.out.println("done:" + sql);
    assertNotNull(sql);
}
Also used : FishingActivitySearchBuilder(eu.europa.ec.fisheries.ers.service.search.builder.FishingActivitySearchBuilder) FishingActivityQuery(eu.europa.ec.fisheries.ers.service.search.FishingActivityQuery) HashMap(java.util.HashMap) PaginationDto(eu.europa.ec.fisheries.uvms.commons.rest.dto.PaginationDto) SearchQueryBuilder(eu.europa.ec.fisheries.ers.service.search.builder.SearchQueryBuilder) SearchFilter(eu.europa.ec.fisheries.uvms.activity.model.schemas.SearchFilter) Test(org.junit.Test) SneakyThrows(lombok.SneakyThrows)

Example 64 with SneakyThrows

use of lombok.SneakyThrows in project UVMS-ActivityModule-APP by UnionVMS.

the class SearchQueryBuilderTest method testCreateSQL_DateSorting.

@Test
@SneakyThrows
public void testCreateSQL_DateSorting() throws ServiceException {
    FishingActivityQuery query = new FishingActivityQuery();
    Map<SearchFilter, String> searchCriteriaMap = new HashMap<>();
    searchCriteriaMap.put(SearchFilter.OWNER, "OWNER1");
    searchCriteriaMap.put(SearchFilter.PERIOD_START, "2012-05-27 07:47:31");
    searchCriteriaMap.put(SearchFilter.PERIOD_END, "2015-05-27 07:47:31");
    searchCriteriaMap.put(SearchFilter.VESSEL_NAME, "vessel1");
    searchCriteriaMap.put(SearchFilter.VESSEL_IDENTIFIRE, "CFR123");
    searchCriteriaMap.put(SearchFilter.PURPOSE, "9");
    searchCriteriaMap.put(SearchFilter.REPORT_TYPE, "DECLARATION");
    searchCriteriaMap.put(SearchFilter.GEAR, "GEAR_TYPE");
    // searchCriteriaMap.put(SearchFilter.ACTIVITY_TYPE, "DEPARTURE");
    searchCriteriaMap.put(SearchFilter.SPECIES, "PLE");
    searchCriteriaMap.put(SearchFilter.MASTER, "MARK");
    searchCriteriaMap.put(SearchFilter.AREAS, "27.4.b");
    searchCriteriaMap.put(SearchFilter.PORT, "GBR");
    searchCriteriaMap.put(SearchFilter.QUANTITY_MIN, "0");
    searchCriteriaMap.put(SearchFilter.QUANTITY_MAX, "25");
    searchCriteriaMap.put(SearchFilter.WEIGHT_MEASURE, "TNE");
    searchCriteriaMap.put(SearchFilter.SOURCE, "FLUX");
    SortKey sortingDto = new SortKey();
    sortingDto.setSortBy(SearchFilter.PERIOD_START);
    sortingDto.setReversed(false);
    query.setSorting(sortingDto);
    query.setSearchCriteriaMap(searchCriteriaMap);
    PaginationDto pagination = new PaginationDto();
    pagination.setPageSize(2);
    pagination.setOffset(1);
    query.setPagination(pagination);
    SortKey sortingDto2 = new SortKey();
    sortingDto2.setReversed(false);
    query.setSorting(sortingDto);
    query.setSorting(sortingDto2);
    SearchQueryBuilder search = new FishingActivitySearchBuilder();
    StringBuilder sql = search.createSQL(query);
    System.out.println("done:" + sql);
    assertNotNull(sql);
}
Also used : FishingActivitySearchBuilder(eu.europa.ec.fisheries.ers.service.search.builder.FishingActivitySearchBuilder) FishingActivityQuery(eu.europa.ec.fisheries.ers.service.search.FishingActivityQuery) HashMap(java.util.HashMap) PaginationDto(eu.europa.ec.fisheries.uvms.commons.rest.dto.PaginationDto) SearchQueryBuilder(eu.europa.ec.fisheries.ers.service.search.builder.SearchQueryBuilder) SearchFilter(eu.europa.ec.fisheries.uvms.activity.model.schemas.SearchFilter) SortKey(eu.europa.ec.fisheries.ers.service.search.SortKey) Test(org.junit.Test) SneakyThrows(lombok.SneakyThrows)

Example 65 with SneakyThrows

use of lombok.SneakyThrows in project UVMS-ActivityModule-APP by UnionVMS.

the class ActivityToSubscriptionMapperTest method before.

@Before
@SneakyThrows
public void before() {
    IDType idType = new IDType();
    idType.setSchemeID("FLUX_GP_PARTY");
    idType.setValue("BEL");
    FLUXParty fluxParty = new FLUXParty();
    fluxParty.setIDS(Collections.singletonList(idType));
    DelimitedPeriod delimitedPeriod = new DelimitedPeriod();
    DateTimeType startDateTime = new DateTimeType();
    GregorianCalendar cal = new GregorianCalendar();
    DateTime dateTime = DateUtils.XML_FORMATTER.parseDateTime("2016-07-01T02:00:00.000+02:00");
    cal.setTime(dateTime.toDate());
    XMLGregorianCalendar xmlDate = DatatypeFactory.newInstance().newXMLGregorianCalendar(cal);
    startDateTime.setDateTime(xmlDate);
    delimitedPeriod.setStartDateTime(startDateTime);
    DateTimeType endDateTime = new DateTimeType();
    GregorianCalendar cal2 = new GregorianCalendar();
    DateTime dateTime2 = DateUtils.XML_FORMATTER.parseDateTime("2017-07-01T02:00:00.000+02:00");
    cal2.setTime(dateTime2.toDate());
    XMLGregorianCalendar xmlDate2 = DatatypeFactory.newInstance().newXMLGregorianCalendar(cal2);
    endDateTime.setDateTime(xmlDate2);
    delimitedPeriod.setEndDateTime(endDateTime);
    FAQueryParameter faQueryParameter = new FAQueryParameter();
    CodeType codeType = new CodeType();
    codeType.setValue(SubCriteriaType.VESSELID.value());
    faQueryParameter.setTypeCode(codeType);
    IDType idType0 = new IDType();
    idType0.setValue("PD2438");
    idType0.setSchemeID("IRCS");
    faQueryParameter.setValueID(idType0);
    FAQueryParameter faQueryParameter2 = new FAQueryParameter();
    CodeType codeType2 = new CodeType();
    codeType2.setValue(SubCriteriaType.VESSELID.value());
    faQueryParameter2.setTypeCode(codeType2);
    IDType idType2 = new IDType();
    idType2.setValue("SVN123456789");
    idType2.setSchemeID("CFR");
    faQueryParameter2.setValueID(idType2);
    FAQueryParameter faQueryParameter3 = new FAQueryParameter();
    CodeType codeType3 = new CodeType();
    codeType3.setValue(SubCriteriaType.TRIPID.value());
    faQueryParameter3.setTypeCode(codeType3);
    IDType idType3 = new IDType();
    idType3.setValue("FRA-TRP-2016122102030");
    idType3.setSchemeID("EU_TRIP_ID");
    faQueryParameter3.setValueID(idType3);
    FAQueryParameter faQueryParameter4 = new FAQueryParameter();
    CodeType codeType4 = new CodeType();
    codeType4.setValue("CONSOLIDATED");
    CodeType valueCode = new CodeType();
    valueCode.setListID("BOOLEAN_VALUE");
    valueCode.setValue("Y");
    faQueryParameter4.setTypeCode(codeType4);
    faQueryParameter4.setValueCode(valueCode);
    List<FAQueryParameter> faQueryParameters = new ArrayList<>();
    faQueryParameters.add(faQueryParameter);
    faQueryParameters.add(faQueryParameter2);
    faQueryParameters.add(faQueryParameter3);
    faQueryParameters.add(faQueryParameter4);
    FAQuery faQuery = new FAQuery();
    faQuery.setSpecifiedDelimitedPeriod(delimitedPeriod);
    faQuery.setSimpleFAQueryParameters(faQueryParameters);
    faQuery.setSubmitterFLUXParty(fluxParty);
    fluxfaQueryMessage.setFAQuery(faQuery);
}
Also used : FAQueryParameter(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FAQueryParameter) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) DateTimeType(un.unece.uncefact.data.standard.unqualifieddatatype._20.DateTimeType) DelimitedPeriod(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.DelimitedPeriod) FAQuery(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FAQuery) GregorianCalendar(java.util.GregorianCalendar) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) ArrayList(java.util.ArrayList) CodeType(un.unece.uncefact.data.standard.unqualifieddatatype._20.CodeType) IDType(un.unece.uncefact.data.standard.unqualifieddatatype._20.IDType) FLUXParty(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FLUXParty) DateTime(org.joda.time.DateTime) Before(org.junit.Before) 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