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));
}
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));
}
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));
}
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);
}
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;
}
Aggregations