Search in sources :

Example 1 with no.difi.meldingsutveksling.noarkexchange.p360.schema

use of no.difi.meldingsutveksling.noarkexchange.p360.schema in project policies-ui-backend by RedHatInsights.

the class OapiTest method validateOpenApi.

@Test
void validateOpenApi() throws Exception {
    OpenApi3 model = new OpenApi3Parser().parse(url, true);
    System.out.printf("OpenAPI Model at %s\n", url);
    if (!model.isValid()) {
        for (ValidationResults.ValidationItem item : model.getValidationItems()) {
            System.err.println(item);
        }
        fail("OpenAPI spec is not valid");
    }
    // 
    // Now that basic validation is done, we can add some of our own
    // 
    Map<String, Path> paths = model.getPaths();
    Map<String, Schema> schemas = model.getSchemas();
    // The base path filler. See also OASModifier.mangleName
    assertTrue(paths.containsKey("/"));
    // User config is private, so don't show it
    assertFalse(paths.containsKey("/user-config"));
    assertFalse(schemas.containsKey("SettingsValues"));
    // Check that openapi does not (again) collapse parameters
    assertEquals(9, paths.get("/policies").getOperation("get").getParameters().size());
    // Check that all properties are present ( https://github.com/smallrye/smallrye-open-api/issues/437 )
    Map<String, Schema> policyProperties = schemas.get("Policy").getProperties();
    assertEquals(9, policyProperties.size());
    assertTrue(policyProperties.containsKey("ctime"));
    assertTrue(policyProperties.containsKey("mtime"));
    // Now that the OpenAPI file has been validated, save a copy to the filesystem
    // This file is going to be uploaded in a regular CI build to know the API state
    // for a given build.
    InputStream in = url.openStream();
    Files.copy(in, Paths.get(TARGET_OPENAPI), StandardCopyOption.REPLACE_EXISTING);
}
Also used : Path(com.reprezen.kaizen.oasparser.model3.Path) ValidationResults(com.reprezen.kaizen.oasparser.val.ValidationResults) InputStream(java.io.InputStream) Schema(com.reprezen.kaizen.oasparser.model3.Schema) OpenApi3Parser(com.reprezen.kaizen.oasparser.OpenApi3Parser) OpenApi3(com.reprezen.kaizen.oasparser.model3.OpenApi3) QuarkusTest(io.quarkus.test.junit.QuarkusTest) Test(org.junit.jupiter.api.Test)

Example 2 with no.difi.meldingsutveksling.noarkexchange.p360.schema

use of no.difi.meldingsutveksling.noarkexchange.p360.schema in project efm-integrasjonspunkt by felleslosninger.

the class P360Client method sendEduMelding.

@Override
public PutMessageResponseType sendEduMelding(PutMessageRequestType request) {
    JAXBElement<no.difi.meldingsutveksling.noarkexchange.p360.schema.PutMessageRequestType> p360request = new PutMessageRequestMapper().mapFrom(request);
    final WebServiceTemplate template = templateFactory.createTemplate("no.difi.meldingsutveksling.noarkexchange.p360.schema", PutMessageMarker.markerFrom(new PutMessageRequestWrapper(request)));
    JAXBElement<no.difi.meldingsutveksling.noarkexchange.p360.schema.PutMessageResponseType> response = (JAXBElement<no.difi.meldingsutveksling.noarkexchange.p360.schema.PutMessageResponseType>) template.marshalSendAndReceive(settings.getEndpointUrl(), p360request, new SoapActionCallback(SOAP_ACTION));
    PutMessageResponseType theResponse = new PutMessageResponseType();
    ModelMapper modelMapper = new ModelMapper();
    modelMapper.map(response.getValue(), theResponse);
    setUnmappedValues(response, theResponse);
    if (!isValid(theResponse)) {
        theResponse = new PutMessageResponseType();
        final no.difi.meldingsutveksling.noarkexchange.schema.AppReceiptType appReceiptType = new no.difi.meldingsutveksling.noarkexchange.schema.AppReceiptType();
        theResponse.setResult(appReceiptType);
        appReceiptType.setType("OK");
    }
    return theResponse;
}
Also used : no.difi.meldingsutveksling.noarkexchange.p360.schema(no.difi.meldingsutveksling.noarkexchange.p360.schema) PutMessageResponseType(no.difi.meldingsutveksling.noarkexchange.schema.PutMessageResponseType) JAXBElement(javax.xml.bind.JAXBElement) PutMessageRequestMapper(no.difi.meldingsutveksling.noarkexchange.p360.PutMessageRequestMapper) WebServiceTemplate(org.springframework.ws.client.core.WebServiceTemplate) ModelMapper(org.modelmapper.ModelMapper) PutMessageRequestType(no.difi.meldingsutveksling.noarkexchange.schema.PutMessageRequestType) SoapActionCallback(org.springframework.ws.soap.client.core.SoapActionCallback)

Example 3 with no.difi.meldingsutveksling.noarkexchange.p360.schema

use of no.difi.meldingsutveksling.noarkexchange.p360.schema in project efm-integrasjonspunkt by felleslosninger.

the class P360PutMessageRequestMapperTest method mapFromEphortePutMessageToP360PutMessage.

@Disabled("Work in progress")
@Test
public void mapFromEphortePutMessageToP360PutMessage() throws JAXBException, XMLStreamException {
    PutMessageRequestType putMessageRequestType = testData.loadFromClasspath("ephorte/PutMessageMessage.xml");
    PutMessageRequestMapper mapper = new PutMessageRequestMapper();
    no.difi.meldingsutveksling.noarkexchange.p360.schema.PutMessageRequestType p360Request = mapper.mapFrom(putMessageRequestType).getValue();
    assertFalse(PayloadUtil.isEmpty(p360Request.getPayload()));
    // assertTrue(p360Request.getPayload().contains("Melding"));
    JAXBContext ctx2 = JAXBContext.newInstance(PutMessageRequestType.class);
    Marshaller marshaller = ctx2.createMarshaller();
    StringWriter writer = new StringWriter();
    marshaller.marshal(new ObjectFactory().createPutMessageRequest(putMessageRequestType), writer);
    String xml = writer.toString();
    JAXBContext ctx = JAXBContext.newInstance(no.difi.meldingsutveksling.noarkexchange.p360.schema.PutMessageRequestType.class);
    Unmarshaller unmarshaller = ctx.createUnmarshaller();
    // System.out.println(xml);
    no.difi.meldingsutveksling.noarkexchange.p360.schema.PutMessageRequestType p360result = unmarshaller.unmarshal(new StringSource(xml), no.difi.meldingsutveksling.noarkexchange.p360.schema.PutMessageRequestType.class).getValue();
    System.out.println(p360result.getPayload());
}
Also used : PutMessageRequestMapper(no.difi.meldingsutveksling.noarkexchange.p360.PutMessageRequestMapper) PutMessageRequestType(no.difi.meldingsutveksling.noarkexchange.schema.PutMessageRequestType) StringWriter(java.io.StringWriter) ObjectFactory(no.difi.meldingsutveksling.noarkexchange.schema.ObjectFactory) StringSource(org.springframework.xml.transform.StringSource) Test(org.junit.jupiter.api.Test) Disabled(org.junit.jupiter.api.Disabled)

Example 4 with no.difi.meldingsutveksling.noarkexchange.p360.schema

use of no.difi.meldingsutveksling.noarkexchange.p360.schema in project efm-integrasjonspunkt by felleslosninger.

the class P360PutMessageRequestMapperTest method emptyPayloadEphorteBug.

@Test
public void emptyPayloadEphorteBug() throws JAXBException, XMLStreamException {
    PutMessageRequestType putMessageRequestType = testData.loadFromClasspath("ephorte/EmptyPayload.xml");
    PutMessageRequestMapper mapper = new PutMessageRequestMapper();
    final JAXBElement<no.difi.meldingsutveksling.noarkexchange.p360.schema.PutMessageRequestType> p360PutMessage = mapper.mapFrom(putMessageRequestType);
    Assertions.assertNotNull(p360PutMessage.getValue().getPayload());
}
Also used : PutMessageRequestType(no.difi.meldingsutveksling.noarkexchange.schema.PutMessageRequestType) PutMessageRequestMapper(no.difi.meldingsutveksling.noarkexchange.p360.PutMessageRequestMapper) Test(org.junit.jupiter.api.Test)

Example 5 with no.difi.meldingsutveksling.noarkexchange.p360.schema

use of no.difi.meldingsutveksling.noarkexchange.p360.schema in project geotoolkit by Geomatys.

the class JAXBFeatureTypeWriter method write.

/**
 * Write an XML representation of the specified featureType into the Writer.
 *
 * @param feature The featureType to marshall.
 */
public void write(FeatureType feature, Writer writer) throws JAXBException {
    final Schema schema = getSchemaFromFeatureType(feature);
    final Marshaller marshaller = POOL.acquireMarshaller();
    marshaller.marshal(schema, writer);
    POOL.recycle(marshaller);
}
Also used : Marshaller(javax.xml.bind.Marshaller) Schema(org.geotoolkit.xsd.xml.v2001.Schema)

Aggregations

Test (org.junit.Test)57 Schema (com.google.pubsub.v1.Schema)38 Schema (org.molgenis.emx2.Schema)38 AbstractMessage (com.google.protobuf.AbstractMessage)16 ByteString (com.google.protobuf.ByteString)16 QName (javax.xml.namespace.QName)16 File (java.io.File)15 Schema (org.geosdi.geoplatform.xml.xsd.v2001.Schema)15 SchemaServiceClient (com.google.cloud.pubsub.v1.SchemaServiceClient)14 ProjectName (com.google.pubsub.v1.ProjectName)14 StringWriter (java.io.StringWriter)14 URL (java.net.URL)14 LayerSchemaDTO (org.geosdi.geoplatform.connector.wfs.response.LayerSchemaDTO)14 IOException (java.io.IOException)13 Schema (org.oasisopen.odata.csdl.v4.Schema)13 Schema (com.reprezen.kaizen.oasparser.model3.Schema)11 JAXBElement (javax.xml.bind.JAXBElement)10 ArrayList (java.util.ArrayList)9 HashMap (java.util.HashMap)9 List (java.util.List)8