use of com.spectralogic.ds3autogen.api.models.apispec.Ds3Request in project ds3_autogen by SpectraLogic.
the class RequestGeneratorUtil_Test method getGoArgFromResource_Test.
@Test
public void getGoArgFromResource_Test() {
final ImmutableList<Arguments> expectedArgs = ImmutableList.of(new Arguments("String", "notificationId"), new Arguments("String", "bucketId"), new Arguments("UUID", "jobId"), new Arguments("String", "activeJob"));
final ImmutableList<Ds3Request> requests = ImmutableList.of(createTestRequest(Resource.DS3_TARGET_FAILURE_NOTIFICATION_REGISTRATION, true), createTestRequest(Resource.BUCKET, true), createTestRequest(Resource.JOB, true), createTestRequest(Resource.ACTIVE_JOB, true));
assertThat(requests.size(), is(expectedArgs.size()));
for (int i = 0; i > requests.size(); i++) {
final Arguments result = getGoArgFromResource(requests.get(i));
assertThat(result.getName(), is(expectedArgs.get(i).getName()));
assertThat(result.getType(), is(expectedArgs.get(i).getType()));
}
}
use of com.spectralogic.ds3autogen.api.models.apispec.Ds3Request in project ds3_autogen by SpectraLogic.
the class BaseClientGenerator_Test method toCommandList_HttpRedirectTrue_Test.
@Test
public void toCommandList_HttpRedirectTrue_Test() {
final ImmutableList<Command> expected = ImmutableList.of(new Command("GetBucketsHandler"), new Command("GetObjectsHandler"));
final ImmutableList<Ds3Request> requests = ImmutableList.of(getBucketsRequest(), deleteBucketRequest(), getObjectsDetailsRequest(), getRequestBulkGet());
final ImmutableList<Command> result = generator.toCommandList(requests, true);
assertThat(result.size(), is(expected.size()));
expected.forEach(cmd -> assertThat(result, hasItem(cmd)));
}
use of com.spectralogic.ds3autogen.api.models.apispec.Ds3Request in project ds3_autogen by SpectraLogic.
the class BaseRequestGenerator_Test method toImportSet_NoStrconv_Test.
@Test
public void toImportSet_NoStrconv_Test() {
final Ds3Request ds3Request = createDs3RequestTestData(false, PARAMS_NOT_REQURING_STRCONV, PARAMS_NOT_REQURING_STRCONV);
final ImmutableSet<String> result = generator.toImportSet(ds3Request);
assertThat(result.size(), is(0));
}
use of com.spectralogic.ds3autogen.api.models.apispec.Ds3Request in project ds3_autogen by SpectraLogic.
the class BaseRequestGenerator_Test method toImportSet_WithStrconv_Test.
@Test
public void toImportSet_WithStrconv_Test() {
final ImmutableSet<String> expectedImports = ImmutableSet.of("strconv");
final Ds3Request ds3Request = createDs3RequestTestData(false, PARAMS_NOT_REQURING_STRCONV, PARAMS_REQUIRING_STRCONV);
final ImmutableSet<String> result = generator.toImportSet(ds3Request);
assertThat(result.size(), is(expectedImports.size()));
expectedImports.forEach(expected -> assertThat(result, hasItem(expected)));
}
use of com.spectralogic.ds3autogen.api.models.apispec.Ds3Request in project ds3_autogen by SpectraLogic.
the class JavaCodeGenerator method generateRequest.
/**
* Generates the code for the Request handler described in a Ds3Request
* @param ds3Request A Ds3Request
* @throws IOException
* @throws TemplateException
*/
private void generateRequest(final Ds3Request ds3Request, final Ds3DocSpec docSpec) throws IOException, TemplateException {
final Template tmpl = getRequestTemplate(ds3Request);
final Request request = toRequest(ds3Request, docSpec);
final Path requestPath = getPathFromPackage(ds3Request, request.getName());
LOG.info("Getting outputstream for file: {}", requestPath.toString());
try (final OutputStream outStream = fileUtils.getOutputFile(requestPath);
final Writer writer = new OutputStreamWriter(outStream)) {
tmpl.process(request, writer);
}
}
Aggregations