Search in sources :

Example 1 with MappingBuilder

use of uk.gov.justice.services.generators.test.utils.builder.MappingBuilder in project microservice_framework by CJSCommonPlatform.

the class NamesTest method shouldBuildResourceMethodNameFromActionAndMimeType.

@Test
public void shouldBuildResourceMethodNameFromActionAndMimeType() throws Exception {
    final MappingBuilder mappingBuilder = mapping().withName("command.create-user").withRequestType("application/vnd.command.create-user+json");
    final Action action = httpAction().withHttpActionType(POST).withDescription(mappingDescriptionWith(mappingBuilder).build()).build();
    action.setResource(resource().withRelativeUri("test").build());
    final String shortMimeType = Names.resourceMethodNameFrom(action, new MimeType("application/vnd.command.create-user+json"));
    assertThat(shortMimeType, is("postCommandCreateUserTest"));
}
Also used : HttpActionBuilder.httpAction(uk.gov.justice.services.generators.test.utils.builder.HttpActionBuilder.httpAction) Action(org.raml.model.Action) MappingBuilder(uk.gov.justice.services.generators.test.utils.builder.MappingBuilder) MimeType(org.raml.model.MimeType) Test(org.junit.Test)

Example 2 with MappingBuilder

use of uk.gov.justice.services.generators.test.utils.builder.MappingBuilder in project microservice_framework by CJSCommonPlatform.

the class NamesTest method shouldBuildResourceMethodNameFromAction.

@Test
public void shouldBuildResourceMethodNameFromAction() throws Exception {
    final MappingBuilder mappingBuilder = mapping().withName("command.create-user").withRequestType("application/vnd.command.create-user+json");
    final Action action = httpAction().withHttpActionType(GET).withDescription(mappingDescriptionWith(mappingBuilder).build()).build();
    action.setResource(resource().withRelativeUri("test").build());
    final String shortMimeType = Names.resourceMethodNameWithNoMimeTypeFrom(action);
    assertThat(shortMimeType, is("getTest"));
}
Also used : HttpActionBuilder.httpAction(uk.gov.justice.services.generators.test.utils.builder.HttpActionBuilder.httpAction) Action(org.raml.model.Action) MappingBuilder(uk.gov.justice.services.generators.test.utils.builder.MappingBuilder) Test(org.junit.Test)

Example 3 with MappingBuilder

use of uk.gov.justice.services.generators.test.utils.builder.MappingBuilder in project microservice_framework by CJSCommonPlatform.

the class NamesTest method shouldBuildResourceMethodNameFromActionAndNullMimeType.

@Test
public void shouldBuildResourceMethodNameFromActionAndNullMimeType() throws Exception {
    final MappingBuilder mappingBuilder = mapping().withName("command.create-user").withRequestType("application/vnd.command.create-user+json");
    final Action action = httpAction().withHttpActionType(POST).withDescription(mappingDescriptionWith(mappingBuilder).build()).build();
    action.setResource(resource().withRelativeUri("test").build());
    final String shortMimeType = Names.resourceMethodNameFrom(action, null);
    assertThat(shortMimeType, is("postTest"));
}
Also used : HttpActionBuilder.httpAction(uk.gov.justice.services.generators.test.utils.builder.HttpActionBuilder.httpAction) Action(org.raml.model.Action) MappingBuilder(uk.gov.justice.services.generators.test.utils.builder.MappingBuilder) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)3 Action (org.raml.model.Action)3 HttpActionBuilder.httpAction (uk.gov.justice.services.generators.test.utils.builder.HttpActionBuilder.httpAction)3 MappingBuilder (uk.gov.justice.services.generators.test.utils.builder.MappingBuilder)3 MimeType (org.raml.model.MimeType)1