Search in sources :

Example 1 with MovementDTO

use of eu.europa.ec.fisheries.uvms.reporting.service.dto.MovementDTO in project UVMS-Docker by UnionVMS.

the class MovementMovementRestIT method getLatestMovementsByConnectIdsTest.

/**
 * Gets the latest movements by connect ids test.
 *
 * @return the latest movements by connect ids test
 * @throws Exception
 *             the exception
 */
@Test
public void getLatestMovementsByConnectIdsTest() throws Exception {
    Asset testAsset = AssetTestHelper.createTestAsset();
    MobileTerminalType mobileTerminalType = MobileTerminalTestHelper.createMobileTerminalType();
    MobileTerminalTestHelper.assignMobileTerminal(testAsset, mobileTerminalType);
    LatLong latLong = new LatLong(16.9, 32.6333333, new Date(System.currentTimeMillis()));
    CreateMovementRequest createMovementRequest = movementHelper.createMovementRequest(testAsset, mobileTerminalType, latLong);
    CreateMovementResponse createMovementResponse = movementHelper.createMovement(testAsset, mobileTerminalType, createMovementRequest);
    List<String> connectIds = new ArrayList<>();
    assertNotNull(createMovementResponse);
    assertNotNull(createMovementResponse.getMovement());
    assertNotNull(createMovementResponse.getMovement().getConnectId());
    String connectId = createMovementResponse.getMovement().getConnectId();
    connectIds.add(connectId);
    // give it some time to execute before retrieving TODO: Remove the functionality and this horrible test
    Thread.sleep(10000);
    final HttpResponse response = Request.Post(getBaseUrl() + "movement/rest/movement/latest").setHeader("Content-Type", "application/json").setHeader("Authorization", getValidJwtToken()).bodyByteArray(writeValueAsString(connectIds).getBytes()).execute().returnResponse();
    List<MovementDTO> dataList = checkSuccessResponseReturnType(response, ArrayList.class);
    assertTrue(dataList.size() > 0);
}
Also used : CreateMovementRequest(eu.europa.ec.fisheries.schema.movement.module.v1.CreateMovementRequest) CreateMovementResponse(eu.europa.ec.fisheries.schema.movement.module.v1.CreateMovementResponse) ArrayList(java.util.ArrayList) MovementDTO(eu.europa.ec.fisheries.uvms.reporting.service.dto.MovementDTO) Asset(eu.europa.ec.fisheries.wsdl.asset.types.Asset) HttpResponse(org.apache.http.HttpResponse) MobileTerminalType(eu.europa.ec.fisheries.schema.mobileterminal.types.v1.MobileTerminalType) Date(java.util.Date) Test(org.junit.Test) AbstractRestServiceTest(eu.europa.ec.fisheries.uvms.docker.validation.common.AbstractRestServiceTest)

Aggregations

MobileTerminalType (eu.europa.ec.fisheries.schema.mobileterminal.types.v1.MobileTerminalType)1 CreateMovementRequest (eu.europa.ec.fisheries.schema.movement.module.v1.CreateMovementRequest)1 CreateMovementResponse (eu.europa.ec.fisheries.schema.movement.module.v1.CreateMovementResponse)1 AbstractRestServiceTest (eu.europa.ec.fisheries.uvms.docker.validation.common.AbstractRestServiceTest)1 MovementDTO (eu.europa.ec.fisheries.uvms.reporting.service.dto.MovementDTO)1 Asset (eu.europa.ec.fisheries.wsdl.asset.types.Asset)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 HttpResponse (org.apache.http.HttpResponse)1 Test (org.junit.Test)1