This commit is contained in:
Andy Wilkinson 2019-02-19 10:03:40 +00:00
parent fad1d14bf0
commit a049d6e4fc
5 changed files with 16 additions and 14 deletions

View File

@ -98,8 +98,10 @@ class SourceCodeProjectGenerationConfigurationTests {
this.projectTester.generate(description, (context) -> {
ServletInitializerContributor bean = context
.getBean(ServletInitializerContributor.class);
SourceCode sourceCode = mock(SourceCode.class);
CompilationUnit compilationUnit = mock(CompilationUnit.class);
SourceCode<TypeDeclaration, CompilationUnit<TypeDeclaration>> sourceCode = mock(
SourceCode.class);
CompilationUnit<TypeDeclaration> compilationUnit = mock(
CompilationUnit.class);
given(sourceCode.createCompilationUnit(any(), any()))
.willReturn(compilationUnit);
TypeDeclaration typeDeclaration = mock(TypeDeclaration.class);

View File

@ -16,6 +16,7 @@
package io.spring.initializr.generator.io;
import java.io.IOException;
import java.io.StringWriter;
import org.junit.jupiter.api.Test;
@ -74,17 +75,18 @@ class IndentingWriterTests {
}
@Test
void customIndentStrategyIsUsed() {
IndentingWriter customIndentingWriter = new IndentingWriter(this.stringWriter,
new SimpleIndentStrategy("\t"));
customIndentingWriter.println("a");
customIndentingWriter.indented(() -> {
customIndentingWriter.println("b");
void customIndentStrategyIsUsed() throws IOException {
try (IndentingWriter customIndentingWriter = new IndentingWriter(
this.stringWriter, new SimpleIndentStrategy("\t"))) {
customIndentingWriter.println("a");
customIndentingWriter.indented(() -> {
customIndentingWriter.print("c");
customIndentingWriter.println("e");
customIndentingWriter.println("b");
customIndentingWriter.indented(() -> {
customIndentingWriter.print("c");
customIndentingWriter.println("e");
});
});
});
}
assertThat(this.stringWriter.toString()).isEqualTo("a\n\tb\n\t\tce\n");
}

View File

@ -34,6 +34,7 @@ import io.spring.initializr.generator.project.ProjectGenerationException;
/**
* Base tester for project generation.
*
* @param <SELF> concrete type of the tester
* @author Stephane Nicoll
*/
public abstract class AbstractProjectGenerationTester<SELF extends AbstractProjectGenerationTester<SELF>> {

View File

@ -196,7 +196,6 @@ class InitializrMetadataBuilderTests {
InitializrMetadata metadata = InitializrMetadataBuilder
.fromInitializrProperties(config)
.withInitializrProperties(forceSslConfig, true).build();
InitializrConfiguration.Env defaultEnv = new InitializrConfiguration().getEnv();
InitializrConfiguration.Env actualEnv = metadata.getConfiguration().getEnv();
assertThat(actualEnv.isForceSsl()).isEqualTo(true);
}

View File

@ -25,7 +25,6 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import io.spring.initializr.generator.buildsystem.Build;
import io.spring.initializr.generator.buildsystem.BuildItemResolver;
import io.spring.initializr.generator.project.DefaultProjectAssetGenerator;
import io.spring.initializr.generator.project.ProjectAssetGenerator;
@ -201,7 +200,6 @@ public class ProjectGenerationInvoker {
private void publishProjectGeneratedEvent(ProjectRequest request,
ProjectGenerationContext context) {
Build build = context.getBeanProvider(Build.class).getIfAvailable();
InitializrMetadata metadata = context.getBean(InitializrMetadata.class);
ProjectGeneratedEvent event = new ProjectGeneratedEvent(request, metadata);
this.eventPublisher.publishEvent(event);