use of com.spectralogic.ds3autogen.api.models.apispec.Ds3Type in project ds3_autogen by SpectraLogic.
the class EnumHelper_Test method testGetEnumValues.
@Test
public void testGetEnumValues() {
final Ds3EnumConstant alpha = new Ds3EnumConstant("Alpha", null);
final Ds3EnumConstant bravo = new Ds3EnumConstant("Bravo", null);
final ImmutableList<Ds3EnumConstant> enumConstants = ImmutableList.of(alpha, bravo);
final Ds3Type testDs3Type = new Ds3Type("Type", null, null, enumConstants);
final ImmutableList<String> stringsList = EnumHelper.convertDs3EnumConstants(testDs3Type);
final String expectedResult = " DS3_TYPE_ALPHA,\n" + " DS3_TYPE_BRAVO";
final String result = EnumHelper.getEnumValues(stringsList);
assertThat(result, is(expectedResult));
}
use of com.spectralogic.ds3autogen.api.models.apispec.Ds3Type in project ds3_autogen by SpectraLogic.
the class EnumHelper_Test method testDoesNotRequireMatcher.
@Test
public void testDoesNotRequireMatcher() {
final Ds3EnumConstant alpha = new Ds3EnumConstant("Alpha", null);
final Ds3EnumConstant bravo = new Ds3EnumConstant("Bravo", null);
final ImmutableList<Ds3EnumConstant> enumConstants = ImmutableList.of(alpha, bravo);
final Ds3Type testDs3Type = new Ds3Type("com.spectralogic.util.db.lang.SqlOperation", null, null, enumConstants);
final Enum testEnum = EnumConverter.toEnum(testDs3Type);
assertFalse(testEnum.requiresMatcher());
}
use of com.spectralogic.ds3autogen.api.models.apispec.Ds3Type in project ds3_autogen by SpectraLogic.
the class EnumHelper_Test method testConvertDs3EnumConstants.
@Test
public void testConvertDs3EnumConstants() {
final Ds3EnumConstant alpha = new Ds3EnumConstant("Alpha", null);
final Ds3EnumConstant bravo = new Ds3EnumConstant("Bravo", null);
final ImmutableList<Ds3EnumConstant> enumConstants = ImmutableList.of(alpha, bravo);
final Ds3Type testDs3Type = new Ds3Type("Type", null, null, enumConstants);
final ImmutableList<String> stringsList = EnumHelper.convertDs3EnumConstants(testDs3Type);
assertFalse(stringsList.isEmpty());
assertEquals(2, stringsList.size());
assertEquals("DS3_TYPE_ALPHA", stringsList.get(0));
assertEquals("DS3_TYPE_BRAVO", stringsList.get(1));
}
use of com.spectralogic.ds3autogen.api.models.apispec.Ds3Type in project ds3_autogen by SpectraLogic.
the class NetCodeGenerator method generateResponseAndParser.
/**
* Generates the .net code for the response handler and parser described in the Ds3Request
*/
private void generateResponseAndParser(final Ds3Request ds3Request) throws IOException, TemplateException {
if (!ResponsePayloadUtil.hasResponsePayload(ds3Request.getDs3ResponseCodes())) {
//Check if the request is an exception for generating response and parser files
if (hasResponseHandlerAndParser(ds3Request)) {
generateResponse(ds3Request, null);
generateResponseParser(ds3Request, null);
}
//There is no payload for this Ds3Request, so do not generate any response handling code
return;
}
final String responsePayloadType = getResponsePayloadType(ds3Request.getDs3ResponseCodes());
if ((isEmpty(responsePayloadType) || !responsePayloadType.equalsIgnoreCase("java.lang.String")) && isEmpty(spec.getTypes())) {
LOG.error("Cannot generate response because type map is empty");
return;
}
if (responsePayloadType == null) {
throw new IllegalArgumentException("Cannot generate a response because there are no non-error payloads: " + ds3Request.getName());
}
generateResponse(ds3Request, responsePayloadType);
if (responsePayloadType.equalsIgnoreCase("java.lang.String")) {
generateResponseParser(ds3Request, null);
} else {
final Ds3Type ds3TypePayload = spec.getTypes().get(responsePayloadType);
generateResponseParser(ds3Request, ds3TypePayload);
}
}
use of com.spectralogic.ds3autogen.api.models.apispec.Ds3Type in project ds3_autogen by SpectraLogic.
the class ChecksumTypeGenerator_Test method getAllImports_Test.
@Test
public void getAllImports_Test() {
final ImmutableList<Ds3Element> ds3Elements = ImmutableList.of(new Ds3Element("ElementName1", "com.spectralogic.test.ElementType1", "ElementComponentType1", false), new Ds3Element("ElementName2", "ElementType2", "com.spectralogic.test.ElementComponentType2", false), new Ds3Element("ElementName3", "ElementType3", null, false));
final Ds3Type ds3Type = new Ds3Type("TypeName", null, ds3Elements, null);
final ImmutableList<String> result = generator.getAllImports(ds3Type);
assertThat(result.size(), is(0));
}
Aggregations