Search in sources :

Example 1 with Api

use of org.raml.v2.api.model.v10.api.Api in project raml-for-jax-rs by mulesoft-labs.

the class AnnotationsTest method getDefaultExtensionClass.

@Test
public void getDefaultExtensionClass() throws Exception {
    Api api = buildApi(this, "annotations.raml");
    when(currentBuild.createExtensions("org.raml.jaxrs.generator.builders.extensions.resources.TrialResourceClassExtension")).thenReturn(Collections.<Object>singletonList(new TrialResourceClassExtension()));
/*
     * assertTrue(((AbstractCompositeExtension) Annotations.ON_RESOURCE_CLASS_CREATION.getWithContext(currentBuild, api, api
     * .resources() .get(1))) .getElements().get(0) instanceof TrialResourceClassExtension);
     */
}
Also used : TrialResourceClassExtension(org.raml.jaxrs.generator.builders.extensions.resources.TrialResourceClassExtension) Api(org.raml.v2.api.model.v10.api.Api) Test(org.junit.Test)

Example 2 with Api

use of org.raml.v2.api.model.v10.api.Api in project raml-for-jax-rs by mulesoft-labs.

the class AnnotationsTest method getExtensionClass.

@Test
public void getExtensionClass() throws Exception {
    Api type = buildApi(this, "annotations.raml");
    when(currentBuild.createExtensions("org.raml.jaxrs.generator.builders.extensions.resources.TrialResourceClassExtension")).thenReturn(Collections.<Object>singletonList(new TrialResourceClassExtension()));
    when(currentBuild.createExtensions("org.raml.jaxrs.generator.builders.extensions.resources.TrialResourceMethodExtension")).thenReturn(Collections.<Object>singletonList(new TrialResourceMethodExtension()));
    when(currentBuild.createExtensions("org.raml.jaxrs.generator.builders.extensions.resources.TrialResponseClassExtension")).thenReturn(Collections.<Object>singletonList(new TrialResponseClassExtension()));
    when(currentBuild.createExtensions("org.raml.jaxrs.generator.builders.extensions.resources.TrialResponseMethodExtension")).thenReturn(Collections.<Object>singletonList(new TrialResponseMethodExtension()));
/*
     * assertTrue(((AbstractCompositeExtension) Annotations.ON_RESOURCE_CLASS_CREATION.getWithContext(currentBuild,
     * type.resources() .get(0))).getElements().get(0) instanceof TrialResourceClassExtension);
     * assertTrue(((AbstractCompositeExtension) Annotations.ON_METHOD_CREATION.getWithContext(currentBuild,
     * type.resources().get(0) .methods().get(0))).getElements().get(0) instanceof TrialResourceMethodExtension);
     * assertTrue(((AbstractCompositeExtension) Annotations.ON_RESPONSE_CLASS_CREATION.getWithContext(currentBuild,
     * type.resources() .get(0).methods().get(0))).getElements().get(0) instanceof TrialResponseClassExtension);
     * assertTrue(((AbstractCompositeExtension) Annotations.ON_RESPONSE_METHOD_CREATION.getWithContext(currentBuild,
     * type.resources().get(0) .methods() .get(0) .responses().get(0)))
     * 
     * .getElements().get(0) instanceof TrialResponseMethodExtension);
     */
}
Also used : TrialResourceClassExtension(org.raml.jaxrs.generator.builders.extensions.resources.TrialResourceClassExtension) TrialResponseMethodExtension(org.raml.jaxrs.generator.builders.extensions.resources.TrialResponseMethodExtension) Api(org.raml.v2.api.model.v10.api.Api) TrialResponseClassExtension(org.raml.jaxrs.generator.builders.extensions.resources.TrialResponseClassExtension) TrialResourceMethodExtension(org.raml.jaxrs.generator.builders.extensions.resources.TrialResourceMethodExtension) Test(org.junit.Test)

Example 3 with Api

use of org.raml.v2.api.model.v10.api.Api in project raml-for-jax-rs by mulesoft-labs.

the class V10GResourceTest method simpleRequest.

@Test
public void simpleRequest() throws Exception {
    Api api = RamlV10.buildApiV10(this, "resource-simple.raml");
    GAbstractionFactory fac = new GAbstractionFactory();
    V10GResource gr = new V10GResource(new CurrentBuild(api, null), fac, api.resources().get(0));
    GRequest req = gr.methods().get(0).body().get(0);
    assertEquals("application/json", req.mediaType());
    assertEquals("ObjectBase", req.type().type());
    assertEquals("ObjectBase", req.type().name());
}
Also used : GRequest(org.raml.jaxrs.generator.ramltypes.GRequest) CurrentBuild(org.raml.jaxrs.generator.CurrentBuild) GAbstractionFactory(org.raml.jaxrs.generator.GAbstractionFactory) Api(org.raml.v2.api.model.v10.api.Api) Test(org.junit.Test)

Example 4 with Api

use of org.raml.v2.api.model.v10.api.Api in project raml-for-jax-rs by mulesoft-labs.

the class V10GResourceTest method extendingRequest.

@Test
public void extendingRequest() throws Exception {
    Api api = RamlV10.buildApiV10(this, "resource-extending-request.raml");
    GAbstractionFactory fac = new GAbstractionFactory();
    V10GResource gr = new V10GResource(new CurrentBuild(api, null), fac, api.resources().get(0));
    GRequest req = gr.methods().get(0).body().get(0);
    assertEquals("application/json", req.mediaType());
    assertEquals("ObjectBase", req.type().type());
    assertEquals("FunPutApplicationJson", req.type().name());
    assertEquals("model.FunPutApplicationJson", req.type().defaultJavaTypeName("").toString());
}
Also used : GRequest(org.raml.jaxrs.generator.ramltypes.GRequest) CurrentBuild(org.raml.jaxrs.generator.CurrentBuild) GAbstractionFactory(org.raml.jaxrs.generator.GAbstractionFactory) Api(org.raml.v2.api.model.v10.api.Api) Test(org.junit.Test)

Example 5 with Api

use of org.raml.v2.api.model.v10.api.Api in project raml-for-jax-rs by mulesoft-labs.

the class RamlV10 method buildResourceV10.

public static void buildResourceV10(Object test, String raml, CodeContainer<TypeSpec> container, String name, String uri) throws IOException {
    Api api = buildApiV10(test, raml);
    CurrentBuild currentBuild = new CurrentBuild(api, ExtensionManager.createExtensionManager());
    currentBuild.constructClasses(new V10Finder(null, api));
    ResourceBuilder builder = new ResourceBuilder(currentBuild, new V10GResource(currentBuild, new GAbstractionFactory(), api.resources().get(0)), name, uri);
    builder.output(container);
}
Also used : ResourceBuilder(org.raml.jaxrs.generator.builders.resources.ResourceBuilder) CurrentBuild(org.raml.jaxrs.generator.CurrentBuild) GAbstractionFactory(org.raml.jaxrs.generator.GAbstractionFactory) V10GResource(org.raml.jaxrs.generator.v10.V10GResource) Api(org.raml.v2.api.model.v10.api.Api) V10Finder(org.raml.jaxrs.generator.v10.V10Finder)

Aggregations

Api (org.raml.v2.api.model.v10.api.Api)9 Test (org.junit.Test)7 CurrentBuild (org.raml.jaxrs.generator.CurrentBuild)6 GAbstractionFactory (org.raml.jaxrs.generator.GAbstractionFactory)6 TrialResourceClassExtension (org.raml.jaxrs.generator.builders.extensions.resources.TrialResourceClassExtension)2 ResourceBuilder (org.raml.jaxrs.generator.builders.resources.ResourceBuilder)2 GRequest (org.raml.jaxrs.generator.ramltypes.GRequest)2 GResponseType (org.raml.jaxrs.generator.ramltypes.GResponseType)2 V10Finder (org.raml.jaxrs.generator.v10.V10Finder)2 Api (api.Api)1 File (java.io.File)1 IOException (java.io.IOException)1 ParameterEmitter (org.raml.jaxrs.emitters.ParameterEmitter)1 TrialResourceMethodExtension (org.raml.jaxrs.generator.builders.extensions.resources.TrialResourceMethodExtension)1 TrialResponseClassExtension (org.raml.jaxrs.generator.builders.extensions.resources.TrialResponseClassExtension)1 TrialResponseMethodExtension (org.raml.jaxrs.generator.builders.extensions.resources.TrialResponseMethodExtension)1 V08Finder (org.raml.jaxrs.generator.v08.V08Finder)1 V08GResource (org.raml.jaxrs.generator.v08.V08GResource)1 V08TypeRegistry (org.raml.jaxrs.generator.v08.V08TypeRegistry)1 ResourceHandler (org.raml.jaxrs.generator.v10.ResourceHandler)1