Search in sources :

Example 11 with AssetListCriteriaPair

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

the class AssetRestIT method assetListQueryHistoryGuidTest.

@Test
public void assetListQueryHistoryGuidTest() throws Exception {
    // Create asset versions
    Asset asset1 = AssetTestHelper.createTestAsset();
    Asset asset2 = AssetTestHelper.getAssetByGuid(asset1.getAssetId().getGuid());
    asset2.setName(asset2.getName() + "1");
    asset2 = AssetTestHelper.updateAsset(asset2);
    Asset asset3 = AssetTestHelper.getAssetByGuid(asset2.getAssetId().getGuid());
    asset3.setName(asset3.getName() + "2");
    asset3 = AssetTestHelper.updateAsset(asset3);
    AssetListQuery assetListQuery1 = AssetTestHelper.getBasicAssetQuery();
    AssetListCriteriaPair assetListCriteriaPair = new AssetListCriteriaPair();
    assetListCriteriaPair.setKey(ConfigSearchField.HIST_GUID);
    assetListCriteriaPair.setValue(asset1.getEventHistory().getEventId());
    assetListQuery1.getAssetSearchCriteria().getCriterias().add(assetListCriteriaPair);
    ListAssetResponse assetHistory1 = AssetTestHelper.assetListQuery(assetListQuery1);
    List<Asset> assets = assetHistory1.getAsset();
    assertEquals(1, assets.size());
    assertEquals(asset1, assets.get(0));
    AssetListQuery assetListQuery2 = AssetTestHelper.getBasicAssetQuery();
    AssetListCriteriaPair assetListCriteriaPair2 = new AssetListCriteriaPair();
    assetListCriteriaPair2.setKey(ConfigSearchField.HIST_GUID);
    assetListCriteriaPair2.setValue(asset2.getEventHistory().getEventId());
    assetListQuery2.getAssetSearchCriteria().getCriterias().add(assetListCriteriaPair2);
    ListAssetResponse assetHistory2 = AssetTestHelper.assetListQuery(assetListQuery2);
    List<Asset> assets2 = assetHistory2.getAsset();
    assertEquals(1, assets2.size());
    assertEquals(asset2, assets2.get(0));
    AssetListQuery assetListQuery3 = AssetTestHelper.getBasicAssetQuery();
    AssetListCriteriaPair assetListCriteriaPair3 = new AssetListCriteriaPair();
    assetListCriteriaPair3.setKey(ConfigSearchField.HIST_GUID);
    assetListCriteriaPair3.setValue(asset3.getEventHistory().getEventId());
    assetListQuery3.getAssetSearchCriteria().getCriterias().add(assetListCriteriaPair3);
    ListAssetResponse assetHistory3 = AssetTestHelper.assetListQuery(assetListQuery3);
    List<Asset> assets3 = assetHistory3.getAsset();
    assertEquals(1, assets3.size());
    assertEquals(asset3, assets3.get(0));
}
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 AssetListCriteriaPair

use of eu.europa.ec.fisheries.wsdl.asset.types.AssetListCriteriaPair 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 13 with AssetListCriteriaPair

use of eu.europa.ec.fisheries.wsdl.asset.types.AssetListCriteriaPair 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 14 with AssetListCriteriaPair

use of eu.europa.ec.fisheries.wsdl.asset.types.AssetListCriteriaPair 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 15 with AssetListCriteriaPair

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

the class BaseMapper method mapToAssetListCriteriaPairList.

public static List<AssetListCriteriaPair> mapToAssetListCriteriaPairList(Set<AssetIdentifierDto> identifierDtoSet) {
    List<AssetListCriteriaPair> criteriaList = new ArrayList<>();
    for (AssetIdentifierDto identifierDto : identifierDtoSet) {
        AssetListCriteriaPair criteriaPair = new AssetListCriteriaPair();
        VesselIdentifierSchemeIdEnum identifierSchemeId = identifierDto.getIdentifierSchemeId();
        ConfigSearchField key = VesselIdentifierMapper.INSTANCE.map(identifierSchemeId);
        String identifierId = identifierDto.getFaIdentifierId();
        if (key != null && identifierId != null) {
            criteriaPair.setKey(key);
            criteriaPair.setValue(identifierId);
            criteriaList.add(criteriaPair);
        }
    }
    return criteriaList;
}
Also used : ConfigSearchField(eu.europa.ec.fisheries.wsdl.asset.types.ConfigSearchField) AssetListCriteriaPair(eu.europa.ec.fisheries.wsdl.asset.types.AssetListCriteriaPair) AssetIdentifierDto(eu.europa.ec.fisheries.ers.service.dto.AssetIdentifierDto) ArrayList(java.util.ArrayList) VesselIdentifierSchemeIdEnum(eu.europa.ec.fisheries.uvms.activity.model.schemas.VesselIdentifierSchemeIdEnum)

Aggregations

AssetListCriteriaPair (eu.europa.ec.fisheries.wsdl.asset.types.AssetListCriteriaPair)17 AssetListQuery (eu.europa.ec.fisheries.wsdl.asset.types.AssetListQuery)13 Asset (eu.europa.ec.fisheries.wsdl.asset.types.Asset)12 Test (org.junit.Test)12 AbstractRestServiceTest (eu.europa.ec.fisheries.uvms.docker.validation.common.AbstractRestServiceTest)9 ListAssetResponse (eu.europa.ec.fisheries.wsdl.asset.types.ListAssetResponse)8 AssetIdentifierDto (eu.europa.ec.fisheries.ers.service.dto.AssetIdentifierDto)6 ConfigSearchField (eu.europa.ec.fisheries.wsdl.asset.types.ConfigSearchField)4 ArrayList (java.util.ArrayList)4 BaseUnitilsTest (eu.europa.ec.fisheries.uvms.BaseUnitilsTest)2 VesselIdentifierSchemeIdEnum (eu.europa.ec.fisheries.uvms.activity.model.schemas.VesselIdentifierSchemeIdEnum)2 ServiceException (eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException)2 AssetListCriteria (eu.europa.ec.fisheries.wsdl.asset.types.AssetListCriteria)2 AssetListPagination (eu.europa.ec.fisheries.wsdl.asset.types.AssetListPagination)1 BigInteger (java.math.BigInteger)1 HttpResponse (org.apache.http.HttpResponse)1