Search in sources :

Example 1 with VesselCountryType

use of un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._18.VesselCountryType in project UVMS-Docker by UnionVMS.

the class FluxMessageReceiverBeanIT method postRequestTypeRequestSuccessTest.

/**
 * Post request type request success test.
 *
 * @throws Exception the exception
 */
@Test
@Ignore
public void postRequestTypeRequestSuccessTest() throws Exception {
    Asset testAsset = AssetTestHelper.createTestAsset();
    MobileTerminalType mobileTerminalType = MobileTerminalTestHelper.createMobileTerminalType();
    MobileTerminalTestHelper.assignMobileTerminal(testAsset, mobileTerminalType);
    GregorianCalendar calendar = new GregorianCalendar();
    calendar.setTime(new Date());
    BridgeConnectorPortType bridgeConnectorPortType = createBridgeConnector();
    RequestType requestType = new RequestType();
    FLUXVesselPositionMessage fLUXVesselPositionMessage = new FLUXVesselPositionMessage();
    VesselTransportMeansType vesselTransportMeansType = new VesselTransportMeansType();
    IDType cfrId = new IDType();
    cfrId.setSchemeID("CFR");
    cfrId.setValue(testAsset.getCfr());
    vesselTransportMeansType.getIDS().add(cfrId);
    IDType ircsId = new IDType();
    ircsId.setSchemeID("IRCS");
    ircsId.setValue(testAsset.getIrcs());
    vesselTransportMeansType.getIDS().add(ircsId);
    // IDType extMarkingId = new IDType();
    // extMarkingId.setSchemeID("EXT_MARKING");
    // extMarkingId.setValue(testAsset.getExternalMarking());
    // vesselTransportMeansType.getIDS().add(extMarkingId);
    VesselCountryType vesselCountry = new VesselCountryType();
    IDType countryId = new IDType();
    countryId.setValue("SWE");
    vesselCountry.setID(countryId);
    vesselTransportMeansType.setRegistrationVesselCountry(vesselCountry);
    VesselPositionEventType vesselPositionEventType = new VesselPositionEventType();
    MeasureType measureType = new MeasureType();
    measureType.setValue(new BigDecimal(282));
    vesselPositionEventType.setCourseValueMeasure(measureType);
    DateTimeType posDateTime = new DateTimeType();
    posDateTime.setDateTime(DatatypeFactory.newInstance().newXMLGregorianCalendar(calendar));
    vesselPositionEventType.setObtainedOccurrenceDateTime(posDateTime);
    VesselGeographicalCoordinateType cordinates = new VesselGeographicalCoordinateType();
    MeasureType longitude = new MeasureType();
    longitude.setValue(new BigDecimal(21.5740000000));
    cordinates.setLongitudeMeasure(longitude);
    MeasureType latitude = new MeasureType();
    latitude.setValue(new BigDecimal(59.6480000000));
    cordinates.setLatitudeMeasure(latitude);
    vesselPositionEventType.setSpecifiedVesselGeographicalCoordinate(cordinates);
    MeasureType speedValue = new MeasureType();
    speedValue.setValue(new BigDecimal(7.5));
    vesselPositionEventType.setSpeedValueMeasure(speedValue);
    CodeType typeCodeValue = new CodeType();
    typeCodeValue.setValue("POS");
    vesselPositionEventType.setTypeCode(typeCodeValue);
    vesselTransportMeansType.getSpecifiedVesselPositionEvents().add(vesselPositionEventType);
    fLUXVesselPositionMessage.setVesselTransportMeans(vesselTransportMeansType);
    FLUXReportDocumentType fluxReportDocumentType = new FLUXReportDocumentType();
    DateTimeType dateTimeType = new DateTimeType();
    dateTimeType.setDateTime(DatatypeFactory.newInstance().newXMLGregorianCalendar(calendar));
    fluxReportDocumentType.setCreationDateTime(dateTimeType);
    FLUXPartyType fLUXPartyType = new FLUXPartyType();
    fLUXPartyType.getIDS().add(countryId);
    fluxReportDocumentType.setOwnerFLUXParty(fLUXPartyType);
    TextType textType = new TextType();
    fluxReportDocumentType.setPurpose(textType);
    CodeType purposeCode = new CodeType();
    purposeCode.setValue("9");
    fluxReportDocumentType.setPurposeCode(purposeCode);
    IDType idType = new IDType();
    fluxReportDocumentType.setReferencedID(idType);
    CodeType typeCode = new CodeType();
    fluxReportDocumentType.setTypeCode(typeCode);
    fLUXVesselPositionMessage.setFLUXReportDocument(fluxReportDocumentType);
    requestType.setAny(createAnyElement(fLUXVesselPositionMessage));
    requestType.setAD("SWE");
    requestType.setAR(true);
    requestType.setDF("df");
    requestType.setON("on");
    requestType.setTO(1234);
    requestType.setTODT(DatatypeFactory.newInstance().newXMLGregorianCalendar(calendar));
    ResponseType responseType = bridgeConnectorPortType.post(requestType);
    assertNotNull(responseType);
    assertEquals("OK", responseType.getStatus());
    Thread.sleep(7500);
    List<String> connectIds = new ArrayList<>();
    connectIds.add(testAsset.getEventHistory().getEventId());
    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 dataList = checkSuccessResponseReturnType(response, List.class);
    assertEquals("Expect one position in movement db", 1, dataList.size());
}
Also used : ArrayList(java.util.ArrayList) MeasureType(un.unece.uncefact.data.standard.unqualifieddatatype._18.MeasureType) FLUXReportDocumentType(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._18.FLUXReportDocumentType) IDType(un.unece.uncefact.data.standard.unqualifieddatatype._18.IDType) BridgeConnectorPortType(xeu.bridge_connector.wsdl.v1.BridgeConnectorPortType) Asset(eu.europa.ec.fisheries.wsdl.asset.types.Asset) ArrayList(java.util.ArrayList) List(java.util.List) MobileTerminalType(eu.europa.ec.fisheries.schema.mobileterminal.types.v1.MobileTerminalType) VesselCountryType(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._18.VesselCountryType) FLUXVesselPositionMessage(un.unece.uncefact.data.standard.fluxvesselpositionmessage._4.FLUXVesselPositionMessage) VesselGeographicalCoordinateType(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._18.VesselGeographicalCoordinateType) GregorianCalendar(java.util.GregorianCalendar) VesselPositionEventType(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._18.VesselPositionEventType) HttpResponse(org.apache.http.HttpResponse) VesselTransportMeansType(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._18.VesselTransportMeansType) FLUXPartyType(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._18.FLUXPartyType) Date(java.util.Date) BigDecimal(java.math.BigDecimal) TextType(un.unece.uncefact.data.standard.unqualifieddatatype._18.TextType) ResponseType(xeu.bridge_connector.v1.ResponseType) DateTimeType(un.unece.uncefact.data.standard.unqualifieddatatype._18.DateTimeType) CodeType(un.unece.uncefact.data.standard.unqualifieddatatype._18.CodeType) RequestType(xeu.bridge_connector.v1.RequestType) Ignore(org.junit.Ignore) 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 AbstractRestServiceTest (eu.europa.ec.fisheries.uvms.docker.validation.common.AbstractRestServiceTest)1 Asset (eu.europa.ec.fisheries.wsdl.asset.types.Asset)1 BigDecimal (java.math.BigDecimal)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 GregorianCalendar (java.util.GregorianCalendar)1 List (java.util.List)1 HttpResponse (org.apache.http.HttpResponse)1 Ignore (org.junit.Ignore)1 Test (org.junit.Test)1 FLUXVesselPositionMessage (un.unece.uncefact.data.standard.fluxvesselpositionmessage._4.FLUXVesselPositionMessage)1 FLUXPartyType (un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._18.FLUXPartyType)1 FLUXReportDocumentType (un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._18.FLUXReportDocumentType)1 VesselCountryType (un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._18.VesselCountryType)1 VesselGeographicalCoordinateType (un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._18.VesselGeographicalCoordinateType)1 VesselPositionEventType (un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._18.VesselPositionEventType)1 VesselTransportMeansType (un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._18.VesselTransportMeansType)1 CodeType (un.unece.uncefact.data.standard.unqualifieddatatype._18.CodeType)1 DateTimeType (un.unece.uncefact.data.standard.unqualifieddatatype._18.DateTimeType)1