From d28d37dd1f55bbefe799ec1add65dc991f0d9b0f Mon Sep 17 00:00:00 2001 From: Stefan Seifert Date: Wed, 10 Jan 2024 13:16:05 +0100 Subject: [PATCH] eliminate usage of guava collections in unit tests --- .../FileGeneratorFileHeaderTest.java | 22 ++-- .../FileGeneratorPostProcessorTest.java | 93 ++++++++-------- .../generator/FileGeneratorValidatorTest.java | 26 +++-- .../GeneratorTestNodeModelExportTest.java | 24 ++--- .../wcm/devops/conga/generator/TestUtils.java | 13 ++- .../fileheader/ConfFileHeaderTest.java | 4 +- .../fileheader/JsonFileHeaderTest.java | 4 +- .../UnixShellScriptFileHeaderTest.java | 4 +- .../WindowsShellScriptFileHeaderTest.java | 4 +- .../plugins/fileheader/XmlFileHeaderTest.java | 4 +- .../handlebars/helper/ContainsHelperTest.java | 14 +-- .../helper/EachIfEqualsHelperTest.java | 16 +-- .../handlebars/helper/EachIfHelperTest.java | 16 +-- .../handlebars/helper/IfEqualsHelperTest.java | 8 +- .../helper/IfNotEqualsHelperTest.java | 8 +- .../handlebars/helper/MockOptions.java | 4 +- .../plugins/multiply/NoneMultiplyTest.java | 4 +- .../plugins/multiply/TenantMultiplyTest.java | 29 +++-- .../AbstractPostProcessorTest.java | 4 +- .../postprocessor/DummyPostProcessor.java | 4 +- .../DummyMapValueProviderPlugin.java | 10 +- ...SystemPropertyValueProviderPluginTest.java | 6 +- .../util/ConfigInheritanceResolverTest.java | 38 +++---- .../generator/util/JexlResolverTest.java | 8 +- .../util/ModelExportConfigProcessorTest.java | 49 ++++----- .../conga/generator/util/RoleUtilTest.java | 100 +++++++++--------- .../conga/generator/util/ValueUtilTest.java | 22 ++-- .../util/VariableMapResolverTest.java | 90 ++++++++-------- .../util/VariableObjectTreeResolverTest.java | 36 +++---- .../VariableStringResolverExpressionTest.java | 26 +++-- .../util/VariableStringResolverTest.java | 40 ++++--- .../model/reader/EnvironmentReaderTest.java | 32 +++--- .../conga/model/reader/RoleReaderTest.java | 32 +++--- .../conga/model/util/MapExpanderTest.java | 70 ++++++------ .../conga/model/util/MapMergerTest.java | 5 +- .../conga/model/util/MapSplitterTest.java | 77 +++++++------- .../conga/model/util/MergingListTest.java | 16 +-- .../resource/ResourceLoaderClasspathTest.java | 12 +-- .../ResourceLoaderFilesystemTest.java | 12 +-- .../plugin/util/PluginConfigUtilTest.java | 18 ++-- .../MavenPropertyValueProviderPluginTest.java | 6 +- 41 files changed, 478 insertions(+), 532 deletions(-) diff --git a/generator/src/test/java/io/wcm/devops/conga/generator/FileGeneratorFileHeaderTest.java b/generator/src/test/java/io/wcm/devops/conga/generator/FileGeneratorFileHeaderTest.java index d714a8ff..d6a06ad9 100644 --- a/generator/src/test/java/io/wcm/devops/conga/generator/FileGeneratorFileHeaderTest.java +++ b/generator/src/test/java/io/wcm/devops/conga/generator/FileGeneratorFileHeaderTest.java @@ -49,8 +49,6 @@ import org.mockito.stubbing.Answer; import com.github.jknack.handlebars.Template; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; import io.wcm.devops.conga.generator.spi.FileHeaderPlugin; import io.wcm.devops.conga.generator.spi.ImplicitApplyOptions; @@ -91,7 +89,7 @@ void setUp(TestInfo testInfo) { when(pluginManager.getAll(FileHeaderPlugin.class)).thenAnswer(new Answer>() { @Override public List answer(InvocationOnMock invocation) throws Throwable { - return ImmutableList.copyOf(fileHeaderPlugins.values()); + return List.copyOf(fileHeaderPlugins.values()); } }); when(pluginManager.get(anyString(), eq(FileHeaderPlugin.class))).thenAnswer(new Answer() { @@ -111,9 +109,9 @@ public FileHeaderPlugin answer(InvocationOnMock invocation) throws Throwable { VariableMapResolver variableMapResolver = new VariableMapResolver( new ValueProviderGlobalContext().pluginContextOptions(pluginContextOptions)); underTest = new FileGenerator(options, "env1", - "role1", ImmutableList.of("variant1"), "template1", - destDir, file, null, null, roleFile, ImmutableMap.of(), template, - variableMapResolver, urlFileManager, pluginContextOptions, ImmutableList.of( + "role1", List.of("variant1"), "template1", + destDir, file, null, null, roleFile, Map.of(), template, + variableMapResolver, urlFileManager, pluginContextOptions, List.of( "version1/1.0.0", "version2/2.0.0-SNAPSHOT", "version3/1.2.0-SNAPSHOT", @@ -125,7 +123,7 @@ public FileHeaderPlugin answer(InvocationOnMock invocation) throws Throwable { void testWithoutFileHeader() throws Exception { FileHeaderPlugin one = mockFileHeader("one", "txt", ImplicitApplyOptions.NEVER); - List result = ImmutableList.copyOf(underTest.generate()); + List result = List.copyOf(underTest.generate()); assertEquals(1, result.size()); assertItem(result.get(0), "test.txt"); @@ -138,7 +136,7 @@ void testExplicitFileHeader() throws Exception { FileHeaderPlugin one = mockFileHeader("one", "txt", ImplicitApplyOptions.NEVER); roleFile.setFileHeader("one"); - List result = ImmutableList.copyOf(underTest.generate()); + List result = List.copyOf(underTest.generate()); assertEquals(1, result.size()); assertItem(result.get(0), "test.txt"); @@ -150,7 +148,7 @@ void testExplicitFileHeader() throws Exception { void testImplicitFileHeader() throws Exception { FileHeaderPlugin one = mockFileHeader("one", "txt", ImplicitApplyOptions.WHEN_UNCONFIGURED); - List result = ImmutableList.copyOf(underTest.generate()); + List result = List.copyOf(underTest.generate()); assertEquals(1, result.size()); assertItem(result.get(0), "test.txt"); @@ -162,7 +160,7 @@ void testImplicitFileHeader() throws Exception { void testAlwaysFileHeader() throws Exception { FileHeaderPlugin one = mockFileHeader("one", "txt", ImplicitApplyOptions.ALWAYS); - List result = ImmutableList.copyOf(underTest.generate()); + List result = List.copyOf(underTest.generate()); assertEquals(1, result.size()); assertItem(result.get(0), "test.txt"); @@ -175,7 +173,7 @@ void testImplicitAndAlwaysFileHeader() throws Exception { FileHeaderPlugin one = mockFileHeader("one", "txt", ImplicitApplyOptions.WHEN_UNCONFIGURED); FileHeaderPlugin two = mockFileHeader("two", "txt", ImplicitApplyOptions.ALWAYS); - List result = ImmutableList.copyOf(underTest.generate()); + List result = List.copyOf(underTest.generate()); assertEquals(1, result.size()); assertItem(result.get(0), "test.txt"); @@ -189,7 +187,7 @@ void testVersions() throws Exception { FileHeaderPlugin one = mockFileHeader("one", "txt", ImplicitApplyOptions.NEVER); roleFile.setFileHeader("one"); - List result = ImmutableList.copyOf(underTest.generate()); + List result = List.copyOf(underTest.generate()); assertEquals(1, result.size()); assertItem(result.get(0), "test.txt"); diff --git a/generator/src/test/java/io/wcm/devops/conga/generator/FileGeneratorPostProcessorTest.java b/generator/src/test/java/io/wcm/devops/conga/generator/FileGeneratorPostProcessorTest.java index 42a3e502..f2b1c640 100644 --- a/generator/src/test/java/io/wcm/devops/conga/generator/FileGeneratorPostProcessorTest.java +++ b/generator/src/test/java/io/wcm/devops/conga/generator/FileGeneratorPostProcessorTest.java @@ -52,9 +52,6 @@ import org.slf4j.Logger; import com.github.jknack.handlebars.Template; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import io.wcm.devops.conga.generator.spi.FileHeaderPlugin; @@ -105,7 +102,7 @@ void setUp(TestInfo testInfo) { when(pluginManager.getAll(PostProcessorPlugin.class)).thenAnswer(new Answer>() { @Override public List answer(InvocationOnMock invocation) throws Throwable { - return ImmutableList.copyOf(postProcessorPlugins.values()); + return List.copyOf(postProcessorPlugins.values()); } }); when(pluginManager.get(anyString(), eq(PostProcessorPlugin.class))).thenAnswer(new Answer() { @@ -125,19 +122,19 @@ public PostProcessorPlugin answer(InvocationOnMock invocation) throws Throwable variableMapResolver = new VariableMapResolver( new ValueProviderGlobalContext().pluginContextOptions(pluginContextOptions)); underTest = new FileGenerator(options, "env1", - "role1", ImmutableList.of("variant1"), "template1", - destDir, file, null, null, roleFile, ImmutableMap.of(), template, - variableMapResolver, urlFileManager, pluginContextOptions, ImmutableList.of()); + "role1", List.of("variant1"), "template1", + destDir, file, null, null, roleFile, Map.of(), template, + variableMapResolver, urlFileManager, pluginContextOptions, List.of()); } @Test void testWithoutPostProcessor() throws Exception { PostProcessorPlugin one = mockPostProcessor("one", "txt", ImplicitApplyOptions.NEVER); - List result = ImmutableList.copyOf(underTest.generate()); + List result = List.copyOf(underTest.generate()); assertEquals(1, result.size()); - assertItem(result.get(0), "test.txt", ImmutableMap.of(), ImmutableSet.of()); + assertItem(result.get(0), "test.txt", Map.of(), Set.of()); verify(one, never()).apply(any(FileContext.class), any(PostProcessorContext.class)); } @@ -145,12 +142,12 @@ void testWithoutPostProcessor() throws Exception { @Test void testOnePostProcessor() throws Exception { PostProcessorPlugin one = mockPostProcessor("one", "txt", ImplicitApplyOptions.NEVER); - roleFile.setPostProcessors(ImmutableList.of("one")); + roleFile.setPostProcessors(List.of("one")); - List result = ImmutableList.copyOf(underTest.generate()); + List result = List.copyOf(underTest.generate()); assertEquals(1, result.size()); - assertItem(result.get(0), "test.txt", ImmutableMap.of(), ImmutableSet.of("one")); + assertItem(result.get(0), "test.txt", Map.of(), Set.of("one")); verify(one, times(1)).apply(any(FileContext.class), any(PostProcessorContext.class)); } @@ -165,17 +162,17 @@ void testOnePostProcessorWithRewrite() throws Exception { public List answer(InvocationOnMock invocation) throws Throwable { // delete input file and create new file test.abc instead FileContext input = invocation.getArgument(0); - assertItem(input, "test.txt", ImmutableMap.of()); + assertItem(input, "test.txt", Map.of()); input.getFile().delete(); - return ImmutableList.of(newFile("test.abc")); + return List.of(newFile("test.abc")); } }); - roleFile.setPostProcessors(ImmutableList.of("one")); + roleFile.setPostProcessors(List.of("one")); - List result = ImmutableList.copyOf(underTest.generate()); + List result = List.copyOf(underTest.generate()); assertEquals(1, result.size()); - assertItem(result.get(0), "test.abc", ImmutableMap.of(), ImmutableSet.of("one")); + assertItem(result.get(0), "test.abc", Map.of(), Set.of("one")); verify(one, times(1)).apply(any(FileContext.class), any(PostProcessorContext.class)); } @@ -189,20 +186,20 @@ void testOnePostProcessorWithRewrite_WithFileHeaderAndValidator() throws Excepti public List answer(InvocationOnMock invocation) throws Throwable { // delete input file and create new file test.abc instead FileContext input = invocation.getArgument(0); - assertItem(input, "test.txt", ImmutableMap.of()); + assertItem(input, "test.txt", Map.of()); input.getFile().delete(); - return ImmutableList.of(newFile("test.abc")); + return List.of(newFile("test.abc")); } }); - roleFile.setPostProcessors(ImmutableList.of("one")); + roleFile.setPostProcessors(List.of("one")); - roleFile.setPostProcessorOptions(ImmutableMap.of( + roleFile.setPostProcessorOptions(Map.of( FileGenerator.POSTPROCESSOR_KEY_FILE_HEADER, "my-fileheader", - FileGenerator.POSTPROCESSOR_KEY_VALIDATORS, ImmutableList.of("my-validator"))); + FileGenerator.POSTPROCESSOR_KEY_VALIDATORS, List.of("my-validator"))); underTest = new FileGenerator(options, "env1", - "role1", ImmutableList.of("variant1"), "template1", - destDir, file, null, null, roleFile, ImmutableMap.of(), template, - variableMapResolver, urlFileManager, pluginContextOptions, ImmutableList.of()); + "role1", List.of("variant1"), "template1", + destDir, file, null, null, roleFile, Map.of(), template, + variableMapResolver, urlFileManager, pluginContextOptions, List.of()); FileHeaderPlugin fileHeaderPlugin = mock(FileHeaderPlugin.class); when(pluginManager.get(eq("my-fileheader"), eq(FileHeaderPlugin.class))).thenAnswer(new Answer() { @@ -220,10 +217,10 @@ public ValidatorPlugin answer(InvocationOnMock invocation) throws Throwable { } }); - List result = ImmutableList.copyOf(underTest.generate()); + List result = List.copyOf(underTest.generate()); assertEquals(1, result.size()); - assertItem(result.get(0), "test.abc", ImmutableMap.of(), ImmutableSet.of("one")); + assertItem(result.get(0), "test.abc", Map.of(), Set.of("one")); verify(one, times(1)).apply(any(FileContext.class), any(PostProcessorContext.class)); verify(fileHeaderPlugin, times(1)).apply(any(FileContext.class), any(FileHeaderContext.class)); @@ -234,12 +231,12 @@ public ValidatorPlugin answer(InvocationOnMock invocation) throws Throwable { void testTwoPostProcessors() throws Exception { PostProcessorPlugin one = mockPostProcessor("one", "txt", ImplicitApplyOptions.NEVER); PostProcessorPlugin two = mockPostProcessor("two", "txt", ImplicitApplyOptions.NEVER); - roleFile.setPostProcessors(ImmutableList.of("one", "two")); + roleFile.setPostProcessors(List.of("one", "two")); - List result = ImmutableList.copyOf(underTest.generate()); + List result = List.copyOf(underTest.generate()); assertEquals(1, result.size()); - assertItem(result.get(0), "test.txt", ImmutableMap.of(), ImmutableSet.of("one", "two")); + assertItem(result.get(0), "test.txt", Map.of(), Set.of("one", "two")); verify(one, times(1)).apply(any(FileContext.class), any(PostProcessorContext.class)); verify(two, times(1)).apply(any(FileContext.class), any(PostProcessorContext.class)); @@ -254,9 +251,9 @@ void testTwoPostProcessorsWithRewrite() throws Exception { public List answer(InvocationOnMock invocation) throws Throwable { // delete input file and create new file test.abc instead FileContext input = invocation.getArgument(0); - assertItem(input, "test.txt", ImmutableMap.of()); + assertItem(input, "test.txt", Map.of()); input.getFile().delete(); - return ImmutableList.of(newFile("test.abc")); + return List.of(newFile("test.abc")); } }); @@ -266,28 +263,28 @@ public List answer(InvocationOnMock invocation) throws Throwable { public List answer(InvocationOnMock invocation) throws Throwable { // create new file test.def FileContext input = invocation.getArgument(0); - assertItem(input, "test.abc", ImmutableMap.of()); - return ImmutableList.of(newFile("test.def")); + assertItem(input, "test.abc", Map.of()); + return List.of(newFile("test.def")); } }); - roleFile.setPostProcessors(ImmutableList.of("one", "two")); + roleFile.setPostProcessors(List.of("one", "two")); - List result = ImmutableList.copyOf(underTest.generate()); + List result = List.copyOf(underTest.generate()); assertEquals(2, result.size()); - assertItem(result.get(0), "test.abc", ImmutableMap.of(), ImmutableSet.of("one", "two")); - assertItem(result.get(1), "test.def", ImmutableMap.of(), ImmutableSet.of("two")); + assertItem(result.get(0), "test.abc", Map.of(), Set.of("one", "two")); + assertItem(result.get(1), "test.def", Map.of(), Set.of("two")); } @Test void testImplicitPostProcessor() throws Exception { PostProcessorPlugin one = mockPostProcessor("one", "txt", ImplicitApplyOptions.WHEN_UNCONFIGURED); - List result = ImmutableList.copyOf(underTest.generate()); + List result = List.copyOf(underTest.generate()); assertEquals(1, result.size()); - assertItem(result.get(0), "test.txt", ImmutableMap.of(), ImmutableSet.of("one")); + assertItem(result.get(0), "test.txt", Map.of(), Set.of("one")); verify(one, times(1)).apply(any(FileContext.class), any(PostProcessorContext.class)); } @@ -296,10 +293,10 @@ void testImplicitPostProcessor() throws Exception { void testAlwaysPostProcessor() throws Exception { PostProcessorPlugin one = mockPostProcessor("one", "txt", ImplicitApplyOptions.ALWAYS); - List result = ImmutableList.copyOf(underTest.generate()); + List result = List.copyOf(underTest.generate()); assertEquals(1, result.size()); - assertItem(result.get(0), "test.txt", ImmutableMap.of(), ImmutableSet.of("one")); + assertItem(result.get(0), "test.txt", Map.of(), Set.of("one")); verify(one, times(1)).apply(any(FileContext.class), any(PostProcessorContext.class)); } @@ -312,20 +309,20 @@ void testPostProcessorWithRewriteAndImplicit() throws Exception { public List answer(InvocationOnMock invocation) throws Throwable { // delete input file and create new file test.abc instead FileContext input = invocation.getArgument(0); - assertItem(input, "test.txt", ImmutableMap.of()); - return ImmutableList.of(newFile("test.abc")); + assertItem(input, "test.txt", Map.of()); + return List.of(newFile("test.abc")); } }); PostProcessorPlugin two = mockPostProcessor("two", "txt", ImplicitApplyOptions.ALWAYS); PostProcessorPlugin three = mockPostProcessor("three", "abc", ImplicitApplyOptions.ALWAYS); - roleFile.setPostProcessors(ImmutableList.of("one")); + roleFile.setPostProcessors(List.of("one")); - List result = ImmutableList.copyOf(underTest.generate()); + List result = List.copyOf(underTest.generate()); assertEquals(2, result.size()); - assertItem(result.get(0), "test.txt", ImmutableMap.of(), ImmutableSet.of("one", "two")); - assertItem(result.get(1), "test.abc", ImmutableMap.of(), ImmutableSet.of("one", "three")); + assertItem(result.get(0), "test.txt", Map.of(), Set.of("one", "two")); + assertItem(result.get(1), "test.abc", Map.of(), Set.of("one", "three")); verify(one, times(1)).apply(any(FileContext.class), any(PostProcessorContext.class)); verify(two, times(1)).apply(any(FileContext.class), any(PostProcessorContext.class)); diff --git a/generator/src/test/java/io/wcm/devops/conga/generator/FileGeneratorValidatorTest.java b/generator/src/test/java/io/wcm/devops/conga/generator/FileGeneratorValidatorTest.java index 09217b24..e2f1323e 100644 --- a/generator/src/test/java/io/wcm/devops/conga/generator/FileGeneratorValidatorTest.java +++ b/generator/src/test/java/io/wcm/devops/conga/generator/FileGeneratorValidatorTest.java @@ -48,8 +48,6 @@ import org.slf4j.Logger; import com.github.jknack.handlebars.Template; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; import io.wcm.devops.conga.generator.spi.ImplicitApplyOptions; import io.wcm.devops.conga.generator.spi.ValidatorPlugin; @@ -92,7 +90,7 @@ void setUp(TestInfo testInfo) { when(pluginManager.getAll(ValidatorPlugin.class)).thenAnswer(new Answer>() { @Override public List answer(InvocationOnMock invocation) throws Throwable { - return ImmutableList.copyOf(validatorPlugins.values()); + return List.copyOf(validatorPlugins.values()); } }); when(pluginManager.get(anyString(), eq(ValidatorPlugin.class))).thenAnswer(new Answer() { @@ -112,16 +110,16 @@ public ValidatorPlugin answer(InvocationOnMock invocation) throws Throwable { VariableMapResolver variableMapResolver = new VariableMapResolver( new ValueProviderGlobalContext().pluginContextOptions(pluginContextOptions)); underTest = new FileGenerator(options, "env1", - "role1", ImmutableList.of("variant1"), "template1", - destDir, file, null, null, roleFile, ImmutableMap.of(), template, - variableMapResolver, urlFileManager, pluginContextOptions, ImmutableList.of()); + "role1", List.of("variant1"), "template1", + destDir, file, null, null, roleFile, Map.of(), template, + variableMapResolver, urlFileManager, pluginContextOptions, List.of()); } @Test void testWithoutValidator() throws Exception { ValidatorPlugin one = mockValidator("one", "txt", ImplicitApplyOptions.NEVER); - List result = ImmutableList.copyOf(underTest.generate()); + List result = List.copyOf(underTest.generate()); assertEquals(1, result.size()); assertItem(result.get(0), "test.txt"); @@ -132,9 +130,9 @@ void testWithoutValidator() throws Exception { @Test void testOneValidator() throws Exception { ValidatorPlugin one = mockValidator("one", "txt", ImplicitApplyOptions.NEVER); - roleFile.setValidators(ImmutableList.of("one")); + roleFile.setValidators(List.of("one")); - List result = ImmutableList.copyOf(underTest.generate()); + List result = List.copyOf(underTest.generate()); assertEquals(1, result.size()); assertItem(result.get(0), "test.txt"); @@ -146,9 +144,9 @@ void testOneValidator() throws Exception { void testTwoValidators() throws Exception { ValidatorPlugin one = mockValidator("one", "txt", ImplicitApplyOptions.NEVER); ValidatorPlugin two = mockValidator("two", "txt", ImplicitApplyOptions.NEVER); - roleFile.setValidators(ImmutableList.of("one", "two")); + roleFile.setValidators(List.of("one", "two")); - List result = ImmutableList.copyOf(underTest.generate()); + List result = List.copyOf(underTest.generate()); assertEquals(1, result.size()); assertItem(result.get(0), "test.txt"); @@ -161,7 +159,7 @@ void testTwoValidators() throws Exception { void testImplicitValidator() throws Exception { ValidatorPlugin one = mockValidator("one", "txt", ImplicitApplyOptions.WHEN_UNCONFIGURED); - List result = ImmutableList.copyOf(underTest.generate()); + List result = List.copyOf(underTest.generate()); assertEquals(1, result.size()); assertItem(result.get(0), "test.txt"); @@ -173,7 +171,7 @@ void testImplicitValidator() throws Exception { void testAlwaysValidator() throws Exception { ValidatorPlugin one = mockValidator("one", "txt", ImplicitApplyOptions.ALWAYS); - List result = ImmutableList.copyOf(underTest.generate()); + List result = List.copyOf(underTest.generate()); assertEquals(1, result.size()); assertItem(result.get(0), "test.txt"); @@ -186,7 +184,7 @@ void testImplicitAndAlwaysValidator() throws Exception { ValidatorPlugin one = mockValidator("one", "txt", ImplicitApplyOptions.WHEN_UNCONFIGURED); ValidatorPlugin two = mockValidator("two", "txt", ImplicitApplyOptions.ALWAYS); - List result = ImmutableList.copyOf(underTest.generate()); + List result = List.copyOf(underTest.generate()); assertEquals(1, result.size()); assertItem(result.get(0), "test.txt"); diff --git a/generator/src/test/java/io/wcm/devops/conga/generator/GeneratorTestNodeModelExportTest.java b/generator/src/test/java/io/wcm/devops/conga/generator/GeneratorTestNodeModelExportTest.java index 3e9ad03e..dc6a46dd 100644 --- a/generator/src/test/java/io/wcm/devops/conga/generator/GeneratorTestNodeModelExportTest.java +++ b/generator/src/test/java/io/wcm/devops/conga/generator/GeneratorTestNodeModelExportTest.java @@ -37,6 +37,7 @@ import java.io.Reader; import java.nio.charset.StandardCharsets; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.Map; @@ -49,9 +50,6 @@ import org.junit.jupiter.api.TestInfo; import org.yaml.snakeyaml.Yaml; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; - import io.wcm.devops.conga.model.util.MapExpander; @SuppressWarnings("unchecked") @@ -86,14 +84,14 @@ void testAllEnvironments() throws IOException { "files/sample-copy.txt"); assertFileModelOptions(role1, "files/sample-filesystem.txt", - ImmutableMap.of("modelOption1", "value1")); + Map.of("modelOption1", "value1")); assertEquals("globalFromRole1", getConfig(role1, "globalString")); - assertEquals(ImmutableList.of("tenantRole1", "tenantRole2"), getTenantRoles(role1, "tenant1")); + assertEquals(List.of("tenantRole1", "tenantRole2"), getTenantRoles(role1, "tenant1")); assertEquals("\"value1\" äöü߀", getTenantConfig(role1, "tenant1", "defaultString")); - assertEquals(ImmutableList.of("tenantRole1"), getTenantRoles(role1, "tenant2")); + assertEquals(List.of("tenantRole1"), getTenantRoles(role1, "tenant2")); assertEquals("defaultFromTenant2", getTenantConfig(role1, "tenant2", "defaultString")); - assertEquals(ImmutableList.of(), getTenantRoles(role1, "tenant3_TenantSuffix")); + assertEquals(List.of(), getTenantRoles(role1, "tenant3_TenantSuffix")); assertEquals("\"value1\" äöü߀", getTenantConfig(role1, "tenant3_TenantSuffix", "defaultString")); assertEquals("tenant1 testVersion1ForFileHeader node1 role1", getTenantConfig(role1, "tenant1", "varWithContext")); assertEquals("tenant2 testVersion1ForFileHeader node1 role1", getTenantConfig(role1, "tenant2", "varWithContext")); @@ -103,11 +101,11 @@ void testAllEnvironments() throws IOException { "json/test.json"); assertEquals("globalValue äöü߀", getConfig(role2, "globalString")); assertEquals("globalValue äöü߀", getConfig(role2, "globalString")); - assertEquals(ImmutableList.of("tenantRole1", "tenantRole2"), getTenantRoles(role2, "tenant1")); + assertEquals(List.of("tenantRole1", "tenantRole2"), getTenantRoles(role2, "tenant1")); assertEquals("value2", getTenantConfig(role2, "tenant1", "defaultString")); - assertEquals(ImmutableList.of("tenantRole1"), getTenantRoles(role2, "tenant2")); + assertEquals(List.of("tenantRole1"), getTenantRoles(role2, "tenant2")); assertEquals("defaultFromTenant2", getTenantConfig(role2, "tenant2", "defaultString")); - assertEquals(ImmutableList.of(), getTenantRoles(role2, "tenant3_TenantSuffix")); + assertEquals(List.of(), getTenantRoles(role2, "tenant3_TenantSuffix")); assertEquals("value2", getTenantConfig(role2, "tenant3_TenantSuffix", "defaultString")); assertEquals("tenant1 testVersion1ForFileHeader node1 role2", getTenantConfig(role2, "tenant1", "varWithContext")); assertEquals("tenant2 testVersion1ForFileHeader node1 role2", getTenantConfig(role2, "tenant2", "varWithContext")); @@ -164,7 +162,7 @@ private void assertFiles(Map role, String... fileNamesExpected) if (files != null) { files.forEach(item -> fileNamesFound.add((String)item.get("path"))); } - assertEquals(ImmutableList.copyOf(fileNamesExpected), fileNamesFound); + assertEquals(Arrays.asList(fileNamesExpected), fileNamesFound); } private void assertFileModelOptions(Map role, String fileName, Map expectedOptions) { @@ -212,9 +210,9 @@ private Object getTenantConfig(Map role, String tenant, String k private List getTenantRoles(Map role, String tenant) { Map tenantObject = getTenant(role, tenant); if (tenantObject == null) { - return ImmutableList.of(); + return List.of(); } - return (List)ObjectUtils.defaultIfNull(tenantObject.get("roles"), ImmutableList.of()); + return (List)ObjectUtils.defaultIfNull(tenantObject.get("roles"), List.of()); } } diff --git a/generator/src/test/java/io/wcm/devops/conga/generator/TestUtils.java b/generator/src/test/java/io/wcm/devops/conga/generator/TestUtils.java index 14ce3cc9..82b7f15d 100644 --- a/generator/src/test/java/io/wcm/devops/conga/generator/TestUtils.java +++ b/generator/src/test/java/io/wcm/devops/conga/generator/TestUtils.java @@ -28,13 +28,12 @@ import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.nio.file.Files; +import java.util.List; +import java.util.Map; import org.apache.commons.io.FileUtils; import org.apache.commons.lang3.StringUtils; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; - import io.wcm.devops.conga.generator.export.ModelExport; import io.wcm.devops.conga.generator.plugins.valueprovider.DummyPluginConfigValueProviderPlugin; import io.wcm.devops.conga.generator.util.FileUtil; @@ -57,14 +56,14 @@ public static Generator setupGenerator(File destDir) { .destDir(destDir) .version(TEST_VERSION) .pluginManager(new PluginManagerImpl()) - .genericPluginConfig(ImmutableMap.of( - DummyPluginConfigValueProviderPlugin.NAME, ImmutableMap.of( + .genericPluginConfig(Map.of( + DummyPluginConfigValueProviderPlugin.NAME, Map.of( "param1", "value1", "param2", 55, - "param3", ImmutableMap.of("param31", "value31", "param32", "value32")))); + "param3", Map.of("param31", "value31", "param32", "value32")))); ModelExport modelExport = new ModelExport(); - modelExport.setNode(ImmutableList.of("yaml")); + modelExport.setNode(List.of("yaml")); options.modelExport(modelExport); return new Generator(options); diff --git a/generator/src/test/java/io/wcm/devops/conga/generator/plugins/fileheader/ConfFileHeaderTest.java b/generator/src/test/java/io/wcm/devops/conga/generator/plugins/fileheader/ConfFileHeaderTest.java index 34fc9698..414cf132 100644 --- a/generator/src/test/java/io/wcm/devops/conga/generator/plugins/fileheader/ConfFileHeaderTest.java +++ b/generator/src/test/java/io/wcm/devops/conga/generator/plugins/fileheader/ConfFileHeaderTest.java @@ -31,8 +31,6 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import com.google.common.collect.ImmutableList; - import io.wcm.devops.conga.generator.spi.FileHeaderPlugin; import io.wcm.devops.conga.generator.spi.context.FileContext; import io.wcm.devops.conga.generator.spi.context.FileHeaderContext; @@ -52,7 +50,7 @@ void testApply() throws Exception { File file = new File("target/generation-test/fileHeader.conf"); FileUtils.write(file, "myscript", StandardCharsets.ISO_8859_1); - List lines = ImmutableList.of("Der Jodelkaiser", "aus dem Oetztal", "ist wieder daheim."); + List lines = List.of("Der Jodelkaiser", "aus dem Oetztal", "ist wieder daheim."); FileHeaderContext context = new FileHeaderContext().commentLines(lines); FileContext fileContext = new FileContext().file(file); diff --git a/generator/src/test/java/io/wcm/devops/conga/generator/plugins/fileheader/JsonFileHeaderTest.java b/generator/src/test/java/io/wcm/devops/conga/generator/plugins/fileheader/JsonFileHeaderTest.java index dbf6d019..cc996e11 100644 --- a/generator/src/test/java/io/wcm/devops/conga/generator/plugins/fileheader/JsonFileHeaderTest.java +++ b/generator/src/test/java/io/wcm/devops/conga/generator/plugins/fileheader/JsonFileHeaderTest.java @@ -31,8 +31,6 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import com.google.common.collect.ImmutableList; - import io.wcm.devops.conga.generator.spi.FileHeaderPlugin; import io.wcm.devops.conga.generator.spi.context.FileContext; import io.wcm.devops.conga.generator.spi.context.FileHeaderContext; @@ -52,7 +50,7 @@ void testApply() throws Exception { File file = new File("target/generation-test/fileHeader.json"); FileUtils.copyFile(new File(getClass().getResource("/validators/json/validJson.json").toURI()), file); - List lines = ImmutableList.of("Der Jodelkaiser", "aus dem Oetztal", "ist wieder daheim."); + List lines = List.of("Der Jodelkaiser", "aus dem Oetztal", "ist wieder daheim."); FileHeaderContext context = new FileHeaderContext().commentLines(lines); FileContext fileContext = new FileContext().file(file); diff --git a/generator/src/test/java/io/wcm/devops/conga/generator/plugins/fileheader/UnixShellScriptFileHeaderTest.java b/generator/src/test/java/io/wcm/devops/conga/generator/plugins/fileheader/UnixShellScriptFileHeaderTest.java index 779b5010..ed5630f2 100644 --- a/generator/src/test/java/io/wcm/devops/conga/generator/plugins/fileheader/UnixShellScriptFileHeaderTest.java +++ b/generator/src/test/java/io/wcm/devops/conga/generator/plugins/fileheader/UnixShellScriptFileHeaderTest.java @@ -31,8 +31,6 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import com.google.common.collect.ImmutableList; - import io.wcm.devops.conga.generator.spi.FileHeaderPlugin; import io.wcm.devops.conga.generator.spi.context.FileContext; import io.wcm.devops.conga.generator.spi.context.FileHeaderContext; @@ -53,7 +51,7 @@ void testApply() throws Exception { FileUtils.write(file, "#!/bin/bash\n" + "myscript", StandardCharsets.ISO_8859_1); - List lines = ImmutableList.of("Der Jodelkaiser", "aus dem Oetztal", "ist wieder daheim."); + List lines = List.of("Der Jodelkaiser", "aus dem Oetztal", "ist wieder daheim."); FileHeaderContext context = new FileHeaderContext().commentLines(lines); FileContext fileContext = new FileContext().file(file); diff --git a/generator/src/test/java/io/wcm/devops/conga/generator/plugins/fileheader/WindowsShellScriptFileHeaderTest.java b/generator/src/test/java/io/wcm/devops/conga/generator/plugins/fileheader/WindowsShellScriptFileHeaderTest.java index 692b1aca..c682423c 100644 --- a/generator/src/test/java/io/wcm/devops/conga/generator/plugins/fileheader/WindowsShellScriptFileHeaderTest.java +++ b/generator/src/test/java/io/wcm/devops/conga/generator/plugins/fileheader/WindowsShellScriptFileHeaderTest.java @@ -31,8 +31,6 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import com.google.common.collect.ImmutableList; - import io.wcm.devops.conga.generator.spi.FileHeaderPlugin; import io.wcm.devops.conga.generator.spi.context.FileContext; import io.wcm.devops.conga.generator.spi.context.FileHeaderContext; @@ -52,7 +50,7 @@ void testApply() throws Exception { File file = new File("target/generation-test/fileHeader.cmd"); FileUtils.write(file, "myscript", StandardCharsets.ISO_8859_1); - List lines = ImmutableList.of("Der Jodelkaiser", "aus dem Oetztal", "ist wieder daheim."); + List lines = List.of("Der Jodelkaiser", "aus dem Oetztal", "ist wieder daheim."); FileHeaderContext context = new FileHeaderContext().commentLines(lines); FileContext fileContext = new FileContext().file(file); diff --git a/generator/src/test/java/io/wcm/devops/conga/generator/plugins/fileheader/XmlFileHeaderTest.java b/generator/src/test/java/io/wcm/devops/conga/generator/plugins/fileheader/XmlFileHeaderTest.java index 3bdfa28b..35607a9a 100644 --- a/generator/src/test/java/io/wcm/devops/conga/generator/plugins/fileheader/XmlFileHeaderTest.java +++ b/generator/src/test/java/io/wcm/devops/conga/generator/plugins/fileheader/XmlFileHeaderTest.java @@ -31,8 +31,6 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import com.google.common.collect.ImmutableList; - import io.wcm.devops.conga.generator.spi.FileHeaderPlugin; import io.wcm.devops.conga.generator.spi.context.FileContext; import io.wcm.devops.conga.generator.spi.context.FileHeaderContext; @@ -52,7 +50,7 @@ void testApply() throws Exception { File file = new File("target/generation-test/fileHeader.xml"); FileUtils.copyFile(new File(getClass().getResource("/validators/xml/validXml.xml").toURI()), file); - List lines = ImmutableList.of("Der Jodelkaiser", "aus dem Oetztal", "ist wieder daheim."); + List lines = List.of("Der Jodelkaiser", "aus dem Oetztal", "ist wieder daheim."); FileHeaderContext context = new FileHeaderContext().commentLines(lines); FileContext fileContext = new FileContext().file(file); diff --git a/generator/src/test/java/io/wcm/devops/conga/generator/plugins/handlebars/helper/ContainsHelperTest.java b/generator/src/test/java/io/wcm/devops/conga/generator/plugins/handlebars/helper/ContainsHelperTest.java index 92fd11a8..e664f592 100644 --- a/generator/src/test/java/io/wcm/devops/conga/generator/plugins/handlebars/helper/ContainsHelperTest.java +++ b/generator/src/test/java/io/wcm/devops/conga/generator/plugins/handlebars/helper/ContainsHelperTest.java @@ -22,12 +22,12 @@ import static io.wcm.devops.conga.generator.plugins.handlebars.helper.MockOptions.FN_RETURN; import static io.wcm.devops.conga.generator.plugins.handlebars.helper.TestUtils.assertHelper; +import java.util.List; +import java.util.Set; + import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableSet; - import io.wcm.devops.conga.generator.spi.handlebars.HelperPlugin; import io.wcm.devops.conga.generator.util.PluginManagerImpl; @@ -43,22 +43,22 @@ void setUp() { @Test void testContains() throws Exception { - assertHelper(FN_RETURN, helper, ImmutableList.of("a", "b", "c"), new MockOptions("a")); - assertHelper(FN_RETURN, helper, ImmutableSet.of("a", "b", "c"), new MockOptions("b")); + assertHelper(FN_RETURN, helper, List.of("a", "b", "c"), new MockOptions("a")); + assertHelper(FN_RETURN, helper, Set.of("a", "b", "c"), new MockOptions("b")); assertHelper(FN_RETURN, helper, new String[] { "a", "b", "c" }, new MockOptions("a")); assertHelper(FN_RETURN, helper, new String[] { "a", "b", "c" }, new MockOptions("b")); } @Test void testNotContains() throws Exception { - assertHelper("", helper, ImmutableList.of("a", "b", "c"), new MockOptions("z")); + assertHelper("", helper, List.of("a", "b", "c"), new MockOptions("z")); assertHelper("", helper, new String[] { "a", "b", "c" }, new MockOptions("z")); } @Test void testNull() throws Exception { assertHelper("", helper, null, new MockOptions("def")); - assertHelper("", helper, ImmutableList.of("a", "b", "c"), new MockOptions()); + assertHelper("", helper, List.of("a", "b", "c"), new MockOptions()); assertHelper("", helper, null, new MockOptions()); } diff --git a/generator/src/test/java/io/wcm/devops/conga/generator/plugins/handlebars/helper/EachIfEqualsHelperTest.java b/generator/src/test/java/io/wcm/devops/conga/generator/plugins/handlebars/helper/EachIfEqualsHelperTest.java index 61ea416c..fb2a19e4 100644 --- a/generator/src/test/java/io/wcm/devops/conga/generator/plugins/handlebars/helper/EachIfEqualsHelperTest.java +++ b/generator/src/test/java/io/wcm/devops/conga/generator/plugins/handlebars/helper/EachIfEqualsHelperTest.java @@ -21,12 +21,12 @@ import static io.wcm.devops.conga.generator.plugins.handlebars.helper.TestUtils.assertHelper; +import java.util.List; +import java.util.Map; + import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; - import io.wcm.devops.conga.generator.spi.handlebars.HelperPlugin; import io.wcm.devops.conga.generator.util.PluginManagerImpl; @@ -54,11 +54,11 @@ void testSingleValue() throws Exception { @Test void testList() throws Exception { - assertHelper("", helper, ImmutableList.of("v1", "v2"), new MockOptions()); - assertHelper("", helper, ImmutableList.of("v1", "v2"), new MockOptions("a")); - assertHelper("", helper, ImmutableList.of(ImmutableMap.of("a", "1"), ImmutableMap.of("a", "2")), new MockOptions("a")); - assertHelper("fn({a=1})", helper, ImmutableList.of(ImmutableMap.of("a", "1"), ImmutableMap.of("a", "2")), new MockOptions("a", "1")); - assertHelper("fn({a=1})fn({a=1})", helper, ImmutableList.of(ImmutableMap.of("a", "1"), ImmutableMap.of("a", "1")), new MockOptions("a", "1")); + assertHelper("", helper, List.of("v1", "v2"), new MockOptions()); + assertHelper("", helper, List.of("v1", "v2"), new MockOptions("a")); + assertHelper("", helper, List.of(Map.of("a", "1"), Map.of("a", "2")), new MockOptions("a")); + assertHelper("fn({a=1})", helper, List.of(Map.of("a", "1"), Map.of("a", "2")), new MockOptions("a", "1")); + assertHelper("fn({a=1})fn({a=1})", helper, List.of(Map.of("a", "1"), Map.of("a", "1")), new MockOptions("a", "1")); } } diff --git a/generator/src/test/java/io/wcm/devops/conga/generator/plugins/handlebars/helper/EachIfHelperTest.java b/generator/src/test/java/io/wcm/devops/conga/generator/plugins/handlebars/helper/EachIfHelperTest.java index 51ada850..c1ec9a0b 100644 --- a/generator/src/test/java/io/wcm/devops/conga/generator/plugins/handlebars/helper/EachIfHelperTest.java +++ b/generator/src/test/java/io/wcm/devops/conga/generator/plugins/handlebars/helper/EachIfHelperTest.java @@ -21,12 +21,12 @@ import static io.wcm.devops.conga.generator.plugins.handlebars.helper.TestUtils.assertHelper; +import java.util.List; +import java.util.Map; + import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; - import io.wcm.devops.conga.generator.spi.handlebars.HelperPlugin; import io.wcm.devops.conga.generator.util.PluginManagerImpl; @@ -54,16 +54,16 @@ void testSingleValue() throws Exception { @Test void testList() throws Exception { - assertHelper("", helper, ImmutableList.of("v1", "v2"), new MockOptions()); - assertHelper("", helper, ImmutableList.of("v1", "v2"), new MockOptions("a")); - assertHelper("fn({a=1})", helper, ImmutableList.of(ImmutableMap.of("a", "1"), ImmutableMap.of("b", "2")), new MockOptions("a")); - assertHelper("fn({a=1})fn({a=2})", helper, ImmutableList.of(ImmutableMap.of("a", "1"), ImmutableMap.of("a", "2")), new MockOptions("a")); + assertHelper("", helper, List.of("v1", "v2"), new MockOptions()); + assertHelper("", helper, List.of("v1", "v2"), new MockOptions("a")); + assertHelper("fn({a=1})", helper, List.of(Map.of("a", "1"), Map.of("b", "2")), new MockOptions("a")); + assertHelper("fn({a=1})fn({a=2})", helper, List.of(Map.of("a", "1"), Map.of("a", "2")), new MockOptions("a")); } @Test void testListDeepMap() throws Exception { assertHelper("fn({a={b=1}})", helper, - ImmutableList.of(ImmutableMap.of("a", "1"), ImmutableMap.of("a", ImmutableMap.of("b", "1"))), new MockOptions("a.b")); + List.of(Map.of("a", "1"), Map.of("a", Map.of("b", "1"))), new MockOptions("a.b")); } } diff --git a/generator/src/test/java/io/wcm/devops/conga/generator/plugins/handlebars/helper/IfEqualsHelperTest.java b/generator/src/test/java/io/wcm/devops/conga/generator/plugins/handlebars/helper/IfEqualsHelperTest.java index 2285c50f..1d3e6d03 100644 --- a/generator/src/test/java/io/wcm/devops/conga/generator/plugins/handlebars/helper/IfEqualsHelperTest.java +++ b/generator/src/test/java/io/wcm/devops/conga/generator/plugins/handlebars/helper/IfEqualsHelperTest.java @@ -22,11 +22,11 @@ import static io.wcm.devops.conga.generator.plugins.handlebars.helper.MockOptions.FN_RETURN; import static io.wcm.devops.conga.generator.plugins.handlebars.helper.TestUtils.assertHelper; +import java.util.List; + import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import com.google.common.collect.ImmutableList; - import io.wcm.devops.conga.generator.spi.handlebars.HelperPlugin; import io.wcm.devops.conga.generator.util.PluginManagerImpl; @@ -43,13 +43,13 @@ void setUp() { @Test void testEquals() throws Exception { assertHelper(FN_RETURN, helper, "abc", new MockOptions("abc")); - assertHelper(FN_RETURN, helper, ImmutableList.of("a", "b", "c"), new MockOptions(ImmutableList.of("a", "b", "c"))); + assertHelper(FN_RETURN, helper, List.of("a", "b", "c"), new MockOptions(List.of("a", "b", "c"))); } @Test void testNotEquals() throws Exception { assertHelper("", helper, "abc", new MockOptions("def")); - assertHelper("", helper, ImmutableList.of("a", "b", "c"), new MockOptions(ImmutableList.of("d", "e", "f"))); + assertHelper("", helper, List.of("a", "b", "c"), new MockOptions(List.of("d", "e", "f"))); } @Test diff --git a/generator/src/test/java/io/wcm/devops/conga/generator/plugins/handlebars/helper/IfNotEqualsHelperTest.java b/generator/src/test/java/io/wcm/devops/conga/generator/plugins/handlebars/helper/IfNotEqualsHelperTest.java index 3f89e271..c1e3e8f3 100644 --- a/generator/src/test/java/io/wcm/devops/conga/generator/plugins/handlebars/helper/IfNotEqualsHelperTest.java +++ b/generator/src/test/java/io/wcm/devops/conga/generator/plugins/handlebars/helper/IfNotEqualsHelperTest.java @@ -22,11 +22,11 @@ import static io.wcm.devops.conga.generator.plugins.handlebars.helper.MockOptions.FN_RETURN; import static io.wcm.devops.conga.generator.plugins.handlebars.helper.TestUtils.assertHelper; +import java.util.List; + import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import com.google.common.collect.ImmutableList; - import io.wcm.devops.conga.generator.spi.handlebars.HelperPlugin; import io.wcm.devops.conga.generator.util.PluginManagerImpl; @@ -43,13 +43,13 @@ void setUp() { @Test void testEquals() throws Exception { assertHelper("", helper, "abc", new MockOptions("abc")); - assertHelper("", helper, ImmutableList.of("a", "b", "c"), new MockOptions(ImmutableList.of("a", "b", "c"))); + assertHelper("", helper, List.of("a", "b", "c"), new MockOptions(List.of("a", "b", "c"))); } @Test void testNotEquals() throws Exception { assertHelper(FN_RETURN, helper, "abc", new MockOptions("def")); - assertHelper(FN_RETURN, helper, ImmutableList.of("a", "b", "c"), new MockOptions(ImmutableList.of("d", "e", "f"))); + assertHelper(FN_RETURN, helper, List.of("a", "b", "c"), new MockOptions(List.of("d", "e", "f"))); } @Test diff --git a/generator/src/test/java/io/wcm/devops/conga/generator/plugins/handlebars/helper/MockOptions.java b/generator/src/test/java/io/wcm/devops/conga/generator/plugins/handlebars/helper/MockOptions.java index 4b820394..c6a4f7c9 100644 --- a/generator/src/test/java/io/wcm/devops/conga/generator/plugins/handlebars/helper/MockOptions.java +++ b/generator/src/test/java/io/wcm/devops/conga/generator/plugins/handlebars/helper/MockOptions.java @@ -26,6 +26,7 @@ import java.io.IOException; import java.util.HashMap; +import java.util.List; import java.util.Map; import org.mockito.invocation.InvocationOnMock; @@ -36,7 +37,6 @@ import com.github.jknack.handlebars.Options; import com.github.jknack.handlebars.TagType; import com.github.jknack.handlebars.Template; -import com.google.common.collect.ImmutableList; /** * Subclass of {@link Options} that mocks all dependencies, but allows to set params. @@ -75,7 +75,7 @@ final class MockOptions extends Options { getInverseTemplate(), params, new HashMap<>(), - ImmutableList.of()); + List.of()); } private static Template getFnTemplate() { diff --git a/generator/src/test/java/io/wcm/devops/conga/generator/plugins/multiply/NoneMultiplyTest.java b/generator/src/test/java/io/wcm/devops/conga/generator/plugins/multiply/NoneMultiplyTest.java index ba81e9b8..659c7f3b 100644 --- a/generator/src/test/java/io/wcm/devops/conga/generator/plugins/multiply/NoneMultiplyTest.java +++ b/generator/src/test/java/io/wcm/devops/conga/generator/plugins/multiply/NoneMultiplyTest.java @@ -27,8 +27,6 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import com.google.common.collect.ImmutableMap; - import io.wcm.devops.conga.generator.spi.MultiplyPlugin; import io.wcm.devops.conga.generator.spi.context.MultiplyContext; import io.wcm.devops.conga.generator.util.PluginManagerImpl; @@ -52,7 +50,7 @@ void setUp() { role = new Role(); roleFile = new RoleFile(); - config = ImmutableMap.of("var1", "v1"); + config = Map.of("var1", "v1"); environment = new Environment(); } diff --git a/generator/src/test/java/io/wcm/devops/conga/generator/plugins/multiply/TenantMultiplyTest.java b/generator/src/test/java/io/wcm/devops/conga/generator/plugins/multiply/TenantMultiplyTest.java index fb58f549..5f2e548b 100644 --- a/generator/src/test/java/io/wcm/devops/conga/generator/plugins/multiply/TenantMultiplyTest.java +++ b/generator/src/test/java/io/wcm/devops/conga/generator/plugins/multiply/TenantMultiplyTest.java @@ -28,9 +28,6 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; - import io.wcm.devops.conga.generator.ContextProperties; import io.wcm.devops.conga.generator.GeneratorException; import io.wcm.devops.conga.generator.spi.MultiplyPlugin; @@ -65,7 +62,7 @@ void setUp() { role = new Role(); roleFile = new RoleFile(); - config = ImmutableMap.of("var1", "v1", "var2", "v2"); + config = Map.of("var1", "v1", "var2", "v2"); environment = new Environment(); @@ -106,7 +103,7 @@ void testTenantWithoutName() { void testTenantsWithConfig() { Tenant tenant1 = new Tenant(); tenant1.setTenant("tenant1"); - tenant1.setConfig(ImmutableMap.of("var1", "v11", "var3", "v33")); + tenant1.setConfig(Map.of("var1", "v11", "var3", "v33")); environment.getTenants().add(tenant1); Tenant tenant2 = new Tenant(); @@ -117,14 +114,14 @@ void testTenantsWithConfig() { assertEquals(2, configs.size()); Map config1 = configs.get(0); - assertEquals(ImmutableMap.of("var1", "v11", "var2", "v2", "var3", "v33", + assertEquals(Map.of("var1", "v11", "var2", "v2", "var3", "v33", ContextProperties.TENANT, "tenant1", - ContextProperties.TENANT_ROLES, ImmutableList.of()), config1); + ContextProperties.TENANT_ROLES, List.of()), config1); Map config2 = configs.get(1); - assertEquals(ImmutableMap.of("var1", "v1", "var2", "v2", + assertEquals(Map.of("var1", "v1", "var2", "v2", ContextProperties.TENANT, "tenant2", - ContextProperties.TENANT_ROLES, ImmutableList.of()), config2); + ContextProperties.TENANT_ROLES, List.of()), config2); } @Test @@ -135,28 +132,28 @@ void testTenantsFilteredByRoles() { Tenant tenant2 = new Tenant(); tenant2.setTenant("tenant2"); - tenant2.setRoles(ImmutableList.of("role1", "role2")); + tenant2.setRoles(List.of("role1", "role2")); environment.getTenants().add(tenant2); Tenant tenant3 = new Tenant(); tenant3.setTenant("tenant3"); - tenant3.setRoles(ImmutableList.of("role1")); + tenant3.setRoles(List.of("role1")); environment.getTenants().add(tenant3); - roleFile.setMultiplyOptions(ImmutableMap.of(TenantMultiply.ROLES_PROPERTY, ImmutableList.of("role1", "role3"))); + roleFile.setMultiplyOptions(Map.of(TenantMultiply.ROLES_PROPERTY, List.of("role1", "role3"))); List> configs = underTest.multiply(context); assertEquals(2, configs.size()); Map config1 = configs.get(0); - assertEquals(ImmutableMap.of("var1", "v1", "var2", "v2", + assertEquals(Map.of("var1", "v1", "var2", "v2", ContextProperties.TENANT, "tenant2", - ContextProperties.TENANT_ROLES, ImmutableList.of("role1", "role2")), config1); + ContextProperties.TENANT_ROLES, List.of("role1", "role2")), config1); Map config2 = configs.get(1); - assertEquals(ImmutableMap.of("var1", "v1", "var2", "v2", + assertEquals(Map.of("var1", "v1", "var2", "v2", ContextProperties.TENANT, "tenant3", - ContextProperties.TENANT_ROLES, ImmutableList.of("role1")), config2); + ContextProperties.TENANT_ROLES, List.of("role1")), config2); } } diff --git a/generator/src/test/java/io/wcm/devops/conga/generator/plugins/postprocessor/AbstractPostProcessorTest.java b/generator/src/test/java/io/wcm/devops/conga/generator/plugins/postprocessor/AbstractPostProcessorTest.java index 02a9e13f..eaaa105e 100644 --- a/generator/src/test/java/io/wcm/devops/conga/generator/plugins/postprocessor/AbstractPostProcessorTest.java +++ b/generator/src/test/java/io/wcm/devops/conga/generator/plugins/postprocessor/AbstractPostProcessorTest.java @@ -27,8 +27,6 @@ import org.apache.commons.io.FileUtils; import org.junit.jupiter.api.Test; -import com.google.common.collect.ImmutableList; - import io.wcm.devops.conga.generator.plugins.fileheader.ConfFileHeader; import io.wcm.devops.conga.generator.plugins.fileheader.JsonFileHeader; import io.wcm.devops.conga.generator.spi.PostProcessorPlugin; @@ -45,7 +43,7 @@ void testApply() throws Exception { File file = new File("target/generation-test/postProcessor.json"); FileUtils.copyFile(new File(getClass().getResource("/validators/json/validJson.json").toURI()), file); - List lines = ImmutableList.of("Der Jodelkaiser", "aus dem Oetztal", "ist wieder daheim."); + List lines = List.of("Der Jodelkaiser", "aus dem Oetztal", "ist wieder daheim."); FileHeaderContext fileHeader = new FileHeaderContext().commentLines(lines); FileContext fileContext = new FileContext().file(file); new JsonFileHeader().apply(fileContext, fileHeader); diff --git a/generator/src/test/java/io/wcm/devops/conga/generator/plugins/postprocessor/DummyPostProcessor.java b/generator/src/test/java/io/wcm/devops/conga/generator/plugins/postprocessor/DummyPostProcessor.java index ed6e741e..87e171e6 100644 --- a/generator/src/test/java/io/wcm/devops/conga/generator/plugins/postprocessor/DummyPostProcessor.java +++ b/generator/src/test/java/io/wcm/devops/conga/generator/plugins/postprocessor/DummyPostProcessor.java @@ -26,8 +26,6 @@ import org.apache.commons.io.FileUtils; -import com.google.common.collect.ImmutableList; - import io.wcm.devops.conga.generator.spi.context.FileContext; import io.wcm.devops.conga.generator.spi.context.FileHeaderContext; import io.wcm.devops.conga.generator.spi.context.PostProcessorContext; @@ -61,7 +59,7 @@ public List apply(FileContext file, PostProcessorContext context) { applyFileHeader(newFileContext, fileHeader, context); } - return ImmutableList.of(newFileContext); + return List.of(newFileContext); } } diff --git a/generator/src/test/java/io/wcm/devops/conga/generator/plugins/valueprovider/DummyMapValueProviderPlugin.java b/generator/src/test/java/io/wcm/devops/conga/generator/plugins/valueprovider/DummyMapValueProviderPlugin.java index 266f1ffe..8814197a 100644 --- a/generator/src/test/java/io/wcm/devops/conga/generator/plugins/valueprovider/DummyMapValueProviderPlugin.java +++ b/generator/src/test/java/io/wcm/devops/conga/generator/plugins/valueprovider/DummyMapValueProviderPlugin.java @@ -19,10 +19,10 @@ */ package io.wcm.devops.conga.generator.plugins.valueprovider; -import org.apache.commons.lang3.StringUtils; +import java.util.List; +import java.util.Map; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; +import org.apache.commons.lang3.StringUtils; import io.wcm.devops.conga.generator.spi.ValueProviderPlugin; import io.wcm.devops.conga.generator.spi.context.ValueProviderContext; @@ -45,10 +45,10 @@ public String getName() { @Override public Object resolve(String variableName, ValueProviderContext context) { if (StringUtils.equals(variableName, "map")) { - return ImmutableMap.of( + return Map.of( "param1", "value1", "param2", 5, - "listParam", ImmutableList.of("v1", "v2", "v3")); + "listParam", List.of("v1", "v2", "v3")); } else { return null; diff --git a/generator/src/test/java/io/wcm/devops/conga/generator/plugins/valueprovider/SystemPropertyValueProviderPluginTest.java b/generator/src/test/java/io/wcm/devops/conga/generator/plugins/valueprovider/SystemPropertyValueProviderPluginTest.java index e33f417a..c3b9e4a2 100644 --- a/generator/src/test/java/io/wcm/devops/conga/generator/plugins/valueprovider/SystemPropertyValueProviderPluginTest.java +++ b/generator/src/test/java/io/wcm/devops/conga/generator/plugins/valueprovider/SystemPropertyValueProviderPluginTest.java @@ -22,11 +22,11 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNull; +import java.util.List; + import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import com.google.common.collect.ImmutableList; - import io.wcm.devops.conga.generator.spi.ValueProviderPlugin; import io.wcm.devops.conga.generator.spi.context.PluginContextOptions; import io.wcm.devops.conga.generator.spi.context.ValueProviderContext; @@ -58,7 +58,7 @@ void testResolve() { System.setProperty(propertyName2, "value1,value2,value3"); assertEquals("value1", underTest.resolve(propertyName1, context)); - assertEquals(ImmutableList.of("value1", "value2", "value3"), underTest.resolve(propertyName2, context)); + assertEquals(List.of("value1", "value2", "value3"), underTest.resolve(propertyName2, context)); assertNull(underTest.resolve(propertyName3, context)); System.clearProperty(propertyName1); diff --git a/generator/src/test/java/io/wcm/devops/conga/generator/util/ConfigInheritanceResolverTest.java b/generator/src/test/java/io/wcm/devops/conga/generator/util/ConfigInheritanceResolverTest.java index baf479d5..277ece3c 100644 --- a/generator/src/test/java/io/wcm/devops/conga/generator/util/ConfigInheritanceResolverTest.java +++ b/generator/src/test/java/io/wcm/devops/conga/generator/util/ConfigInheritanceResolverTest.java @@ -21,10 +21,10 @@ import static org.junit.jupiter.api.Assertions.assertEquals; -import org.junit.jupiter.api.Test; +import java.util.List; +import java.util.Map; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; +import org.junit.jupiter.api.Test; import io.wcm.devops.conga.generator.util.testmodel.ConfScope1; import io.wcm.devops.conga.generator.util.testmodel.ConfScope2; @@ -61,46 +61,46 @@ void testResolve() { scope21.setScope31(scope31); scope21.setScope32(scope32); ConfScope2 scope22 = new ConfScope2(); - scope1.setScope2(ImmutableList.of(scope21, scope22)); + scope1.setScope2(List.of(scope21, scope22)); root.setScope1(scope1); SimpleConf simple1 = new SimpleConf(); - scope1.setMap(ImmutableMap.of("simple", simple1)); + scope1.setMap(Map.of("simple", simple1)); SampleNode sample = new SampleNode(); SimpleConf simple2 = new SimpleConf(); sample.setSimple(simple2); scope1.setSample(sample); - scope1.setConfig(ImmutableMap.of("conf", "s1")); + scope1.setConfig(Map.of("conf", "s1")); - scope21.setConfig(ImmutableMap.of("conf2", "s21")); + scope21.setConfig(Map.of("conf2", "s21")); - scope22.setConfig(ImmutableMap.of("conf", "s22")); + scope22.setConfig(Map.of("conf", "s22")); - scope31.setConfig(ImmutableMap.of("conf2", "s31")); + scope31.setConfig(Map.of("conf2", "s31")); - scope32.setConfig(ImmutableMap.of("conf3", "s32")); + scope32.setConfig(Map.of("conf3", "s32")); - simple1.setConfig(ImmutableMap.of("conf", "simple1")); + simple1.setConfig(Map.of("conf", "simple1")); - simple2.setConfig(ImmutableMap.of("conf2", "simple2")); + simple2.setConfig(Map.of("conf2", "simple2")); ConfigInheritanceResolver.resolve(root); - assertEquals(ImmutableMap.of("conf", "s1"), scope1.getConfig()); + assertEquals(Map.of("conf", "s1"), scope1.getConfig()); - assertEquals(ImmutableMap.of("conf", "s1", "conf2", "s21"), scope21.getConfig()); + assertEquals(Map.of("conf", "s1", "conf2", "s21"), scope21.getConfig()); - assertEquals(ImmutableMap.of("conf", "s22"), scope22.getConfig()); + assertEquals(Map.of("conf", "s22"), scope22.getConfig()); - assertEquals(ImmutableMap.of("conf", "s1", "conf2", "s31"), scope31.getConfig()); + assertEquals(Map.of("conf", "s1", "conf2", "s31"), scope31.getConfig()); - assertEquals(ImmutableMap.of("conf", "s1", "conf2", "s21", "conf3", "s32"), scope32.getConfig()); + assertEquals(Map.of("conf", "s1", "conf2", "s21", "conf3", "s32"), scope32.getConfig()); - assertEquals(ImmutableMap.of("conf", "simple1"), simple1.getConfig()); + assertEquals(Map.of("conf", "simple1"), simple1.getConfig()); - assertEquals(ImmutableMap.of("conf", "s1", "conf2", "simple2"), simple2.getConfig()); + assertEquals(Map.of("conf", "s1", "conf2", "simple2"), simple2.getConfig()); } } diff --git a/generator/src/test/java/io/wcm/devops/conga/generator/util/JexlResolverTest.java b/generator/src/test/java/io/wcm/devops/conga/generator/util/JexlResolverTest.java index 638b2670..e0c5aaa1 100644 --- a/generator/src/test/java/io/wcm/devops/conga/generator/util/JexlResolverTest.java +++ b/generator/src/test/java/io/wcm/devops/conga/generator/util/JexlResolverTest.java @@ -49,8 +49,8 @@ void setUp() { VariableMapResolver variableMapResolver = new VariableMapResolver(context); underTest = new JexlResolver(variableMapResolver); - object2 = ImmutableMap.of("var4", "value4"); - object1 = ImmutableMap.of("var3", "value3", "object2", object2, + object2 = Map.of("var4", "value4"); + object1 = Map.of("var3", "value3", "object2", object2, "nested1var1", "${nested1.nested1var1}", "nested2var1", "${nested1.nested2.nested2var1}"); variables = ImmutableMap.builder() @@ -61,10 +61,10 @@ void setUp() { .put("refVar2", "${var2}") .put("refCombined", "${object1.var3}|${var1}") .put("jexlExpr", "${object1.var3 + ';' + var1}") - .put("nested1", ImmutableMap.of( + .put("nested1", Map.of( "nested1var1", "nested1-value1", "nested1JexlExpr", "${object1.var3 + ';' + var1}", - "nested2", ImmutableMap.of( + "nested2", Map.of( "nested2var1", "nested2-value1", "nested2JexlExpr", "${object1.var3 + ';' + var1}"))) .put("array1", new String[] { "v1", "v2", "v3" }) diff --git a/generator/src/test/java/io/wcm/devops/conga/generator/util/ModelExportConfigProcessorTest.java b/generator/src/test/java/io/wcm/devops/conga/generator/util/ModelExportConfigProcessorTest.java index c27542b8..964578bc 100644 --- a/generator/src/test/java/io/wcm/devops/conga/generator/util/ModelExportConfigProcessorTest.java +++ b/generator/src/test/java/io/wcm/devops/conga/generator/util/ModelExportConfigProcessorTest.java @@ -24,6 +24,7 @@ import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.when; +import java.util.List; import java.util.Map; import java.util.Set; @@ -35,10 +36,6 @@ import org.mockito.junit.jupiter.MockitoExtension; import org.mockito.stubbing.Answer; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import com.google.common.collect.ImmutableSet; - import io.wcm.devops.conga.generator.spi.ValueEncryptionPlugin; import io.wcm.devops.conga.generator.spi.context.PluginContextOptions; import io.wcm.devops.conga.generator.spi.context.ValueEncryptionContext; @@ -46,7 +43,7 @@ @ExtendWith(MockitoExtension.class) class ModelExportConfigProcessorTest { - private static final Set SENSITIVE_PARAMS = ImmutableSet.of( + private static final Set SENSITIVE_PARAMS = Set.of( "param1", "group1.param3", "group1.group2.param4", @@ -67,7 +64,7 @@ class ModelExportConfigProcessorTest { @BeforeEach void setUp() { // simulate valueEncryptPlugin that prepends {enc} to the value - when(pluginManager.getAll(ValueEncryptionPlugin.class)).thenReturn(ImmutableList.of(valueEncryptPlugin)); + when(pluginManager.getAll(ValueEncryptionPlugin.class)).thenReturn(List.of(valueEncryptPlugin)); when(valueEncryptPlugin.isEnabled()).thenReturn(true); when(valueEncryptPlugin.encrypt(anyString(), any(), any(ValueEncryptionContext.class))).then(new Answer() { @Override @@ -84,21 +81,21 @@ public Object answer(InvocationOnMock invocation) throws Throwable { @Test void testNestedParams() { - Map config = ImmutableMap.of( + Map config = Map.of( "param1", "value1", "param2", "value2", - "group1", ImmutableMap.of( + "group1", Map.of( "param3", 123, - "group2", ImmutableMap.of( + "group2", Map.of( "param4", true, "param5", 5L))); - Map expected = ImmutableMap.of( + Map expected = Map.of( "param1", "{enc}value1", "param2", "value2", - "group1", ImmutableMap.of( + "group1", Map.of( "param3", "{enc}123", - "group2", ImmutableMap.of( + "group2", Map.of( "param4", "{enc}true", "param5", 5L))); @@ -107,29 +104,29 @@ void testNestedParams() { @Test void testList() { - Map config = ImmutableMap.of( - "list1", ImmutableList.of("value1", "value2"), - "list2", ImmutableList.of( - ImmutableMap.of( + Map config = Map.of( + "list1", List.of("value1", "value2"), + "list2", List.of( + Map.of( "param1", "value1a", "param2", 123, - "list3", ImmutableList.of( - ImmutableMap.of( + "list3", List.of( + Map.of( "param3", "value3"))), - ImmutableMap.of( + Map.of( "param1", "value1b", "param2", 345))); - Map expected = ImmutableMap.of( - "list1", ImmutableList.of("{enc}value1", "{enc}value2"), - "list2", ImmutableList.of( - ImmutableMap.of( + Map expected = Map.of( + "list1", List.of("{enc}value1", "{enc}value2"), + "list2", List.of( + Map.of( "param1", "{enc}value1a", "param2", 123, - "list3", ImmutableList.of( - ImmutableMap.of( + "list3", List.of( + Map.of( "param3", "{enc}value3"))), - ImmutableMap.of( + Map.of( "param1", "{enc}value1b", "param2", 345))); diff --git a/generator/src/test/java/io/wcm/devops/conga/generator/util/RoleUtilTest.java b/generator/src/test/java/io/wcm/devops/conga/generator/util/RoleUtilTest.java index 09856ddb..b9adb15e 100644 --- a/generator/src/test/java/io/wcm/devops/conga/generator/util/RoleUtilTest.java +++ b/generator/src/test/java/io/wcm/devops/conga/generator/util/RoleUtilTest.java @@ -25,6 +25,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; +import java.util.Arrays; import java.util.HashMap; import java.util.Iterator; import java.util.List; @@ -34,9 +35,6 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; - import io.wcm.devops.conga.generator.GeneratorException; import io.wcm.devops.conga.model.role.Role; import io.wcm.devops.conga.model.role.RoleFile; @@ -68,74 +66,74 @@ void setUp() throws Exception { Role role1 = new Role(); role1.setTemplateDir("role1Dir"); - role1.setConfig(ImmutableMap.of( + role1.setConfig(Map.of( "param1", "value1.1", "param2", 123, "param3", true)); - role1.setFiles(ImmutableList.of( + role1.setFiles(List.of( buildFile("role1", "file1.1"), buildFile("role1", "file1.2"), buildUrlFile("role1", "http://file1.3"))); - role1.setSensitiveConfigParameters(ImmutableList.of("param1")); + role1.setSensitiveConfigParameters(List.of("param1")); roleMap.put("role1", role1); Role role2 = new Role(); - role2.setVariants(ImmutableList.of( + role2.setVariants(List.of( buildVariant("variant1"), - buildVariant("variant2", ImmutableMap.of( + buildVariant("variant2", Map.of( "varparam1", "varvalue2.1", "varparam2", 888)))); role2.setTemplateDir("role2Dir"); - role2.setConfig(ImmutableMap.of( + role2.setConfig(Map.of( "param1", "value2.1", "param4", "value2.4")); - role2.setFiles(ImmutableList.of( + role2.setFiles(List.of( buildFile("role2", "file2.1", "variant1"), buildFile("role2", "file2.2", "variant2"), buildUrlFile("role2", "http://file2.3", "variant1"))); - role2.setInherits(ImmutableList.of( + role2.setInherits(List.of( buildInherit("role1"))); - role2.setSensitiveConfigParameters(ImmutableList.of("param2")); + role2.setSensitiveConfigParameters(List.of("param2")); roleMap.put("role2", role2); Role role3 = new Role(); - role3.setVariants(ImmutableList.of( + role3.setVariants(List.of( buildVariant("variant1"), - buildVariant("variant2", ImmutableMap.of( + buildVariant("variant2", Map.of( "varparam1", "varvalue3.1")), - buildVariant("variant3", ImmutableMap.of( + buildVariant("variant3", Map.of( "varparam1", "varvalue3.2")))); role3.setTemplateDir("role3Dir"); - role3.setConfig(ImmutableMap.of( + role3.setConfig(Map.of( "param1", "value3.1", "param5", "value3.5")); - role3.setFiles(ImmutableList.of( + role3.setFiles(List.of( buildFile("role3", "file3.1", "variant1"), buildFile("role3", "file3.2", "variant2"), buildUrlFile("role3", "http://file3.3", "variant2"), buildFile("role3", "file1.1"), buildUrlFile("role3", "http://file1.3"))); - role3.setInherits(ImmutableList.of( + role3.setInherits(List.of( buildInherit("role2"))); roleMap.put("role3", role3); Role role4 = new Role(); role4.setTemplateDir("role4Dir"); - role4.setConfig(ImmutableMap.of( + role4.setConfig(Map.of( "param1", "value4.1")); - role4.setFiles(ImmutableList.of( + role4.setFiles(List.of( buildFile("role4", "file4.1"))); - role4.setInherits(ImmutableList.of( + role4.setInherits(List.of( buildInherit("role2"))); roleMap.put("role4", role4); Role role5 = new Role(); role5.setTemplateDir("role5Dir"); - role5.setConfig(ImmutableMap.of( + role5.setConfig(Map.of( "param1", "value5.1")); - role5.setFiles(ImmutableList.of( + role5.setFiles(List.of( buildFile("role5", "file5.1"))); - role5.setInherits(ImmutableList.of( + role5.setInherits(List.of( buildInherit("role5"))); roleMap.put("role5", role5); } @@ -163,7 +161,7 @@ void testRole1() { assertFile(role, "role1", "file1.2"); assertUrlFile(role, "role1", "http://file1.3"); - assertEquals(ImmutableList.of("param1"), role.getSensitiveConfigParameters()); + assertEquals(List.of("param1"), role.getSensitiveConfigParameters()); } @Test @@ -192,11 +190,11 @@ void testRole2() { assertUrlFile(role2, "role2", "http://file2.3", "variant1"); assertVariant(role2, "variant1"); - assertVariant(role2, "variant2", ImmutableMap.of( + assertVariant(role2, "variant2", Map.of( "varparam1", "varvalue2.1", "varparam2", 888)); - assertEquals(ImmutableList.of("param1", "param2"), role2.getSensitiveConfigParameters()); + assertEquals(List.of("param1", "param2"), role2.getSensitiveConfigParameters()); } @Test @@ -232,18 +230,18 @@ void testRole3() { assertUrlFile(role3, "role3", "http://file1.3"); assertVariant(role2, "variant1"); - assertVariant(role2, "variant2", ImmutableMap.of( + assertVariant(role2, "variant2", Map.of( "varparam1", "varvalue3.1", "varparam2", 888)); assertVariant(role3, "variant1"); - assertVariant(role3, "variant2", ImmutableMap.of( + assertVariant(role3, "variant2", Map.of( "varparam1", "varvalue3.1", "varparam2", 888)); - assertVariant(role3, "variant3", ImmutableMap.of( + assertVariant(role3, "variant3", Map.of( "varparam1", "varvalue3.2")); - assertEquals(ImmutableList.of("param1", "param2"), role3.getSensitiveConfigParameters()); + assertEquals(List.of("param1", "param2"), role3.getSensitiveConfigParameters()); } @Test @@ -279,7 +277,7 @@ private RoleFile buildFile(String role, String name, String... variants) { file.setFile(name); file.setTemplate(role + "-" + name + ".hbs"); if (variants.length > 0) { - file.setVariants(ImmutableList.copyOf(variants)); + file.setVariants(Arrays.asList(variants)); } return file; } @@ -289,7 +287,7 @@ private RoleFile buildUrlFile(String role, String url, String... variants) { RoleFile file = new RoleFile(); file.setUrl(url); if (variants.length > 0) { - file.setVariants(ImmutableList.copyOf(variants)); + file.setVariants(Arrays.asList(variants)); } return file; } @@ -305,7 +303,7 @@ private void assertFile(Role role, String roleName, String file, String... varia for (RoleFile fileItem : role.getFiles()) { if (StringUtils.equals(file, fileItem.getFile()) && StringUtils.equals(template, fileItem.getTemplate()) - && ImmutableList.copyOf(variants).equals(fileItem.getVariants())) { + && Arrays.asList(variants).equals(fileItem.getVariants())) { // item found return; } @@ -329,7 +327,7 @@ private void assertNotFile(Role role, String roleName, String file, String... va private void assertUrlFile(Role role, String roleName, String url, String... variants) { for (RoleFile fileItem : role.getFiles()) { if (StringUtils.equals(url, fileItem.getUrl()) - && ImmutableList.copyOf(variants).equals(fileItem.getVariants())) { + && Arrays.asList(variants).equals(fileItem.getVariants())) { // item found return; } @@ -349,7 +347,7 @@ private void assertNotUrlFile(Role role, String roleName, String url, String... } private void assertVariant(Role role, String variant) { - assertVariant(role, variant, ImmutableMap.of()); + assertVariant(role, variant, Map.of()); } private void assertVariant(Role role, String variant, Map config) { @@ -365,21 +363,21 @@ private void assertVariant(Role role, String variant, Map config @Test void testMatchesRoleFile() { - assertTrue(RoleUtil.matchesRoleFile(roleFileVariants(ImmutableList.of()), ImmutableList.of())); - assertTrue(RoleUtil.matchesRoleFile(roleFileVariants(ImmutableList.of()), ImmutableList.of("v1"))); - assertTrue(RoleUtil.matchesRoleFile(roleFileVariants(ImmutableList.of()), ImmutableList.of("v1", "v2"))); - - assertTrue(RoleUtil.matchesRoleFile(roleFileVariants(ImmutableList.of("v1")), ImmutableList.of("v1", "v2"))); - assertTrue(RoleUtil.matchesRoleFile(roleFileVariants(ImmutableList.of("v1*")), ImmutableList.of("v1", "v2"))); - assertTrue(RoleUtil.matchesRoleFile(roleFileVariants(ImmutableList.of("v2")), ImmutableList.of("v1", "v2"))); - assertTrue(RoleUtil.matchesRoleFile(roleFileVariants(ImmutableList.of("v1", "v2")), ImmutableList.of("v1", "v2"))); - assertTrue(RoleUtil.matchesRoleFile(roleFileVariants(ImmutableList.of("v1", "v2")), ImmutableList.of("v2", "v3"))); - assertTrue(RoleUtil.matchesRoleFile(roleFileVariants(ImmutableList.of("v1", "v2*")), ImmutableList.of("v2", "v3"))); - assertTrue(RoleUtil.matchesRoleFile(roleFileVariants(ImmutableList.of("v1*", "v2*")), ImmutableList.of("v1", "v2", "v3"))); - - assertFalse(RoleUtil.matchesRoleFile(roleFileVariants(ImmutableList.of("v1")), ImmutableList.of())); - assertFalse(RoleUtil.matchesRoleFile(roleFileVariants(ImmutableList.of("v1")), ImmutableList.of("v2"))); - assertFalse(RoleUtil.matchesRoleFile(roleFileVariants(ImmutableList.of("v1*", "v2*")), ImmutableList.of("v2", "v3"))); + assertTrue(RoleUtil.matchesRoleFile(roleFileVariants(List.of()), List.of())); + assertTrue(RoleUtil.matchesRoleFile(roleFileVariants(List.of()), List.of("v1"))); + assertTrue(RoleUtil.matchesRoleFile(roleFileVariants(List.of()), List.of("v1", "v2"))); + + assertTrue(RoleUtil.matchesRoleFile(roleFileVariants(List.of("v1")), List.of("v1", "v2"))); + assertTrue(RoleUtil.matchesRoleFile(roleFileVariants(List.of("v1*")), List.of("v1", "v2"))); + assertTrue(RoleUtil.matchesRoleFile(roleFileVariants(List.of("v2")), List.of("v1", "v2"))); + assertTrue(RoleUtil.matchesRoleFile(roleFileVariants(List.of("v1", "v2")), List.of("v1", "v2"))); + assertTrue(RoleUtil.matchesRoleFile(roleFileVariants(List.of("v1", "v2")), List.of("v2", "v3"))); + assertTrue(RoleUtil.matchesRoleFile(roleFileVariants(List.of("v1", "v2*")), List.of("v2", "v3"))); + assertTrue(RoleUtil.matchesRoleFile(roleFileVariants(List.of("v1*", "v2*")), List.of("v1", "v2", "v3"))); + + assertFalse(RoleUtil.matchesRoleFile(roleFileVariants(List.of("v1")), List.of())); + assertFalse(RoleUtil.matchesRoleFile(roleFileVariants(List.of("v1")), List.of("v2"))); + assertFalse(RoleUtil.matchesRoleFile(roleFileVariants(List.of("v1*", "v2*")), List.of("v2", "v3"))); } private RoleFile roleFileVariants(List variants) { diff --git a/generator/src/test/java/io/wcm/devops/conga/generator/util/ValueUtilTest.java b/generator/src/test/java/io/wcm/devops/conga/generator/util/ValueUtilTest.java index c749beaa..7775f4fb 100644 --- a/generator/src/test/java/io/wcm/devops/conga/generator/util/ValueUtilTest.java +++ b/generator/src/test/java/io/wcm/devops/conga/generator/util/ValueUtilTest.java @@ -24,10 +24,10 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNull; -import org.junit.jupiter.api.Test; +import java.util.List; +import java.util.Map; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; +import org.junit.jupiter.api.Test; class ValueUtilTest { @@ -45,8 +45,8 @@ void stringToValue_string() { @Test void stringToValue_stringList() { - assertEquals(ImmutableList.of("abc", "def", "ghi"), stringToValue("abc,def,ghi")); - assertEquals(ImmutableList.of("abc", " def", " ghi"), stringToValue("abc, def, ghi")); + assertEquals(List.of("abc", "def", "ghi"), stringToValue("abc,def,ghi")); + assertEquals(List.of("abc", " def", " ghi"), stringToValue("abc, def, ghi")); } @Test @@ -58,7 +58,7 @@ void stringToValue_integer() { @Test void stringToValue_integerList() { - assertEquals(ImmutableList.of(0, 123456, -5000), stringToValue("0,123456,-5000")); + assertEquals(List.of(0, 123456, -5000), stringToValue("0,123456,-5000")); } @Test @@ -68,7 +68,7 @@ void stringToValue_long() { @Test void stringToValue_longList() { - assertEquals(ImmutableList.of(0, 123456, 1234567890123456L), stringToValue("0,123456,1234567890123456")); + assertEquals(List.of(0, 123456, 1234567890123456L), stringToValue("0,123456,1234567890123456")); } @Test @@ -90,12 +90,12 @@ void stringToValue_boolean() { @Test void stringToValue_booleanList() { - assertEquals(ImmutableList.of(true, false), stringToValue("true,false")); + assertEquals(List.of(true, false), stringToValue("true,false")); } @Test void stringToValue_mixed() { - assertEquals(ImmutableList.of("abc", 123, true), stringToValue("abc,123,true")); + assertEquals(List.of("abc", 123, true), stringToValue("abc,123,true")); } @Test @@ -114,12 +114,12 @@ void valueToString_primitives() { @Test void valueToString_list() { - assertEquals("abc,123,1.23,true", valueToString(ImmutableList.of("abc", 123, 1.23, true))); + assertEquals("abc,123,1.23,true", valueToString(List.of("abc", 123, 1.23, true))); } @Test void valueToString_map() { - assertEquals("prop1=abc,prop2=123", valueToString(ImmutableMap.of("prop1", "abc", "prop2", 123))); + assertEquals("prop1=abc,prop2=123", valueToString(Map.of("prop1", "abc", "prop2", 123))); } } diff --git a/generator/src/test/java/io/wcm/devops/conga/generator/util/VariableMapResolverTest.java b/generator/src/test/java/io/wcm/devops/conga/generator/util/VariableMapResolverTest.java index b58dc87d..06f1f885 100644 --- a/generator/src/test/java/io/wcm/devops/conga/generator/util/VariableMapResolverTest.java +++ b/generator/src/test/java/io/wcm/devops/conga/generator/util/VariableMapResolverTest.java @@ -24,14 +24,12 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; +import java.util.List; import java.util.Map; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; - import io.wcm.devops.conga.generator.spi.context.PluginContextOptions; import io.wcm.devops.conga.generator.spi.context.ValueProviderGlobalContext; @@ -50,25 +48,25 @@ void setUp() { @Test void testSimple() { - Map map = ImmutableMap.of("var1", "v1", "var2", 2, + Map map = Map.of("var1", "v1", "var2", 2, "key1", "The ${var1} and ${var2}"); - assertEquals(ImmutableMap.of("var1", "v1", "var2", 2, + assertEquals(Map.of("var1", "v1", "var2", 2, "key1", "The v1 and 2"), underTest.resolve(map)); } @Test void testNested() { - Map map = ImmutableMap.of("var1", "v1", "var2", "${var1}v2", "var3", "${var1}${var2}v3", + Map map = Map.of("var1", "v1", "var2", "${var1}v2", "var3", "${var1}${var2}v3", "key1", "The ${var1} and ${var2} and ${var3}"); - assertEquals(ImmutableMap.of("var1", "v1", "var2", "v1v2", "var3", "v1v1v2v3", + assertEquals(Map.of("var1", "v1", "var2", "v1v2", "var3", "v1v1v2v3", "key1", "The v1 and v1v2 and v1v1v2v3"), underTest.resolve(map)); } @Test void testNestedCyclicReference() { - Map map = ImmutableMap.of("var1", "${var2}", "var2", "${var1}"); + Map map = Map.of("var1", "${var2}", "var2", "${var1}"); assertThrows(IllegalArgumentException.class, () -> { underTest.resolve(map); @@ -77,7 +75,7 @@ void testNestedCyclicReference() { @Test void testUnknownVariables() { - Map map = ImmutableMap.of("key1", "The ${var1} and ${var2}"); + Map map = Map.of("key1", "The ${var1} and ${var2}"); assertThrows(IllegalArgumentException.class, () -> { underTest.resolve(map); @@ -86,89 +84,89 @@ void testUnknownVariables() { @Test void testNestedMap() { - Map map = ImmutableMap.of("var1", "v1", - "var2", ImmutableMap.of("var21", "v21", "var22", ImmutableMap.of("var221", "${var1}${var2.var21}")), + Map map = Map.of("var1", "v1", + "var2", Map.of("var21", "v21", "var22", Map.of("var221", "${var1}${var2.var21}")), "key1", "The ${var1} and ${var2.var22.var221}"); - assertEquals(ImmutableMap.of("var1", "v1", - "var2", ImmutableMap.of("var21", "v21", "var22", ImmutableMap.of("var221", "v1v21")), + assertEquals(Map.of("var1", "v1", + "var2", Map.of("var21", "v21", "var22", Map.of("var221", "v1v21")), "key1", "The v1 and v1v21"), underTest.resolve(map)); } @Test void testNestedList() { - Map map = ImmutableMap.of("var1", "v1", - "var2", ImmutableList.of("v21", ImmutableMap.of("var221", "${var1}")), + Map map = Map.of("var1", "v1", + "var2", List.of("v21", Map.of("var221", "${var1}")), "key1", "The ${var1} and ${var2}"); - assertEquals(ImmutableMap.of("var1", "v1", - "var2", ImmutableList.of("v21", ImmutableMap.of("var221", "v1")), + assertEquals(Map.of("var1", "v1", + "var2", List.of("v21", Map.of("var221", "v1")), "key1", "The v1 and v21,var221=v1"), underTest.resolve(map)); } @Test void testNestedWithEscapedVariable() { - Map map = ImmutableMap.of("var1", "\\${novar}", "var2", "${var1}v2", "var3", "${var1}${var2}v3", + Map map = Map.of("var1", "\\${novar}", "var2", "${var1}v2", "var3", "${var1}${var2}v3", "key1", "The ${var1} and ${var2} and ${var3}"); - assertEquals(ImmutableMap.of("var1", "${novar}", "var2", "${novar}v2", "var3", "${novar}${novar}v2v3", + assertEquals(Map.of("var1", "${novar}", "var2", "${novar}v2", "var3", "${novar}${novar}v2v3", "key1", "The ${novar} and ${novar}v2 and ${novar}${novar}v2v3"), underTest.resolve(map)); } @Test void testIterateDirect() { - Map map = ImmutableMap.of( + Map map = Map.of( "var1", "value1", - "object1", ImmutableMap.of( - LIST_VARIABLE_ITERATE, ImmutableList.of("item1", "item2", "item3"), + "object1", Map.of( + LIST_VARIABLE_ITERATE, List.of("item1", "item2", "item3"), "item", "${" + ITEM_VARIABLE + "}", "refvar1", "${var1}")); - assertEquals(ImmutableMap.of( + assertEquals(Map.of( "var1", "value1", - "object1", ImmutableList.of( - ImmutableMap.of("item", "item1", "refvar1", "value1"), - ImmutableMap.of("item", "item2", "refvar1", "value1"), - ImmutableMap.of("item", "item3", "refvar1", "value1"))), + "object1", List.of( + Map.of("item", "item1", "refvar1", "value1"), + Map.of("item", "item2", "refvar1", "value1"), + Map.of("item", "item3", "refvar1", "value1"))), underTest.resolve(map)); } @Test void testIterateVariable() { - Map map = ImmutableMap.of( + Map map = Map.of( "var1", "value1", - "listholder", ImmutableList.of( - ImmutableMap.of("name", "item1", "var2", "value21"), - ImmutableMap.of("name", "item2", "var2", "value22"), - ImmutableMap.of("name", "item3", "var2", "value23")), - "object1", ImmutableMap.of( + "listholder", List.of( + Map.of("name", "item1", "var2", "value21"), + Map.of("name", "item2", "var2", "value22"), + Map.of("name", "item3", "var2", "value23")), + "object1", Map.of( LIST_VARIABLE_ITERATE, "${listholder}", "item", "${" + ITEM_VARIABLE + ".name}", "refvar1", "${var1}", "refvar2", "${" + ITEM_VARIABLE + ".var2}")); - assertEquals(ImmutableMap.of( + assertEquals(Map.of( "var1", "value1", - "listholder", ImmutableList.of( - ImmutableMap.of("name", "item1", "var2", "value21"), - ImmutableMap.of("name", "item2", "var2", "value22"), - ImmutableMap.of("name", "item3", "var2", "value23")), - "object1", ImmutableList.of( - ImmutableMap.of("item", "item1", "refvar1", "value1", "refvar2", "value21"), - ImmutableMap.of("item", "item2", "refvar1", "value1", "refvar2", "value22"), - ImmutableMap.of("item", "item3", "refvar1", "value1", "refvar2", "value23"))), + "listholder", List.of( + Map.of("name", "item1", "var2", "value21"), + Map.of("name", "item2", "var2", "value22"), + Map.of("name", "item3", "var2", "value23")), + "object1", List.of( + Map.of("item", "item1", "refvar1", "value1", "refvar2", "value21"), + Map.of("item", "item2", "refvar1", "value1", "refvar2", "value22"), + Map.of("item", "item3", "refvar1", "value1", "refvar2", "value23"))), underTest.resolve(map)); } @Test void testIterateSingleValue() { - Map map = ImmutableMap.of( + Map map = Map.of( "var1", "value1", - "object1", ImmutableMap.of(LIST_VARIABLE_ITERATE, "${var1}", + "object1", Map.of(LIST_VARIABLE_ITERATE, "${var1}", "item", "${" + ITEM_VARIABLE + "}")); - assertEquals(ImmutableMap.of( + assertEquals(Map.of( "var1", "value1", - "object1", ImmutableList.of(ImmutableMap.of("item", "value1"))), + "object1", List.of(Map.of("item", "value1"))), underTest.resolve(map)); } diff --git a/generator/src/test/java/io/wcm/devops/conga/generator/util/VariableObjectTreeResolverTest.java b/generator/src/test/java/io/wcm/devops/conga/generator/util/VariableObjectTreeResolverTest.java index 7fd771b7..6c3c8627 100644 --- a/generator/src/test/java/io/wcm/devops/conga/generator/util/VariableObjectTreeResolverTest.java +++ b/generator/src/test/java/io/wcm/devops/conga/generator/util/VariableObjectTreeResolverTest.java @@ -22,14 +22,12 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import java.util.HashMap; +import java.util.List; import java.util.Map; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; - import io.wcm.devops.conga.generator.ContextPropertiesBuilder; import io.wcm.devops.conga.generator.spi.context.PluginContextOptions; import io.wcm.devops.conga.generator.spi.context.ValueProviderGlobalContext; @@ -79,46 +77,46 @@ void testResolve() { scope21.setScope31(scope31); scope21.setScope32(scope32); ConfScope2 scope22 = new ConfScope2(); - scope1.setScope2(ImmutableList.of(scope21, scope22)); + scope1.setScope2(List.of(scope21, scope22)); root.setScope1(scope1); SimpleConf simple1 = new SimpleConf(); - scope1.setMap(ImmutableMap.of("simple", simple1)); + scope1.setMap(Map.of("simple", simple1)); SampleNode sample = new SampleNode(); SimpleConf simple2 = new SimpleConf(); sample.setSimple(simple2); scope1.setSample(sample); - scope1.setConfig(ImmutableMap.of("var1", "v1", "conf", "${var1}")); + scope1.setConfig(Map.of("var1", "v1", "conf", "${var1}")); - scope21.setConfig(ImmutableMap.of("var21", "v21", "conf21", "${var21}")); + scope21.setConfig(Map.of("var21", "v21", "conf21", "${var21}")); - scope22.setConfig(ImmutableMap.of("var22", "v22", "conf22", "${var22}")); + scope22.setConfig(Map.of("var22", "v22", "conf22", "${var22}")); - scope31.setConfig(ImmutableMap.of("var31", "v31", "conf31", "${var31}")); + scope31.setConfig(Map.of("var31", "v31", "conf31", "${var31}")); - scope32.setConfig(ImmutableMap.of("var32", "v32", "conf32", "${var32}")); + scope32.setConfig(Map.of("var32", "v32", "conf32", "${var32}")); - simple1.setConfig(ImmutableMap.of("varS1", "vS1", "confS1", "${varS1}")); + simple1.setConfig(Map.of("varS1", "vS1", "confS1", "${varS1}")); - simple2.setConfig(ImmutableMap.of("varS2", "vS2", "confS2", "${varS2}")); + simple2.setConfig(Map.of("varS2", "vS2", "confS2", "${varS2}")); underTest.resolve(root); - assertMap(ImmutableMap.of("var1", "v1", "conf", "v1"), scope1.getConfig()); + assertMap(Map.of("var1", "v1", "conf", "v1"), scope1.getConfig()); - assertMap(ImmutableMap.of("var21", "v21", "conf21", "v21"), scope21.getConfig()); + assertMap(Map.of("var21", "v21", "conf21", "v21"), scope21.getConfig()); - assertMap(ImmutableMap.of("var22", "v22", "conf22", "v22"), scope22.getConfig()); + assertMap(Map.of("var22", "v22", "conf22", "v22"), scope22.getConfig()); - assertMap(ImmutableMap.of("var31", "v31", "conf31", "v31"), scope31.getConfig()); + assertMap(Map.of("var31", "v31", "conf31", "v31"), scope31.getConfig()); - assertMap(ImmutableMap.of("var32", "v32", "conf32", "v32"), scope32.getConfig()); + assertMap(Map.of("var32", "v32", "conf32", "v32"), scope32.getConfig()); - assertMap(ImmutableMap.of("varS1", "vS1", "confS1", "vS1"), simple1.getConfig()); + assertMap(Map.of("varS1", "vS1", "confS1", "vS1"), simple1.getConfig()); - assertMap(ImmutableMap.of("varS2", "vS2", "confS2", "vS2"), simple2.getConfig()); + assertMap(Map.of("varS2", "vS2", "confS2", "vS2"), simple2.getConfig()); } private void assertMap(Map expected, Map actual) { diff --git a/generator/src/test/java/io/wcm/devops/conga/generator/util/VariableStringResolverExpressionTest.java b/generator/src/test/java/io/wcm/devops/conga/generator/util/VariableStringResolverExpressionTest.java index 9dc25b90..18fd97b2 100644 --- a/generator/src/test/java/io/wcm/devops/conga/generator/util/VariableStringResolverExpressionTest.java +++ b/generator/src/test/java/io/wcm/devops/conga/generator/util/VariableStringResolverExpressionTest.java @@ -22,14 +22,12 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; +import java.util.List; import java.util.Map; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; - import io.wcm.devops.conga.generator.spi.context.PluginContextOptions; import io.wcm.devops.conga.generator.spi.context.ValueProviderGlobalContext; @@ -54,28 +52,28 @@ void setUp() { @Test void testSimple() { - Map variables = ImmutableMap.of("var1", "v1", "var2", "v2"); + Map variables = Map.of("var1", "v1", "var2", "v2"); assertEquals("The v1 and v2", underTest.resolve("The ${ var1 + ' and ' + var2 }", variables)); } @Test void testSingleVariableWithObject() { - Map variables = ImmutableMap.of("var1", ImmutableList.of("v1", "v2")); + Map variables = Map.of("var1", List.of("v1", "v2")); - assertEquals(ImmutableList.of("v1", "v2"), underTest.resolve("${ var1 }", variables)); + assertEquals(List.of("v1", "v2"), underTest.resolve("${ var1 }", variables)); } @Test void testNestedVariables() { - Map variables = ImmutableMap.of("var1", "v1", "var2", "${var1 + var1}", "var3", "${var2 + var1}"); + Map variables = Map.of("var1", "v1", "var2", "${var1 + var1}", "var3", "${var2 + var1}"); assertEquals("v1,v1v1,v1v1v1", underTest.resolve("${var1},${var2},${var3}", variables)); } @Test void testNestedVariables_IllegalRecursion() { - Map variables = ImmutableMap.of("var1", "${ var2 }", "var2", "${ var1 }"); + Map variables = Map.of("var1", "${ var2 }", "var2", "${ var1 }"); assertThrows(IllegalArgumentException.class, () -> { underTest.resolve("${var1}", variables); @@ -84,7 +82,7 @@ void testNestedVariables_IllegalRecursion() { @Test void testUnknownVariable() { - Map variables = ImmutableMap.of(); + Map variables = Map.of(); assertThrows(IllegalArgumentException.class, () -> { underTest.resolve("${var1}", variables); @@ -93,7 +91,7 @@ void testUnknownVariable() { @Test void testEscapedVariables() { - Map variables = ImmutableMap.of("var1", "v1", "var2", "\\${ var1 }${ var1 }", "var3", "${ var2 }${ var1 }"); + Map variables = Map.of("var1", "v1", "var2", "\\${ var1 }${ var1 }", "var3", "${ var2 }${ var1 }"); assertEquals("${ var1 },${ var1 }v1,${ var1 }v1v1", underTest.resolve("\\${ var1 },${ var2 },${ var3 }", variables)); assertEquals("\\${ var1 },\\${ var1 }v1,\\${ var1 }v1v1", underTest.resolve("\\${ var1 },${ var2 },${ var3 }", variables, false)); @@ -102,28 +100,28 @@ void testEscapedVariables() { @Test void testDeepMapVariable() { - Map variables = ImmutableMap.of("var1", ImmutableMap.of("k1", "v1", "k2", ImmutableMap.of("k21", "v21", "k22", "v22"))); + Map variables = Map.of("var1", Map.of("k1", "v1", "k2", Map.of("k21", "v21", "k22", "v22"))); assertEquals("The v1 and v21", underTest.resolve("The ${var1.k1 + ' and ' + var1.k2.k21}", variables)); } @Test void testListVariable() { - Map variables = ImmutableMap.of("var1", ImmutableList.of("v1", "v2", ImmutableList.of("v31", "v32"))); + Map variables = Map.of("var1", List.of("v1", "v2", List.of("v31", "v32"))); assertEquals("The v1,v2,v31,v32", underTest.resolve("The ${ var1 }", variables)); } @Test void testListVariable_StringJoin() { - Map variables = ImmutableMap.of("var1", ImmutableList.of("v1", "v2", "v3")); + Map variables = Map.of("var1", List.of("v1", "v2", "v3")); assertEquals("The v1 v2 v3", underTest.resolve("The ${new('java.lang.String').join(' ',var1)}", variables)); } @Test void testMapVariable() { - Map variables = ImmutableMap.of("var1", ImmutableMap.of("k1", "v1", "k2", ImmutableMap.of("k21", "v21", "k22", "v22"))); + Map variables = Map.of("var1", Map.of("k1", "v1", "k2", Map.of("k21", "v21", "k22", "v22"))); assertEquals("The k1=v1,k2=k21=v21,k22=v22", underTest.resolve("The ${ var1 }", variables)); } diff --git a/generator/src/test/java/io/wcm/devops/conga/generator/util/VariableStringResolverTest.java b/generator/src/test/java/io/wcm/devops/conga/generator/util/VariableStringResolverTest.java index 605ccd61..c2e57342 100644 --- a/generator/src/test/java/io/wcm/devops/conga/generator/util/VariableStringResolverTest.java +++ b/generator/src/test/java/io/wcm/devops/conga/generator/util/VariableStringResolverTest.java @@ -24,14 +24,12 @@ import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; +import java.util.List; import java.util.Map; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; - import io.wcm.devops.conga.generator.spi.context.PluginContextOptions; import io.wcm.devops.conga.generator.spi.context.ValueProviderGlobalContext; @@ -55,41 +53,41 @@ void setUp() { @Test void testSimple() { - Map variables = ImmutableMap.of("var1", "v1", "var2", "v2"); + Map variables = Map.of("var1", "v1", "var2", "v2"); assertEquals("The v1 and v2", underTest.resolve("The ${var1} and ${var2}", variables)); } @Test void testSingleVariableWithObject() { - Map variables = ImmutableMap.of("var1", ImmutableList.of("v1", "v2")); + Map variables = Map.of("var1", List.of("v1", "v2")); - assertEquals(ImmutableList.of("v1", "v2"), underTest.resolve("${var1}", variables)); + assertEquals(List.of("v1", "v2"), underTest.resolve("${var1}", variables)); } @Test void testDefaultValue() { - Map variables = ImmutableMap.of("var1", "v1"); + Map variables = Map.of("var1", "v1"); assertEquals("The v1 and theDefValue2", underTest.resolve("The ${var1:theDefValue1} and ${var2:theDefValue2}", variables)); } @Test void testDefaultEmptyValue() { - Map variables = ImmutableMap.of("var1", "v1"); + Map variables = Map.of("var1", "v1"); assertEquals("The empty value: ''", underTest.resolve("The empty value: '${var2:}'", variables)); } @Test void testNestedVariables() { - Map variables = ImmutableMap.of("var1", "v1", "var2", "${var1}${var1}", "var3", "${var2}${var1}"); + Map variables = Map.of("var1", "v1", "var2", "${var1}${var1}", "var3", "${var2}${var1}"); assertEquals("v1,v1v1,v1v1v1", underTest.resolve("${var1},${var2},${var3}", variables)); } @Test void testNestedVariables_IllegalRecursion() { - Map variables = ImmutableMap.of("var1", "${var2}", "var2", "${var1}"); + Map variables = Map.of("var1", "${var2}", "var2", "${var1}"); assertThrows(IllegalArgumentException.class, () -> { underTest.resolve("${var1}", variables); @@ -98,7 +96,7 @@ void testNestedVariables_IllegalRecursion() { @Test void testUnknownVariable() { - Map variables = ImmutableMap.of(); + Map variables = Map.of(); assertThrows(IllegalArgumentException.class, () -> { underTest.resolve("${var1}", variables); @@ -107,7 +105,7 @@ void testUnknownVariable() { @Test void testEscapedVariables() { - Map variables = ImmutableMap.of("var1", "v1", "var2", "\\${var1}${var1}", "var3", "${var2}${var1}"); + Map variables = Map.of("var1", "v1", "var2", "\\${var1}${var1}", "var3", "${var2}${var1}"); assertEquals("${var1},${var1}v1,${var1}v1v1", underTest.resolve("\\${var1},${var2},${var3}", variables)); assertEquals("\\${var1},\\${var1}v1,\\${var1}v1v1", underTest.resolve("\\${var1},${var2},${var3}", variables, false)); @@ -116,7 +114,7 @@ void testEscapedVariables() { @Test void testEscapedVariables_Provider_DefValue() { - Map variables = ImmutableMap.of("var1", "v1", "var2", "\\${var1}${var1}", "var3", "${var2}${var1}"); + Map variables = Map.of("var1", "v1", "var2", "\\${var1}${var1}", "var3", "${var2}${var1}"); assertEquals("\\${provider::var1},\\${var2:defValue},\\${provider::var3:defValue}", underTest.resolve("\\${provider::var1},\\${var2:defValue},\\${provider::var3:defValue}", variables, false)); @@ -126,21 +124,21 @@ void testEscapedVariables_Provider_DefValue() { @Test void testDeepMapVariable() { - Map variables = ImmutableMap.of("var1", ImmutableMap.of("k1", "v1", "k2", ImmutableMap.of("k21", "v21", "k22", "v22"))); + Map variables = Map.of("var1", Map.of("k1", "v1", "k2", Map.of("k21", "v21", "k22", "v22"))); assertEquals("The v1 and v21", underTest.resolve("The ${var1.k1} and ${var1.k2.k21}", variables)); } @Test void testListVariable() { - Map variables = ImmutableMap.of("var1", ImmutableList.of("v1", "v2", ImmutableList.of("v31", "v32"))); + Map variables = Map.of("var1", List.of("v1", "v2", List.of("v31", "v32"))); assertEquals("The v1,v2,v31,v32", underTest.resolve("The ${var1}", variables)); } @Test void testMapVariable() { - Map variables = ImmutableMap.of("var1", ImmutableMap.of("k1", "v1", "k2", ImmutableMap.of("k21", "v21", "k22", "v22"))); + Map variables = Map.of("var1", Map.of("k1", "v1", "k2", Map.of("k21", "v21", "k22", "v22"))); assertEquals("The k1=v1,k2=k21=v21,k22=v22", underTest.resolve("The ${var1}", variables)); } @@ -151,7 +149,7 @@ void testValueProvider() { String propertyName2 = getClass().getName() + "-test.prop2"; System.setProperty(propertyName1, "value1"); - Map variables = ImmutableMap.of("var1", "v1"); + Map variables = Map.of("var1", "v1"); assertEquals("The v1 and value1", underTest.resolve("The ${var1} and ${system::" + propertyName1 + "}", variables)); assertEquals("The v1 and theDefValue", underTest.resolve("The ${var1} and ${system::" + propertyName2 + ":theDefValue}", variables)); @@ -164,13 +162,13 @@ void testValueProvider() { void testCustomValueProvider() { // define value provider name 'customProvider' of type 'system' globalContext.getPluginContextOptions() - .valueProviderConfig(ImmutableMap.of("customProvider", ImmutableMap.of(ValueProviderGlobalContext.PARAM_PLUGIN_NAME, "system"))); + .valueProviderConfig(Map.of("customProvider", Map.of(ValueProviderGlobalContext.PARAM_PLUGIN_NAME, "system"))); String propertyName1 = getClass().getName() + "-test.propCustom1"; String propertyName2 = getClass().getName() + "-test.propCustom2"; System.setProperty(propertyName1, "value1"); - Map variables = ImmutableMap.of("var1", "v1"); + Map variables = Map.of("var1", "v1"); assertEquals("The v1 and value1", underTest.resolve("The ${var1} and ${customProvider::" + propertyName1 + "}", variables)); assertEquals("The v1 and theDefValue", underTest.resolve("The ${var1} and ${customProvider::" + propertyName2 + ":theDefValue}", variables)); @@ -185,7 +183,7 @@ void testCustomValueProvider() { @Test void testDummyMapValueProvider() { - Map variables = ImmutableMap.of("var1", "v1"); + Map variables = Map.of("var1", "v1"); assertEquals("The v1 and value1 and 5", underTest.resolve("The ${var1} and ${dummy-map::map.param1} and ${dummy-map::map.param2}", variables)); assertEquals("The v1 and theDefValue", underTest.resolve("The ${var1} and ${dummy-map::map.paramNotDefined:theDefValue}", variables)); @@ -193,7 +191,7 @@ void testDummyMapValueProvider() { @Test void testDummyMapValueProvider_ListReturnValue() { - assertEquals(ImmutableList.of("v1", "v2", "v3"), underTest.resolve("${dummy-map::map.listParam}", ImmutableMap.of())); + assertEquals(List.of("v1", "v2", "v3"), underTest.resolve("${dummy-map::map.listParam}", Map.of())); } @Test diff --git a/model/src/test/java/io/wcm/devops/conga/model/reader/EnvironmentReaderTest.java b/model/src/test/java/io/wcm/devops/conga/model/reader/EnvironmentReaderTest.java index 0e1428ee..004b2b3b 100644 --- a/model/src/test/java/io/wcm/devops/conga/model/reader/EnvironmentReaderTest.java +++ b/model/src/test/java/io/wcm/devops/conga/model/reader/EnvironmentReaderTest.java @@ -26,15 +26,13 @@ import java.io.IOException; import java.io.InputStream; +import java.util.List; import java.util.Map; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.yaml.snakeyaml.constructor.ConstructorException; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; - import io.wcm.devops.conga.model.environment.Environment; import io.wcm.devops.conga.model.environment.Node; import io.wcm.devops.conga.model.environment.NodeRole; @@ -60,10 +58,10 @@ public void testEnvironment() { assertEquals(1, environment.getRoleConfig().size()); assertEquals(2, environment.getTenants().size()); - assertEquals(ImmutableMap.of( + assertEquals(Map.of( "topologyConnectorPath", "/connector", - "jvm", ImmutableMap.of("heapspace", ImmutableMap.of("max", "4096m")), - "topologyConnectors", ImmutableList.of("http://host1${topologyConnectorPath}", "http://host2${topologyConnectorPath}") + "jvm", Map.of("heapspace", Map.of("max", "4096m")), + "topologyConnectors", List.of("http://host1${topologyConnectorPath}", "http://host2${topologyConnectorPath}") ), environment.getConfig()); } @@ -73,8 +71,8 @@ public void testNode() { assertEquals("importer", node.getNode()); - assertEquals(ImmutableMap.of("topologyConnectorPath", "/specialConnector", - "jvm", ImmutableMap.of("heapspace", ImmutableMap.of("max", "2048m"))), node.getConfig()); + assertEquals(Map.of("topologyConnectorPath", "/specialConnector", + "jvm", Map.of("heapspace", Map.of("max", "2048m"))), node.getConfig()); assertEquals(2, node.getRoles().size()); } @@ -82,7 +80,7 @@ public void testNode() { @Test public void testMultiNode() { Node node = environment.getNodes().get(1); - assertEquals(ImmutableList.of("services-1", "services-2"), node.getNodes()); + assertEquals(List.of("services-1", "services-2"), node.getNodes()); assertEquals(1, node.getRoles().size()); } @@ -91,13 +89,13 @@ public void testNodeRole() { NodeRole role1 = environment.getNodes().get(0).getRoles().get(0); assertEquals("tomcat-services", role1.getRole()); assertEquals("importer", role1.getVariant()); - assertEquals(ImmutableList.of("importer"), role1.getAggregatedVariants()); - assertEquals(ImmutableMap.of("topologyConnectors", ImmutableList.of("http://host3${topologyConnectorPath}")), role1.getConfig()); + assertEquals(List.of("importer"), role1.getAggregatedVariants()); + assertEquals(Map.of("topologyConnectors", List.of("http://host3${topologyConnectorPath}")), role1.getConfig()); NodeRole role2 = environment.getNodes().get(0).getRoles().get(1); assertEquals("tomcat-backendconnector", role2.getRole()); - assertEquals(ImmutableList.of("var1", "var2"), role2.getVariants()); - assertEquals(ImmutableList.of("var1", "var2"), role2.getAggregatedVariants()); + assertEquals(List.of("var1", "var2"), role2.getVariants()); + assertEquals(List.of("var1", "var2"), role2.getAggregatedVariants()); } @Test @@ -106,7 +104,7 @@ public void testRoleConfig() { assertEquals("tomcat-backendconnector", roleConfig.getRole()); - assertEquals(ImmutableMap.of("jvm", ImmutableMap.of("heapspace", ImmutableMap.of("max", "1024m"))), roleConfig.getConfig()); + assertEquals(Map.of("jvm", Map.of("heapspace", Map.of("max", "1024m"))), roleConfig.getConfig()); } @Test @@ -115,8 +113,8 @@ public void testTenant() { assertEquals("tenant1", tenant.getTenant()); - assertEquals(ImmutableList.of("website", "application"), tenant.getRoles()); - assertEquals(ImmutableMap.of("domain", "mysite.de", "website", ImmutableMap.of("hostname", "www.${domain}")), tenant.getConfig()); + assertEquals(List.of("website", "application"), tenant.getRoles()); + assertEquals(Map.of("domain", "mysite.de", "website", Map.of("hostname", "www.${domain}")), tenant.getConfig()); } @Test @@ -131,7 +129,7 @@ public void testEnvironmentWithNullTenant() { @Test public void testDependencies() { - assertEquals(ImmutableList.of("url1", "mvn:url2"), environment.getDependencies()); + assertEquals(List.of("url1", "mvn:url2"), environment.getDependencies()); } @Test diff --git a/model/src/test/java/io/wcm/devops/conga/model/reader/RoleReaderTest.java b/model/src/test/java/io/wcm/devops/conga/model/reader/RoleReaderTest.java index 34f94640..e40493d9 100644 --- a/model/src/test/java/io/wcm/devops/conga/model/reader/RoleReaderTest.java +++ b/model/src/test/java/io/wcm/devops/conga/model/reader/RoleReaderTest.java @@ -28,13 +28,11 @@ import java.io.InputStream; import java.nio.charset.StandardCharsets; import java.util.List; +import java.util.Map; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; - import io.wcm.devops.conga.model.role.Role; import io.wcm.devops.conga.model.role.RoleFile; import io.wcm.devops.conga.model.role.RoleFile.RoleFileVariantMetadata; @@ -69,12 +67,12 @@ void testRole() { List files = role.getFiles(); assertEquals(7, files.size()); - assertEquals(ImmutableMap.of( + assertEquals(Map.of( "var1", "value1", - "group1", ImmutableMap.of("var2", "value2"), - "tomcat", ImmutableMap.of("port", 8080, "path", "/path/to/tomcat"), - "jvm", ImmutableMap.of("heapspace", ImmutableMap.of("min", "512m", "max", "2048m"), "permgenspace", ImmutableMap.of("max", "256m")), - "topologyConnectors", ImmutableList.of("http://localhost:8080/libs/sling/topology/connector") + "group1", Map.of("var2", "value2"), + "tomcat", Map.of("port", 8080, "path", "/path/to/tomcat"), + "jvm", Map.of("heapspace", Map.of("min", "512m", "max", "2048m"), "permgenspace", Map.of("max", "256m")), + "topologyConnectors", List.of("http://localhost:8080/libs/sling/topology/connector") ), role.getConfig()); } @@ -90,7 +88,7 @@ void testVariant() { RoleVariant variant = role.getVariants().get(0); assertEquals("services", variant.getVariant()); - assertEquals(ImmutableMap.of("var1", "value1_service"), variant.getConfig()); + assertEquals(Map.of("var1", "value1_service"), variant.getConfig()); } @Test @@ -100,12 +98,12 @@ void testFile() { assertEquals("systemconfig-importer.txt", file.getFile()); assertEquals("data/deploy", file.getDir()); assertEquals("systemconfig-importer.txt.hbs", file.getTemplate()); - assertEquals(ImmutableList.of("importer", "variant2*", "variant3"), file.getVariants()); + assertEquals(List.of("importer", "variant2*", "variant3"), file.getVariants()); assertEquals("${abc}", file.getCondition()); - assertEquals(ImmutableList.of("sling-provisioning-model"), file.getValidators()); - assertEquals(ImmutableMap.of("option1", "value1"), file.getValidatorOptions()); - assertEquals(ImmutableList.of("osgi-config-generator"), file.getPostProcessors()); - assertEquals(ImmutableMap.of("option2", "value2"), file.getPostProcessorOptions()); + assertEquals(List.of("sling-provisioning-model"), file.getValidators()); + assertEquals(Map.of("option1", "value1"), file.getValidatorOptions()); + assertEquals(List.of("osgi-config-generator"), file.getPostProcessors()); + assertEquals(Map.of("option2", "value2"), file.getPostProcessorOptions()); assertEquals("sling-provisioning", file.getFileHeader()); assertEquals("none", file.getMultiply()); assertEquals(StandardCharsets.UTF_8.name(), file.getCharset()); @@ -114,7 +112,7 @@ void testFile() { RoleFile vhostFile = role.getFiles().get(4); assertEquals("tenant", vhostFile.getMultiply()); - assertEquals(ImmutableMap.of("roles", ImmutableList.of("website")), vhostFile.getMultiplyOptions()); + assertEquals(Map.of("roles", List.of("website")), vhostFile.getMultiplyOptions()); assertEquals(LineEndings.unix, vhostFile.getLineEndings()); List variantsMetadata = file.getVariantsMetadata(); @@ -132,7 +130,7 @@ void testDownload() { assertEquals("download", file.getDir()); assertEquals("classpath://xyz.txt", file.getUrl()); - assertEquals(ImmutableMap.of("modelOption1", "value1"), file.getModelOptions()); + assertEquals(Map.of("modelOption1", "value1"), file.getModelOptions()); assertTrue(file.isDeleteSource()); } @@ -147,7 +145,7 @@ void testSymlink() { @Test void testSensitiveConfigurationParameters() { - assertEquals(ImmutableList.of("var1", "group1.var2"), role.getSensitiveConfigParameters()); + assertEquals(List.of("var1", "group1.var2"), role.getSensitiveConfigParameters()); } } diff --git a/model/src/test/java/io/wcm/devops/conga/model/util/MapExpanderTest.java b/model/src/test/java/io/wcm/devops/conga/model/util/MapExpanderTest.java index c66e94da..e243cc6d 100644 --- a/model/src/test/java/io/wcm/devops/conga/model/util/MapExpanderTest.java +++ b/model/src/test/java/io/wcm/devops/conga/model/util/MapExpanderTest.java @@ -24,10 +24,10 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNull; -import org.junit.jupiter.api.Test; +import java.util.List; +import java.util.Map; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; +import org.junit.jupiter.api.Test; class MapExpanderTest { @@ -38,73 +38,73 @@ void testNull() { @Test void testEmpty() { - assertEquals(ImmutableMap.of(), expand(ImmutableMap.of())); + assertEquals(Map.of(), expand(Map.of())); } @Test void testSimple() { - assertEquals(ImmutableMap.of("key1", "value1"), - expand(ImmutableMap.of("key1", "value1"))); + assertEquals(Map.of("key1", "value1"), + expand(Map.of("key1", "value1"))); - assertEquals(ImmutableMap.of("key1", "value1", "key2", 5), - expand(ImmutableMap.of("key1", "value1", "key2", 5))); + assertEquals(Map.of("key1", "value1", "key2", 5), + expand(Map.of("key1", "value1", "key2", 5))); } @Test void testSimpleNested() { - assertEquals(ImmutableMap.of("key1", "value1", "key2", ImmutableMap.of("key21", "value21")), - expand(ImmutableMap.of("key1", "value1", "key2", ImmutableMap.of("key21", "value21")))); + assertEquals(Map.of("key1", "value1", "key2", Map.of("key21", "value21")), + expand(Map.of("key1", "value1", "key2", Map.of("key21", "value21")))); } @Test void testOneLevel_1() { - assertEquals(ImmutableMap.of("key1", "value1", "key2", ImmutableMap.of("key21", "value21")), - expand(ImmutableMap.of("key1", "value1", "key2.key21", "value21"))); + assertEquals(Map.of("key1", "value1", "key2", Map.of("key21", "value21")), + expand(Map.of("key1", "value1", "key2.key21", "value21"))); } @Test void testOneLevel_2() { - assertEquals(ImmutableMap.of("key1", "value1", "key2", ImmutableMap.of("key21", "value21", "key22", 55)), - expand(ImmutableMap.of("key1", "value1", "key2.key21", "value21", "key2.key22", 55))); + assertEquals(Map.of("key1", "value1", "key2", Map.of("key21", "value21", "key22", 55)), + expand(Map.of("key1", "value1", "key2.key21", "value21", "key2.key22", 55))); } @Test void testThreeLevels() { - assertEquals(ImmutableMap.of("key1", "value1", "a", ImmutableMap.of("b", ImmutableMap.of( - "c", ImmutableMap.of("1", "v1", "2", 99), - "d", ImmutableMap.of("1", true)))), - expand(ImmutableMap.of("key1", "value1", "a.b.c.1", "v1", "a.b.c.2", 99, "a.b.d.1", true))); + assertEquals(Map.of("key1", "value1", "a", Map.of("b", Map.of( + "c", Map.of("1", "v1", "2", 99), + "d", Map.of("1", true)))), + expand(Map.of("key1", "value1", "a.b.c.1", "v1", "a.b.c.2", 99, "a.b.d.1", true))); } @Test void testMapDeeperLevel() { - assertEquals(ImmutableMap.of("key1", ImmutableMap.of("a", ImmutableMap.of("b", ImmutableMap.of("c", "v1")))), - expand(ImmutableMap.of("key1", ImmutableMap.of("a.b.c", "v1")))); + assertEquals(Map.of("key1", Map.of("a", Map.of("b", Map.of("c", "v1")))), + expand(Map.of("key1", Map.of("a.b.c", "v1")))); } @Test void testWithList() { - assertEquals(ImmutableMap.of("key1", ImmutableList.of( - ImmutableMap.of("a", ImmutableMap.of("b", "v1", "c", ImmutableMap.of("d", "v2"))), - ImmutableMap.of("a", ImmutableMap.of("b", "v3")) + assertEquals(Map.of("key1", List.of( + Map.of("a", Map.of("b", "v1", "c", Map.of("d", "v2"))), + Map.of("a", Map.of("b", "v3")) )), - expand(ImmutableMap.of("key1", ImmutableList.of( - ImmutableMap.of("a.b", "v1", "a.c.d", "v2"), - ImmutableMap.of("a.b", "v3") + expand(Map.of("key1", List.of( + Map.of("a.b", "v1", "a.c.d", "v2"), + Map.of("a.b", "v3") )))); } @Test void testGetDeep() { - assertNull(getDeep(ImmutableMap.of(), null)); - assertNull(getDeep(ImmutableMap.of(), "p1")); - assertNull(getDeep(ImmutableMap.of(), "p1.p2")); - assertNull(getDeep(ImmutableMap.of(), "p1.p2.p3")); - - assertEquals("v1", getDeep(ImmutableMap.of("p1", "v1", "p2", "v2"), "p1")); - assertNull(getDeep(ImmutableMap.of("p1", "v1", "p2", "v2"), "p1.p2")); - assertEquals("v1", getDeep(ImmutableMap.of("p1", ImmutableMap.of("p2", "v1"), "p2", "v2"), "p1.p2")); - assertEquals("v1", getDeep(ImmutableMap.of("p1", ImmutableMap.of("p2", ImmutableMap.of("p3", "v1")), "p2", "v2"), "p1.p2.p3")); + assertNull(getDeep(Map.of(), "")); + assertNull(getDeep(Map.of(), "p1")); + assertNull(getDeep(Map.of(), "p1.p2")); + assertNull(getDeep(Map.of(), "p1.p2.p3")); + + assertEquals("v1", getDeep(Map.of("p1", "v1", "p2", "v2"), "p1")); + assertNull(getDeep(Map.of("p1", "v1", "p2", "v2"), "p1.p2")); + assertEquals("v1", getDeep(Map.of("p1", Map.of("p2", "v1"), "p2", "v2"), "p1.p2")); + assertEquals("v1", getDeep(Map.of("p1", Map.of("p2", Map.of("p3", "v1")), "p2", "v2"), "p1.p2.p3")); } } diff --git a/model/src/test/java/io/wcm/devops/conga/model/util/MapMergerTest.java b/model/src/test/java/io/wcm/devops/conga/model/util/MapMergerTest.java index dca6804f..52a6c202 100644 --- a/model/src/test/java/io/wcm/devops/conga/model/util/MapMergerTest.java +++ b/model/src/test/java/io/wcm/devops/conga/model/util/MapMergerTest.java @@ -23,6 +23,7 @@ import static io.wcm.devops.conga.model.util.MapMerger.merge; import static org.junit.jupiter.api.Assertions.assertEquals; +import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.List; @@ -30,8 +31,6 @@ import org.junit.jupiter.api.Test; -import com.google.common.collect.ImmutableList; - class MapMergerTest { @Test @@ -267,7 +266,7 @@ void testMergeList_EliminateDuplicates_Map() { } private static List list(Object... items) { - return ImmutableList.copyOf(items); + return Arrays.asList(items); } private static Map map(Object... items) { diff --git a/model/src/test/java/io/wcm/devops/conga/model/util/MapSplitterTest.java b/model/src/test/java/io/wcm/devops/conga/model/util/MapSplitterTest.java index a3ea135b..64b92251 100644 --- a/model/src/test/java/io/wcm/devops/conga/model/util/MapSplitterTest.java +++ b/model/src/test/java/io/wcm/devops/conga/model/util/MapSplitterTest.java @@ -31,34 +31,31 @@ import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Test; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; - import io.wcm.devops.conga.model.util.MapSplitter.SplitResult; class MapSplitterTest { - private static final Map TEST_MAP = ImmutableMap.of( + private static final Map TEST_MAP = Map.of( "var1", "value1", "var2", "value2", - "obj1", ImmutableMap.of( + "obj1", Map.of( "var11", "value11", "var12", "value12", - "obj13", ImmutableMap.of( + "obj13", Map.of( "var131", "value131", "var132", "value132"), - "list14", ImmutableList.of( + "list14", List.of( "value14a", "value14b", "value14c")), - "list2", ImmutableList.of( - ImmutableMap.of( + "list2", List.of( + Map.of( "var21a", "value11a", "var22a", "value22a", - "obj23a", ImmutableMap.of( + "obj23a", Map.of( "var23a1", "value23a1", "var23a2", "value23a2")), - ImmutableMap.of( + Map.of( "var21b", "value11b", "var22b", "value22b"))); @@ -81,30 +78,30 @@ void testAllOut() { @Test void testKeyStartsWithVar1() { result = splitMap(TEST_MAP, entry -> StringUtils.startsWith(entry.getKey(), "var1")); - assertEquals(ImmutableMap.of( + assertEquals(Map.of( "var1", "value1", - "obj1", ImmutableMap.of( + "obj1", Map.of( "var11", "value11", "var12", "value12", - "obj13", ImmutableMap.of( + "obj13", Map.of( "var131", "value131", "var132", "value132"))), result.getMatching()); - assertEquals(ImmutableMap.of( + assertEquals(Map.of( "var2", "value2", - "obj1", ImmutableMap.of( - "list14", ImmutableList.of( + "obj1", Map.of( + "list14", List.of( "value14a", "value14b", "value14c")), - "list2", ImmutableList.of( - ImmutableMap.of( + "list2", List.of( + Map.of( "var21a", "value11a", "var22a", "value22a", - "obj23a", ImmutableMap.of( + "obj23a", Map.of( "var23a1", "value23a1", "var23a2", "value23a2")), - ImmutableMap.of( + Map.of( "var21b", "value11b", "var22b", "value22b"))), result.getUnmatching()); @@ -114,29 +111,29 @@ void testKeyStartsWithVar1() { void testValueStartsWithValue2() { result = splitMap(TEST_MAP, entry -> matchesSimpleListValue(entry.getValue(), value -> (value instanceof String) && StringUtils.startsWith(value.toString(), "value2"))); - assertEquals(ImmutableMap.of( + assertEquals(Map.of( "var2", "value2"), result.getMatching()); - assertEquals(ImmutableMap.of( + assertEquals(Map.of( "var1", "value1", - "obj1", ImmutableMap.of( + "obj1", Map.of( "var11", "value11", "var12", "value12", - "obj13", ImmutableMap.of( + "obj13", Map.of( "var131", "value131", "var132", "value132"), - "list14", ImmutableList.of( + "list14", List.of( "value14a", "value14b", "value14c")), - "list2", ImmutableList.of( - ImmutableMap.of( + "list2", List.of( + Map.of( "var21a", "value11a", "var22a", "value22a", - "obj23a", ImmutableMap.of( + "obj23a", Map.of( "var23a1", "value23a1", "var23a2", "value23a2")), - ImmutableMap.of( + Map.of( "var21b", "value11b", "var22b", "value22b"))), result.getUnmatching()); @@ -146,30 +143,30 @@ void testValueStartsWithValue2() { void testStartsWithValue14() { result = splitMap(TEST_MAP, entry -> matchesSimpleListValue(entry.getValue(), value -> (value instanceof String) && StringUtils.startsWith(value.toString(), "value14"))); - assertEquals(ImmutableMap.of( - "obj1", ImmutableMap.of( - "list14", ImmutableList.of( + assertEquals(Map.of( + "obj1", Map.of( + "list14", List.of( "value14a", "value14b", "value14c"))), result.getMatching()); - assertEquals(ImmutableMap.of( + assertEquals(Map.of( "var1", "value1", "var2", "value2", - "obj1", ImmutableMap.of( + "obj1", Map.of( "var11", "value11", "var12", "value12", - "obj13", ImmutableMap.of( + "obj13", Map.of( "var131", "value131", "var132", "value132")), - "list2", ImmutableList.of( - ImmutableMap.of( + "list2", List.of( + Map.of( "var21a", "value11a", "var22a", "value22a", - "obj23a", ImmutableMap.of( + "obj23a", Map.of( "var23a1", "value23a1", "var23a2", "value23a2")), - ImmutableMap.of( + Map.of( "var21b", "value11b", "var22b", "value22b"))), result.getUnmatching()); diff --git a/model/src/test/java/io/wcm/devops/conga/model/util/MergingListTest.java b/model/src/test/java/io/wcm/devops/conga/model/util/MergingListTest.java index f6189e02..8c1e4596 100644 --- a/model/src/test/java/io/wcm/devops/conga/model/util/MergingListTest.java +++ b/model/src/test/java/io/wcm/devops/conga/model/util/MergingListTest.java @@ -22,11 +22,11 @@ import static io.wcm.devops.conga.model.util.MapMerger.LIST_MERGE_ENTRY; import static org.junit.jupiter.api.Assertions.assertEquals; +import java.util.List; + import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import com.google.common.collect.ImmutableList; - class MergingListTest { private MergingList underTest; @@ -46,7 +46,7 @@ void testNoMerging_Duplicates() { underTest.add("item5"); underTest.add("item5"); - assertEquals(ImmutableList.of("item1", "item2", "item4", "item5"), underTest); + assertEquals(List.of("item1", "item2", "item4", "item5"), underTest); } @Test @@ -58,7 +58,7 @@ void testMergeStart() { underTest.add("item4"); underTest.add("item5"); - assertEquals(ImmutableList.of("item4", "item5", "item1", "item2"), underTest); + assertEquals(List.of("item4", "item5", "item1", "item2"), underTest); } @Test @@ -70,7 +70,7 @@ void testMergeMiddle() { underTest.add("item4"); underTest.add("item5"); - assertEquals(ImmutableList.of("item1", "item4", "item5", "item2"), underTest); + assertEquals(List.of("item1", "item4", "item5", "item2"), underTest); } @Test @@ -84,7 +84,7 @@ void testMergeMiddle_Duplicates() { underTest.add("item1"); underTest.add("item5"); - assertEquals(ImmutableList.of("item1", "item4", "item5", "item2"), underTest); + assertEquals(List.of("item1", "item4", "item5", "item2"), underTest); } @Test @@ -96,7 +96,7 @@ void testMergeEnd() { underTest.add("item4"); underTest.add("item5"); - assertEquals(ImmutableList.of("item1", "item2", "item4", "item5"), underTest); + assertEquals(List.of("item1", "item2", "item4", "item5"), underTest); } @Test @@ -109,7 +109,7 @@ void testMergeMultipleTokens() { underTest.add("item4"); underTest.add("item5"); - assertEquals(ImmutableList.of("item1", "item4", "item5", "item2"), underTest); + assertEquals(List.of("item1", "item4", "item5", "item2"), underTest); } } diff --git a/resource/src/test/java/io/wcm/devops/conga/resource/ResourceLoaderClasspathTest.java b/resource/src/test/java/io/wcm/devops/conga/resource/ResourceLoaderClasspathTest.java index dd55d5c5..39da464d 100644 --- a/resource/src/test/java/io/wcm/devops/conga/resource/ResourceLoaderClasspathTest.java +++ b/resource/src/test/java/io/wcm/devops/conga/resource/ResourceLoaderClasspathTest.java @@ -32,8 +32,6 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import com.google.common.collect.ImmutableList; - class ResourceLoaderClasspathTest { private static final String ROOT = "/test-files"; @@ -71,16 +69,16 @@ void testResourceCollection() throws Exception { assertEquals(ROOT + "/folder1", col.getPath()); assertEquals(CLASSPATH_PREFIX + ROOT + "/folder1", col.getCanonicalPath()); - List resources = ImmutableList.copyOf(col.getResources()); + List resources = List.copyOf(col.getResources()); assertEquals(2, resources.size()); assertEquals("file1.txt", resources.get(0).getName()); assertEquals("file2.txt", resources.get(1).getName()); - List resourceCollections = ImmutableList.copyOf(col.getResourceCollections()); + List resourceCollections = List.copyOf(col.getResourceCollections()); assertEquals(1, resourceCollections.size()); assertEquals("folder2", resourceCollections.get(0).getName()); - List folder2Resources = ImmutableList.copyOf(resourceCollections.get(0).getResources()); + List folder2Resources = List.copyOf(resourceCollections.get(0).getResources()); assertEquals(1, folder2Resources.size()); assertEquals("file3.txt", folder2Resources.get(0).getName()); } @@ -112,8 +110,8 @@ void testNonExistingResource() throws Exception { void testNonExistingResourceCollection() throws Exception { ResourceCollection col = underTest.getResourceCollection(CLASSPATH_PREFIX + ROOT + "/invalidFolder"); assertFalse(col.exists()); - assertEquals(ImmutableList.of(), ImmutableList.copyOf(col.getResources())); - assertEquals(ImmutableList.of(), ImmutableList.copyOf(col.getResourceCollections())); + assertEquals(List.of(), List.copyOf(col.getResources())); + assertEquals(List.of(), List.copyOf(col.getResourceCollections())); } @Test diff --git a/resource/src/test/java/io/wcm/devops/conga/resource/ResourceLoaderFilesystemTest.java b/resource/src/test/java/io/wcm/devops/conga/resource/ResourceLoaderFilesystemTest.java index 33776ba3..05f7b6ce 100644 --- a/resource/src/test/java/io/wcm/devops/conga/resource/ResourceLoaderFilesystemTest.java +++ b/resource/src/test/java/io/wcm/devops/conga/resource/ResourceLoaderFilesystemTest.java @@ -33,8 +33,6 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import com.google.common.collect.ImmutableList; - class ResourceLoaderFilesystemTest { private static final String ROOT = "src/test/resources/test-files"; @@ -74,16 +72,16 @@ void testResourceCollection() throws Exception { assertTrue(StringUtils.endsWith(unifySlashes(col.getCanonicalPath()), "/" + ROOT + "/folder1"), "Canonical path " + unifySlashes(col.getCanonicalPath()) + " does not end with /" + ROOT + "/folder1"); - List resources = ImmutableList.copyOf(col.getResources()); + List resources = List.copyOf(col.getResources()); assertEquals(2, resources.size()); assertEquals("file1.txt", resources.get(0).getName()); assertEquals("file2.txt", resources.get(1).getName()); - List resourceCollections = ImmutableList.copyOf(col.getResourceCollections()); + List resourceCollections = List.copyOf(col.getResourceCollections()); assertEquals(1, resourceCollections.size()); assertEquals("folder2", resourceCollections.get(0).getName()); - List folder2Resources = ImmutableList.copyOf(resourceCollections.get(0).getResources()); + List folder2Resources = List.copyOf(resourceCollections.get(0).getResources()); assertEquals(1, folder2Resources.size()); assertEquals("file3.txt", folder2Resources.get(0).getName()); } @@ -113,8 +111,8 @@ void testNonExistingResourceAutoDetect() throws Exception { void testNonExistingResourceCollection() throws Exception { ResourceCollection col = underTest.getResourceCollection(FILE_PREFIX + ROOT + "/invalidFolder"); assertFalse(col.exists()); - assertEquals(ImmutableList.of(), ImmutableList.copyOf(col.getResources())); - assertEquals(ImmutableList.of(), ImmutableList.copyOf(col.getResourceCollections())); + assertEquals(List.of(), List.copyOf(col.getResources())); + assertEquals(List.of(), List.copyOf(col.getResourceCollections())); } @Test diff --git a/tooling/conga-maven-plugin/src/test/java/io/wcm/devops/conga/tooling/maven/plugin/util/PluginConfigUtilTest.java b/tooling/conga-maven-plugin/src/test/java/io/wcm/devops/conga/tooling/maven/plugin/util/PluginConfigUtilTest.java index d439c6e9..9567f746 100644 --- a/tooling/conga-maven-plugin/src/test/java/io/wcm/devops/conga/tooling/maven/plugin/util/PluginConfigUtilTest.java +++ b/tooling/conga-maven-plugin/src/test/java/io/wcm/devops/conga/tooling/maven/plugin/util/PluginConfigUtilTest.java @@ -21,25 +21,25 @@ import static org.junit.jupiter.api.Assertions.assertEquals; -import org.junit.jupiter.api.Test; +import java.util.Map; -import com.google.common.collect.ImmutableMap; +import org.junit.jupiter.api.Test; public class PluginConfigUtilTest { @Test public void testGetConfigMap() { - assertEquals(ImmutableMap.of(), + assertEquals(Map.of(), PluginConfigUtil.getConfigMap(null)); - assertEquals(ImmutableMap.of( - "plugin1", ImmutableMap.of(), - "plugin2", ImmutableMap.of()), + assertEquals(Map.of( + "plugin1", Map.of(), + "plugin2", Map.of()), PluginConfigUtil.getConfigMap("plugin1,plugin2")); - assertEquals(ImmutableMap.of( - "plugin1", ImmutableMap.of("param1", "abc", "param2", 5), - "plugin2", ImmutableMap.of("param3", true)), + assertEquals(Map.of( + "plugin1", Map.of("param1", "abc", "param2", 5), + "plugin2", Map.of("param3", true)), PluginConfigUtil.getConfigMap("plugin1;param1=abc;param2=5,plugin2;param3=true")); } diff --git a/tooling/conga-maven-plugin/src/test/java/io/wcm/devops/conga/tooling/maven/plugin/valueprovider/MavenPropertyValueProviderPluginTest.java b/tooling/conga-maven-plugin/src/test/java/io/wcm/devops/conga/tooling/maven/plugin/valueprovider/MavenPropertyValueProviderPluginTest.java index a1eb0dc0..91ba87b0 100644 --- a/tooling/conga-maven-plugin/src/test/java/io/wcm/devops/conga/tooling/maven/plugin/valueprovider/MavenPropertyValueProviderPluginTest.java +++ b/tooling/conga-maven-plugin/src/test/java/io/wcm/devops/conga/tooling/maven/plugin/valueprovider/MavenPropertyValueProviderPluginTest.java @@ -24,12 +24,12 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNull; +import java.util.List; + import org.apache.maven.project.MavenProject; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import com.google.common.collect.ImmutableList; - import io.wcm.devops.conga.generator.spi.ValueProviderPlugin; import io.wcm.devops.conga.generator.spi.context.PluginContextOptions; import io.wcm.devops.conga.generator.spi.context.ValueProviderContext; @@ -73,7 +73,7 @@ void testResolve() { mavenProject.getProperties().setProperty(propertyDependency, "1.10"); assertEquals("value1", underTest.resolve(propertyName1, context)); - assertEquals(ImmutableList.of("value1", "value2", "value3"), underTest.resolve(propertyName2, context)); + assertEquals(List.of("value1", "value2", "value3"), underTest.resolve(propertyName2, context)); assertNull(underTest.resolve(propertyName3, context)); assertNotNull(underTest.resolve(propertyJavaVersion, context));