Search in sources :

Example 6 with DefaultTestRockerModelProvider

use of io.micronaut.starter.options.DefaultTestRockerModelProvider in project micronaut-starter by micronaut-projects.

the class CreateTestCommand method call.

@Override
public Integer call() throws Exception {
    Project project = getProject(testName);
    TemplateRenderer templateRenderer = getTemplateRenderer(project);
    final String path = "/{packagePath}/{className}";
    TestRockerModelProvider provider = new DefaultTestRockerModelProvider(spock.template(project), javaJunit.template(project), groovyJunit.template(project), kotlinJunit.template(project), koTest.template(project));
    RockerModel rockerModel = provider.findModel(config.getSourceLanguage(), config.getTestFramework());
    String testPath = config.getTestFramework().getSourcePath(path, config.getSourceLanguage());
    RockerTemplate rockerTemplate = new RockerTemplate(testPath, rockerModel);
    RenderResult renderResult = templateRenderer.render(rockerTemplate);
    if (renderResult != null) {
        if (renderResult.isSuccess()) {
            out("@|blue ||@ Rendered test to " + renderResult.getPath());
        } else if (renderResult.isSkipped()) {
            warning("Rendering skipped for " + renderResult.getPath() + " because it already exists. Run again with -f to overwrite.");
        } else if (renderResult.getError() != null) {
            throw renderResult.getError();
        }
    }
    return 0;
}
Also used : RockerTemplate(io.micronaut.starter.template.RockerTemplate) Project(io.micronaut.starter.application.Project) TestRockerModelProvider(io.micronaut.starter.options.TestRockerModelProvider) DefaultTestRockerModelProvider(io.micronaut.starter.options.DefaultTestRockerModelProvider) TemplateRenderer(io.micronaut.starter.template.TemplateRenderer) DefaultTestRockerModelProvider(io.micronaut.starter.options.DefaultTestRockerModelProvider) RenderResult(io.micronaut.starter.template.RenderResult) RockerModel(com.fizzed.rocker.RockerModel)

Example 7 with DefaultTestRockerModelProvider

use of io.micronaut.starter.options.DefaultTestRockerModelProvider in project micronaut-starter by micronaut-projects.

the class CreateControllerCommand method call.

@Override
public Integer call() throws Exception {
    Project project = getProject(controllerName);
    TemplateRenderer templateRenderer = getTemplateRenderer(project);
    RenderResult renderResult = null;
    if (config.getSourceLanguage() == Language.JAVA) {
        renderResult = templateRenderer.render(new RockerTemplate(Language.JAVA.getSrcDir() + "/{packagePath}/{className}Controller." + Language.JAVA.getExtension(), javaController.template(project)), overwrite);
    } else if (config.getSourceLanguage() == Language.GROOVY) {
        renderResult = templateRenderer.render(new RockerTemplate(Language.GROOVY.getSrcDir() + "/{packagePath}/{className}Controller." + Language.GROOVY.getExtension(), groovyController.template(project)), overwrite);
    } else if (config.getSourceLanguage() == Language.KOTLIN) {
        renderResult = templateRenderer.render(new RockerTemplate(Language.KOTLIN.getSrcDir() + "/{packagePath}/{className}Controller." + Language.KOTLIN.getExtension(), kotlinController.template(project)), overwrite);
    }
    if (renderResult != null) {
        if (renderResult.isSuccess()) {
            out("@|blue ||@ Rendered controller to " + renderResult.getPath());
        } else if (renderResult.isSkipped()) {
            warning("Rendering skipped for " + renderResult.getPath() + " because it already exists. Run again with -f to overwrite.");
        } else if (renderResult.getError() != null) {
            throw renderResult.getError();
        }
    }
    renderResult = null;
    String path = "/{packagePath}/{className}Controller";
    path = config.getTestFramework().getSourcePath(path, config.getSourceLanguage());
    TestRockerModelProvider provider = new DefaultTestRockerModelProvider(spock.template(project), javaJunit.template(project), groovyJunit.template(project), kotlinJunit.template(project), koTest.template(project));
    RockerModel rockerModel = provider.findModel(config.getSourceLanguage(), config.getTestFramework());
    renderResult = templateRenderer.render(new RockerTemplate(path, rockerModel), overwrite);
    if (renderResult != null) {
        if (renderResult.isSuccess()) {
            out("@|blue ||@ Rendered test to " + renderResult.getPath());
        } else if (renderResult.isSkipped()) {
            warning("Rendering skipped for " + renderResult.getPath() + " because it already exists. Run again with -f to overwrite.");
        } else if (renderResult.getError() != null) {
            throw renderResult.getError();
        }
    }
    return 0;
}
Also used : RockerTemplate(io.micronaut.starter.template.RockerTemplate) Project(io.micronaut.starter.application.Project) TestRockerModelProvider(io.micronaut.starter.options.TestRockerModelProvider) DefaultTestRockerModelProvider(io.micronaut.starter.options.DefaultTestRockerModelProvider) TemplateRenderer(io.micronaut.starter.template.TemplateRenderer) RenderResult(io.micronaut.starter.template.RenderResult) DefaultTestRockerModelProvider(io.micronaut.starter.options.DefaultTestRockerModelProvider) RockerModel(com.fizzed.rocker.RockerModel)

Example 8 with DefaultTestRockerModelProvider

use of io.micronaut.starter.options.DefaultTestRockerModelProvider in project micronaut-starter by micronaut-projects.

the class AwsAlexa method stopIntentHandlerTest.

private void stopIntentHandlerTest(GeneratorContext generatorContext, Project project) {
    String stopIntentHandlerTest = generatorContext.getTestSourcePath("/{packagePath}/StopIntentHandler");
    TestRockerModelProvider provider = new DefaultTestRockerModelProvider(stopIntentHandlerGroovySpock.template(project), stopIntentHandlerJavaJunit.template(project), stopIntentHandlerGroovyJunit.template(project), stopIntentHandlerKotlinJunit.template(project), stopIntentHandlerKoTest.template(project));
    generatorContext.addTemplate("testStopIntentHandler", stopIntentHandlerTest, provider);
}
Also used : TestRockerModelProvider(io.micronaut.starter.options.TestRockerModelProvider) DefaultTestRockerModelProvider(io.micronaut.starter.options.DefaultTestRockerModelProvider) DefaultTestRockerModelProvider(io.micronaut.starter.options.DefaultTestRockerModelProvider)

Example 9 with DefaultTestRockerModelProvider

use of io.micronaut.starter.options.DefaultTestRockerModelProvider in project micronaut-starter by micronaut-projects.

the class AwsAlexa method launchRequestIntentHandlerTest.

private void launchRequestIntentHandlerTest(GeneratorContext generatorContext, Project project) {
    String launchRequestIntentHandlerTest = generatorContext.getTestSourcePath("/{packagePath}/LaunchRequestIntentHandler");
    TestRockerModelProvider provider = new DefaultTestRockerModelProvider(launchRequestIntentHandlerGroovySpock.template(project), launchRequestIntentHandlerJavaJunit.template(project), launchRequestIntentHandlerGroovyJunit.template(project), launchRequestIntentHandlerKotlinJunit.template(project), launchRequestIntentHandlerKoTest.template(project));
    generatorContext.addTemplate("testLaunchRequestIntentHandler", launchRequestIntentHandlerTest, provider);
}
Also used : TestRockerModelProvider(io.micronaut.starter.options.TestRockerModelProvider) DefaultTestRockerModelProvider(io.micronaut.starter.options.DefaultTestRockerModelProvider) DefaultTestRockerModelProvider(io.micronaut.starter.options.DefaultTestRockerModelProvider)

Example 10 with DefaultTestRockerModelProvider

use of io.micronaut.starter.options.DefaultTestRockerModelProvider in project micronaut-starter by micronaut-projects.

the class AwsAlexa method sessionEndedIntentHandlerTest.

private void sessionEndedIntentHandlerTest(GeneratorContext generatorContext, Project project) {
    String sessionEndedIntentHandlerTest = generatorContext.getTestSourcePath("/{packagePath}/SessionEndedRequestIntentHandler");
    TestRockerModelProvider provider = new DefaultTestRockerModelProvider(sessionEndedRequestIntentHandlerGroovySpock.template(project), sessionEndedRequestIntentHandlerJavaJunit.template(project), sessionEndedRequestIntentHandlerGroovyJunit.template(project), sessionEndedRequestIntentHandlerKotlinJunit.template(project), sessionEndedRequestIntentHandlerKoTest.template(project));
    generatorContext.addTemplate("testSessionEndedRequestIntentHandler", sessionEndedIntentHandlerTest, provider);
}
Also used : TestRockerModelProvider(io.micronaut.starter.options.TestRockerModelProvider) DefaultTestRockerModelProvider(io.micronaut.starter.options.DefaultTestRockerModelProvider) DefaultTestRockerModelProvider(io.micronaut.starter.options.DefaultTestRockerModelProvider)

Aggregations

DefaultTestRockerModelProvider (io.micronaut.starter.options.DefaultTestRockerModelProvider)15 TestRockerModelProvider (io.micronaut.starter.options.TestRockerModelProvider)15 Project (io.micronaut.starter.application.Project)6 RockerTemplate (io.micronaut.starter.template.RockerTemplate)5 TestFramework (io.micronaut.starter.options.TestFramework)3 RockerModel (com.fizzed.rocker.RockerModel)2 RenderResult (io.micronaut.starter.template.RenderResult)2 TemplateRenderer (io.micronaut.starter.template.TemplateRenderer)2