Search in sources :

Example 36 with Asset

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

the class AssetHistoryRestIT method getAssetFromAssetIdAndDate.

@Test
public void getAssetFromAssetIdAndDate() throws Exception {
    try {
        Date eventDate = null;
        AssetHistoryId history = null;
        // Create asset
        Asset asset = AssetTestHelper.createCfrTestAsset();
        history = asset.getEventHistory();
        eventDate = history.getEventDate();
        Thread.sleep(1000);
        AssetIdType assetIdType = AssetIdType.CFR;
        String value = asset.getCfr();
        String type = assetIdType.value();
        Asset fetchedAsset = AssetTestHelper.getAssetFromAssetIdAndDate(type, value, eventDate);
        Assert.assertEquals(asset.getCfr(), fetchedAsset.getCfr());
    } catch (RuntimeException e) {
        System.out.println(e.toString());
    }
}
Also used : AssetIdType(eu.europa.ec.fisheries.wsdl.asset.types.AssetIdType) AssetHistoryId(eu.europa.ec.fisheries.wsdl.asset.types.AssetHistoryId) Asset(eu.europa.ec.fisheries.wsdl.asset.types.Asset) Date(java.util.Date) Test(org.junit.Test) AbstractRestServiceTest(eu.europa.ec.fisheries.uvms.docker.validation.common.AbstractRestServiceTest)

Example 37 with Asset

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

the class AssetHistoryRestIT method getAssetHistoryListByAssetIdHistoriesIsRetainedTest.

@Test
public void getAssetHistoryListByAssetIdHistoriesIsRetainedTest() 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);
    List<Asset> assetHistories = AssetTestHelper.getAssetHistoryFromAssetGuid(asset3.getAssetId().getGuid());
    assertTrue(assetHistories.size() == 3);
    assertTrue(assetHistories.contains(asset1));
    assertTrue(assetHistories.contains(asset2));
    assertTrue(assetHistories.contains(asset3));
}
Also used : Asset(eu.europa.ec.fisheries.wsdl.asset.types.Asset) Test(org.junit.Test) AbstractRestServiceTest(eu.europa.ec.fisheries.uvms.docker.validation.common.AbstractRestServiceTest)

Example 38 with Asset

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

the class AssetHistoryRestIT method getAssetHistoryByAssetHistGuidTest.

/**
 * Gets the asset history by asset hist guid test.
 *
 * @return the asset history by asset hist guid test
 * @throws Exception
 *             the exception
 */
@Test
// FIXME timeout on jenkins
@Ignore
public void getAssetHistoryByAssetHistGuidTest() throws Exception {
    Asset asset = AssetTestHelper.createTestAsset();
    Asset assetFromHistory = AssetTestHelper.getAssetHistoryFromHistoryGuid(asset.getEventHistory().getEventId());
    assertEquals(asset, assetFromHistory);
}
Also used : Asset(eu.europa.ec.fisheries.wsdl.asset.types.Asset) Ignore(org.junit.Ignore) Test(org.junit.Test) AbstractRestServiceTest(eu.europa.ec.fisheries.uvms.docker.validation.common.AbstractRestServiceTest)

Example 39 with Asset

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

the class AssetHistoryRestIT method getAssetFlagStateByAssetIdAndDate.

@Test
public void getAssetFlagStateByAssetIdAndDate() throws Exception {
    try {
        Date eventDate = null;
        AssetHistoryId history = null;
        Date aNorDate = null;
        // Create asset versions
        Asset asset = AssetTestHelper.createTestAsset();
        String assetGuid = asset.getAssetId().getGuid();
        history = asset.getEventHistory();
        eventDate = history.getEventDate();
        Thread.sleep(1000);
        FlagStateType flagState = AssetTestHelper.getFlagStateFromAssetGuidAndDate(assetGuid, eventDate);
        String returnedCode = flagState.getCode();
        Assert.assertEquals("SWE", returnedCode);
        asset.setCountryCode("DNK");
        AssetTestHelper.updateAsset(asset);
        asset = AssetTestHelper.getAssetByGuid(assetGuid);
        history = asset.getEventHistory();
        eventDate = history.getEventDate();
        flagState = AssetTestHelper.getFlagStateFromAssetGuidAndDate(assetGuid, eventDate);
        returnedCode = flagState.getCode();
        Assert.assertEquals("DNK", returnedCode);
        asset.setCountryCode("NOR");
        asset = AssetTestHelper.updateAsset(asset);
        history = asset.getEventHistory();
        eventDate = history.getEventDate();
        aNorDate = history.getEventDate();
        Thread.sleep(1000);
        flagState = AssetTestHelper.getFlagStateFromAssetGuidAndDate(assetGuid, eventDate);
        returnedCode = flagState.getCode();
        Assert.assertEquals("NOR", returnedCode);
        asset.setCountryCode("DNK");
        asset = AssetTestHelper.updateAsset(asset);
        history = asset.getEventHistory();
        eventDate = history.getEventDate();
        Thread.sleep(1000);
        flagState = AssetTestHelper.getFlagStateFromAssetGuidAndDate(assetGuid, eventDate);
        returnedCode = flagState.getCode();
        Assert.assertEquals("DNK", returnedCode);
        asset.setCountryCode("SWE");
        asset = AssetTestHelper.updateAsset(asset);
        history = asset.getEventHistory();
        eventDate = history.getEventDate();
        Thread.sleep(1000);
        flagState = AssetTestHelper.getFlagStateFromAssetGuidAndDate(assetGuid, eventDate);
        returnedCode = flagState.getCode();
        Assert.assertEquals("SWE", returnedCode);
        asset.setCountryCode("DNK");
        asset = AssetTestHelper.updateAsset(asset);
        history = asset.getEventHistory();
        eventDate = history.getEventDate();
        Thread.sleep(1000);
        flagState = AssetTestHelper.getFlagStateFromAssetGuidAndDate(assetGuid, eventDate);
        returnedCode = flagState.getCode();
        Assert.assertEquals("DNK", returnedCode);
        // here we test a saved norwegian date
        flagState = AssetTestHelper.getFlagStateFromAssetGuidAndDate(assetGuid, aNorDate);
        returnedCode = flagState.getCode();
        Assert.assertEquals("NOR", returnedCode);
    } catch (RuntimeException e) {
        System.out.println(e.toString());
    }
}
Also used : FlagStateType(eu.europa.ec.fisheries.wsdl.asset.types.FlagStateType) AssetHistoryId(eu.europa.ec.fisheries.wsdl.asset.types.AssetHistoryId) Asset(eu.europa.ec.fisheries.wsdl.asset.types.Asset) Date(java.util.Date) Test(org.junit.Test) AbstractRestServiceTest(eu.europa.ec.fisheries.uvms.docker.validation.common.AbstractRestServiceTest)

Example 40 with Asset

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

the class AssetJMSIT method testGetAssetByCFR.

@Test
public void testGetAssetByCFR() throws Exception {
    Asset asset = AssetTestHelper.createDummyCFRAsset();
    asset = AssetTestHelper.createAsset(asset);
    Asset assetById = AssetJMSHelper.getAssetById(asset.getCfr(), AssetIdType.CFR);
    setDecimalScaleAndNullNotes(assetById);
    assertEquals(asset, assetById);
}
Also used : Asset(eu.europa.ec.fisheries.wsdl.asset.types.Asset) Test(org.junit.Test)

Aggregations

Asset (eu.europa.ec.fisheries.wsdl.asset.types.Asset)61 Test (org.junit.Test)54 AbstractRestServiceTest (eu.europa.ec.fisheries.uvms.docker.validation.common.AbstractRestServiceTest)38 MobileTerminalType (eu.europa.ec.fisheries.schema.mobileterminal.types.v1.MobileTerminalType)15 ArrayList (java.util.ArrayList)14 HttpResponse (org.apache.http.HttpResponse)14 AssetListQuery (eu.europa.ec.fisheries.wsdl.asset.types.AssetListQuery)13 AssetListCriteriaPair (eu.europa.ec.fisheries.wsdl.asset.types.AssetListCriteriaPair)12 CreateMovementRequest (eu.europa.ec.fisheries.schema.movement.module.v1.CreateMovementRequest)11 CreateMovementResponse (eu.europa.ec.fisheries.schema.movement.module.v1.CreateMovementResponse)9 ListAssetResponse (eu.europa.ec.fisheries.wsdl.asset.types.ListAssetResponse)8 Date (java.util.Date)5 AssetGroup (eu.europa.ec.fisheries.wsdl.asset.group.AssetGroup)4 AssetGroupSearchField (eu.europa.ec.fisheries.wsdl.asset.group.AssetGroupSearchField)4 Map (java.util.Map)4 AssetIdentifierDto (eu.europa.ec.fisheries.ers.service.dto.AssetIdentifierDto)3 List (java.util.List)3 VesselDetailsDTO (eu.europa.ec.fisheries.ers.service.dto.fareport.details.VesselDetailsDTO)2 ServiceException (eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException)2 LatLong (eu.europa.ec.fisheries.uvms.docker.validation.movement.LatLong)2