Search in sources :

Example 21 with Ds3DocSpecEmptyImpl

use of com.spectralogic.ds3autogen.docspec.Ds3DocSpecEmptyImpl in project ds3_autogen by SpectraLogic.

the class CreateNotificationRequestGenerator_Test method toConstructorList_Test.

@Test
public void toConstructorList_Test() {
    final ImmutableList.Builder<Ds3Param> builder = ImmutableList.builder();
    builder.addAll(createTestDs3ParamList());
    builder.add(new Ds3Param("NotificationEndPoint", "String", false));
    final Ds3Request request = createDs3RequestTestData(true, null, builder.build());
    final ImmutableList<RequestConstructor> result = generator.toConstructorList(request, "", new Ds3DocSpecEmptyImpl());
    assertThat(result.size(), is(1));
    final RequestConstructor constructor = result.get(0);
    assertThat(constructor.getAdditionalLines().size(), is(0));
    assertThat(constructor.isDeprecated(), is(false));
    final ImmutableList<Arguments> constructorParams = constructor.getParameters();
    assertThat(constructorParams.size(), is(4));
    assertThat(constructorParams.get(0).getName(), is("MaxUploadSize"));
    assertThat(constructorParams.get(1).getName(), is("Name"));
    assertThat(constructorParams.get(2).getName(), is("Priority"));
    assertThat(constructorParams.get(3).getName(), is("NotificationEndPoint"));
    final ImmutableList<Arguments> constructorAssignments = constructor.getAssignments();
    assertThat(constructorAssignments.size(), is(3));
    assertThat(constructorAssignments.get(0).getName(), is("MaxUploadSize"));
    assertThat(constructorAssignments.get(1).getName(), is("Name"));
    assertThat(constructorAssignments.get(2).getName(), is("Priority"));
    final ImmutableList<QueryParam> queryParams = constructor.getQueryParams();
    assertThat(queryParams.size(), is(4));
    assertThat(queryParams.get(0).getName(), is("IgnoreNamingConflicts"));
    assertThat(queryParams.get(1).getName(), is("MaxUploadSize"));
    assertThat(queryParams.get(2).getName(), is("Name"));
    assertThat(queryParams.get(3).getName(), is("Priority"));
}
Also used : Ds3Param(com.spectralogic.ds3autogen.api.models.apispec.Ds3Param) QueryParam(com.spectralogic.ds3autogen.java.models.QueryParam) ImmutableList(com.google.common.collect.ImmutableList) RequestGeneratorTestHelper.createSimpleTestDs3Request(com.spectralogic.ds3autogen.java.test.helpers.RequestGeneratorTestHelper.createSimpleTestDs3Request) Ds3Request(com.spectralogic.ds3autogen.api.models.apispec.Ds3Request) Arguments(com.spectralogic.ds3autogen.api.models.Arguments) Ds3DocSpecEmptyImpl(com.spectralogic.ds3autogen.docspec.Ds3DocSpecEmptyImpl) RequestConstructor(com.spectralogic.ds3autogen.java.models.RequestConstructor) Test(org.junit.Test)

Example 22 with Ds3DocSpecEmptyImpl

use of com.spectralogic.ds3autogen.docspec.Ds3DocSpecEmptyImpl in project ds3_autogen by SpectraLogic.

the class BaseRequestGenerator_Test method toWithConstructor_Test.

@Test
public void toWithConstructor_Test() {
    final String expectedResult = "    public RequestName withArgName(final ArgType argName) {\n" + "        this.argName = argName;\n" + "        this.updateQueryParam(\"arg_name\", argName);\n" + "        return this;\n" + "    }\n";
    final Arguments argument = new Arguments("ArgType", "ArgName");
    final String result = generator.toWithConstructor(argument, "RequestName", new Ds3DocSpecEmptyImpl());
    assertThat(result, is(expectedResult));
}
Also used : Arguments(com.spectralogic.ds3autogen.api.models.Arguments) Ds3DocSpecEmptyImpl(com.spectralogic.ds3autogen.docspec.Ds3DocSpecEmptyImpl) Test(org.junit.Test)

Example 23 with Ds3DocSpecEmptyImpl

use of com.spectralogic.ds3autogen.docspec.Ds3DocSpecEmptyImpl in project ds3_autogen by SpectraLogic.

the class PythonCodeGenerator_Test method toClientCommands_EmptyList_Test.

@Test
public void toClientCommands_EmptyList_Test() {
    final ImmutableList<BaseClient> result = toClientCommands(ImmutableList.of(), new Ds3DocSpecEmptyImpl());
    assertThat(result.size(), is(0));
}
Also used : Ds3DocSpecEmptyImpl(com.spectralogic.ds3autogen.docspec.Ds3DocSpecEmptyImpl) BaseClient(com.spectralogic.ds3autogen.python.model.client.BaseClient) Test(org.junit.Test)

Example 24 with Ds3DocSpecEmptyImpl

use of com.spectralogic.ds3autogen.docspec.Ds3DocSpecEmptyImpl in project ds3_autogen by SpectraLogic.

the class PythonCodeGenerator_Test method toRequestModelList_NullList_Test.

@Test
public void toRequestModelList_NullList_Test() {
    final ImmutableList<BaseRequest> result = generator.toRequestModelList(null, new Ds3DocSpecEmptyImpl());
    assertThat(result.size(), is(0));
}
Also used : BaseRequest(com.spectralogic.ds3autogen.python.model.request.BaseRequest) Ds3DocSpecEmptyImpl(com.spectralogic.ds3autogen.docspec.Ds3DocSpecEmptyImpl) Test(org.junit.Test)

Example 25 with Ds3DocSpecEmptyImpl

use of com.spectralogic.ds3autogen.docspec.Ds3DocSpecEmptyImpl in project ds3_autogen by SpectraLogic.

the class CCodeGenerator_Test method testStuctsContainsJobCreationFailedNotificationPayload.

@Test
public void testStuctsContainsJobCreationFailedNotificationPayload() throws IOException, ParseException {
    final Ds3SpecParser parser = new Ds3SpecParserImpl();
    final Ds3ApiSpec spec = parser.getSpec(CCodeGenerator_Test.class.getResourceAsStream("/input/3_2_2_contract.xml"));
    final ImmutableList<Enum> allEnums = CCodeGenerator.getAllEnums(spec);
    final ImmutableSet<String> enumNames = EnumHelper.getEnumNamesSet(allEnums);
    final ImmutableSet<String> arrayMemberTypes = CCodeGenerator.getArrayMemberTypes(spec, enumNames);
    final ImmutableSet<String> embeddedTypes = CCodeGenerator.getEmbeddedTypes(spec, enumNames);
    final ImmutableList<Request> allRequests = CCodeGenerator.getAllRequests(spec, new Ds3DocSpecEmptyImpl());
    final ImmutableSet<String> responseTypes = RequestHelper.getResponseTypes(allRequests);
    final ImmutableSet<String> paginatedTypes = CCodeGenerator.getPaginatedTypes(spec);
    final ImmutableList<Struct> allStructs = CCodeGenerator.getAllStructs(spec, enumNames, responseTypes, embeddedTypes, arrayMemberTypes, paginatedTypes);
    assertTrue(allStructs.stream().map(Struct::getName).anyMatch(name -> name.equals("ds3_job_creation_failed_notification_payload_response")));
}
Also used : Enum(com.spectralogic.ds3autogen.c.models.Enum) CoreMatchers.is(org.hamcrest.CoreMatchers.is) EnumHelper(com.spectralogic.ds3autogen.c.helpers.EnumHelper) StructHelper(com.spectralogic.ds3autogen.c.helpers.StructHelper) com.spectralogic.ds3autogen.c.models(com.spectralogic.ds3autogen.c.models) ByteArrayOutputStream(java.io.ByteArrayOutputStream) TemplateModelException(freemarker.template.TemplateModelException) Ds3SpecParserImpl(com.spectralogic.ds3autogen.Ds3SpecParserImpl) SourceConverter(com.spectralogic.ds3autogen.c.converters.SourceConverter) LoggerFactory(org.slf4j.LoggerFactory) Ds3DocSpecEmptyImpl(com.spectralogic.ds3autogen.docspec.Ds3DocSpecEmptyImpl) Ds3Element(com.spectralogic.ds3autogen.api.models.apispec.Ds3Element) Ds3ModelFixtures(com.spectralogic.ds3autogen.testutil.Ds3ModelFixtures) HashMap(java.util.HashMap) RequestConverter(com.spectralogic.ds3autogen.c.converters.RequestConverter) NameMapper(com.spectralogic.ds3autogen.NameMapper) TestFileUtilsImpl(com.spectralogic.ds3autogen.utils.TestFileUtilsImpl) Ds3SpecParser(com.spectralogic.ds3autogen.api.Ds3SpecParser) RequestHelper(com.spectralogic.ds3autogen.c.helpers.RequestHelper) Matcher(java.util.regex.Matcher) ImmutableList(com.google.common.collect.ImmutableList) Ds3Type(com.spectralogic.ds3autogen.api.models.apispec.Ds3Type) Ds3DocSpec(com.spectralogic.ds3autogen.api.models.docspec.Ds3DocSpec) Map(java.util.Map) Ds3DocSpecParserImpl(com.spectralogic.ds3autogen.docspec.Ds3DocSpecParserImpl) ParseException(java.text.ParseException) Ds3EnumConstant(com.spectralogic.ds3autogen.api.models.apispec.Ds3EnumConstant) ImmutableSet(com.google.common.collect.ImmutableSet) StructConverter(com.spectralogic.ds3autogen.c.converters.StructConverter) Logger(org.slf4j.Logger) ImmutableMap(com.google.common.collect.ImmutableMap) Ds3DocSpecParser(com.spectralogic.ds3autogen.api.Ds3DocSpecParser) Test(org.junit.Test) IOException(java.io.IOException) Ds3ApiSpec(com.spectralogic.ds3autogen.api.models.apispec.Ds3ApiSpec) Enum(com.spectralogic.ds3autogen.c.models.Enum) Optional(java.util.Optional) Pattern(java.util.regex.Pattern) EnumConverter(com.spectralogic.ds3autogen.c.converters.EnumConverter) Ds3DocSpecImpl(com.spectralogic.ds3autogen.docspec.Ds3DocSpecImpl) Assert(org.junit.Assert) Ds3SpecParser(com.spectralogic.ds3autogen.api.Ds3SpecParser) Ds3SpecParserImpl(com.spectralogic.ds3autogen.Ds3SpecParserImpl) Ds3ApiSpec(com.spectralogic.ds3autogen.api.models.apispec.Ds3ApiSpec) Ds3DocSpecEmptyImpl(com.spectralogic.ds3autogen.docspec.Ds3DocSpecEmptyImpl) Test(org.junit.Test)

Aggregations

Ds3DocSpecEmptyImpl (com.spectralogic.ds3autogen.docspec.Ds3DocSpecEmptyImpl)83 Test (org.junit.Test)79 TestFileUtilsImpl (com.spectralogic.ds3autogen.utils.TestFileUtilsImpl)36 ByteArrayOutputStream (java.io.ByteArrayOutputStream)34 Ds3SpecParserImpl (com.spectralogic.ds3autogen.Ds3SpecParserImpl)26 Ds3ApiSpec (com.spectralogic.ds3autogen.api.models.apispec.Ds3ApiSpec)26 Arguments (com.spectralogic.ds3autogen.api.models.Arguments)25 Ds3SpecParser (com.spectralogic.ds3autogen.api.Ds3SpecParser)24 RequestConstructor (com.spectralogic.ds3autogen.java.models.RequestConstructor)18 Request (com.spectralogic.ds3autogen.c.models.Request)16 HashMap (java.util.HashMap)16 QueryParam (com.spectralogic.ds3autogen.java.models.QueryParam)14 Enum (com.spectralogic.ds3autogen.c.models.Enum)13 Ds3Request (com.spectralogic.ds3autogen.api.models.apispec.Ds3Request)10 Source (com.spectralogic.ds3autogen.c.models.Source)9 RequestGeneratorTestHelper.createSimpleTestDs3Request (com.spectralogic.ds3autogen.java.test.helpers.RequestGeneratorTestHelper.createSimpleTestDs3Request)6 Ds3Param (com.spectralogic.ds3autogen.api.models.apispec.Ds3Param)5 Ds3DocSpec (com.spectralogic.ds3autogen.api.models.docspec.Ds3DocSpec)4 CodeGenerator (com.spectralogic.ds3autogen.api.CodeGenerator)3 JavaCodeGenerator (com.spectralogic.ds3autogen.java.JavaCodeGenerator)3