Search in sources :

Example 11 with AssetListQuery

use of eu.europa.ec.fisheries.wsdl.asset.types.AssetListQuery in project UVMS-Docker by UnionVMS.

the class AssetRestIT method getAssetListTest.

/**
 * Gets the asset list test.
 *
 * @return the asset list test
 * @throws Exception
 *             the exception
 */
@Test
public void getAssetListTest() throws Exception {
    Asset asset = AssetTestHelper.createTestAsset();
    AssetListQuery assetListQuery = AssetTestHelper.getBasicAssetQuery();
    AssetListCriteriaPair assetListCriteriaPair = new AssetListCriteriaPair();
    assetListCriteriaPair.setKey(ConfigSearchField.FLAG_STATE);
    assetListCriteriaPair.setValue(asset.getCountryCode());
    assetListQuery.getAssetSearchCriteria().getCriterias().add(assetListCriteriaPair);
    ListAssetResponse assetListResponse = AssetTestHelper.assetListQuery(assetListQuery);
    List<Asset> assets = assetListResponse.getAsset();
    assertTrue(assets.contains(asset));
}
Also used : AssetListCriteriaPair(eu.europa.ec.fisheries.wsdl.asset.types.AssetListCriteriaPair) AssetListQuery(eu.europa.ec.fisheries.wsdl.asset.types.AssetListQuery) Asset(eu.europa.ec.fisheries.wsdl.asset.types.Asset) ListAssetResponse(eu.europa.ec.fisheries.wsdl.asset.types.ListAssetResponse) Test(org.junit.Test) AbstractRestServiceTest(eu.europa.ec.fisheries.uvms.docker.validation.common.AbstractRestServiceTest)

Example 12 with AssetListQuery

use of eu.europa.ec.fisheries.wsdl.asset.types.AssetListQuery in project UVMS-Docker by UnionVMS.

the class AssetRestIT method getAssetListWithLikeSearchValue_CHANGE_KEY_AND_FAIL.

@Test
public void getAssetListWithLikeSearchValue_CHANGE_KEY_AND_FAIL() throws Exception {
    Asset asset = AssetTestHelper.createTestAsset();
    String guid = asset.getAssetId().getGuid();
    String theValue = UUID.randomUUID().toString();
    String newName = asset.getName() + "Changed";
    asset.setName(newName);
    asset.setIccat(theValue);
    AssetTestHelper.updateAsset(asset);
    AssetListQuery assetListQuery = AssetTestHelper.getBasicAssetQuery();
    AssetListCriteriaPair assetListCriteriaPair_ICCAT = new AssetListCriteriaPair();
    assetListCriteriaPair_ICCAT.setKey(ConfigSearchField.ICCAT);
    assetListCriteriaPair_ICCAT.setValue(theValue);
    AssetListCriteriaPair assetListCriteriaPair_UUID = new AssetListCriteriaPair();
    assetListCriteriaPair_UUID.setKey(ConfigSearchField.GUID);
    assetListCriteriaPair_UUID.setValue(guid);
    assetListQuery.getAssetSearchCriteria().getCriterias().add(assetListCriteriaPair_ICCAT);
    assetListQuery.getAssetSearchCriteria().getCriterias().add(assetListCriteriaPair_UUID);
    ListAssetResponse listAssetResponse = AssetTestHelper.assetListQuery(assetListQuery);
    List<Asset> fetchedAsssets = listAssetResponse.getAsset();
    assertFalse(fetchedAsssets.contains(asset));
}
Also used : AssetListCriteriaPair(eu.europa.ec.fisheries.wsdl.asset.types.AssetListCriteriaPair) AssetListQuery(eu.europa.ec.fisheries.wsdl.asset.types.AssetListQuery) Asset(eu.europa.ec.fisheries.wsdl.asset.types.Asset) ListAssetResponse(eu.europa.ec.fisheries.wsdl.asset.types.ListAssetResponse) Test(org.junit.Test) AbstractRestServiceTest(eu.europa.ec.fisheries.uvms.docker.validation.common.AbstractRestServiceTest)

Example 13 with AssetListQuery

use of eu.europa.ec.fisheries.wsdl.asset.types.AssetListQuery in project UVMS-Docker by UnionVMS.

the class AssetTestHelper method getAssetCountSweden.

// ************************************************
// Misc
// ************************************************
public static Integer getAssetCountSweden() throws ClientProtocolException, JsonProcessingException, IOException {
    AssetListQuery assetListQuery = getBasicAssetQuery();
    AssetListCriteriaPair assetListCriteriaPair = new AssetListCriteriaPair();
    assetListCriteriaPair.setKey(ConfigSearchField.FLAG_STATE);
    assetListCriteriaPair.setValue("SWE");
    assetListQuery.getAssetSearchCriteria().getCriterias().add(assetListCriteriaPair);
    final HttpResponse response = Request.Post(getBaseUrl() + "asset/rest/asset/listcount").setHeader("Content-Type", "application/json").setHeader("Authorization", getValidJwtToken()).bodyByteArray(writeValueAsString(assetListQuery).getBytes()).execute().returnResponse();
    return checkSuccessResponseReturnInt(response);
}
Also used : AssetListCriteriaPair(eu.europa.ec.fisheries.wsdl.asset.types.AssetListCriteriaPair) AssetListQuery(eu.europa.ec.fisheries.wsdl.asset.types.AssetListQuery) HttpResponse(org.apache.http.HttpResponse)

Example 14 with AssetListQuery

use of eu.europa.ec.fisheries.wsdl.asset.types.AssetListQuery in project UVMS-ActivityModule-APP by UnionVMS.

the class FishingTripServiceBean method enrichWithAssetsModuleDataIfNeeded.

// need confirmation for removal of this method
private void enrichWithAssetsModuleDataIfNeeded(VesselDetailsDTO vesselDetailsDTO) {
    if (vesselDetailsDTO != null && vesselDetailsDTO.hasEmptyIdentifierValues()) {
        try {
            Set<AssetIdentifierDto> vesselIdentifiers = vesselDetailsDTO.getVesselIdentifiers();
            List<AssetListCriteriaPair> assetListCriteriaPairs = BaseMapper.mapToAssetListCriteriaPairList(vesselIdentifiers);
            AssetListCriteria criteria = new AssetListCriteria();
            criteria.getCriterias().addAll(assetListCriteriaPairs);
            AssetListQuery query = new AssetListQuery();
            query.setAssetSearchCriteria(criteria);
            List<Asset> assetList = assetModuleService.getAssetListResponse(query);
            vesselDetailsDTO.enrichIdentifiers(assetList.get(0));
        } catch (ServiceException e) {
            log.error("Error while trying to send message to Assets module.", e);
        }
    }
}
Also used : AssetIdentifierDto(eu.europa.ec.fisheries.ers.service.dto.AssetIdentifierDto) AssetListCriteriaPair(eu.europa.ec.fisheries.wsdl.asset.types.AssetListCriteriaPair) ServiceException(eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException) AssetListQuery(eu.europa.ec.fisheries.wsdl.asset.types.AssetListQuery) Asset(eu.europa.ec.fisheries.wsdl.asset.types.Asset) AssetListCriteria(eu.europa.ec.fisheries.wsdl.asset.types.AssetListCriteria)

Aggregations

AssetListQuery (eu.europa.ec.fisheries.wsdl.asset.types.AssetListQuery)14 AssetListCriteriaPair (eu.europa.ec.fisheries.wsdl.asset.types.AssetListCriteriaPair)13 Asset (eu.europa.ec.fisheries.wsdl.asset.types.Asset)12 Test (org.junit.Test)10 AbstractRestServiceTest (eu.europa.ec.fisheries.uvms.docker.validation.common.AbstractRestServiceTest)9 ListAssetResponse (eu.europa.ec.fisheries.wsdl.asset.types.ListAssetResponse)8 AssetListCriteria (eu.europa.ec.fisheries.wsdl.asset.types.AssetListCriteria)3 AssetIdentifierDto (eu.europa.ec.fisheries.ers.service.dto.AssetIdentifierDto)2 ServiceException (eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException)2 AssetListPagination (eu.europa.ec.fisheries.wsdl.asset.types.AssetListPagination)2 BigInteger (java.math.BigInteger)1 ArrayList (java.util.ArrayList)1 HttpResponse (org.apache.http.HttpResponse)1