From 6f5fc0605793c0ef52514a7689605f748c2a55fd Mon Sep 17 00:00:00 2001 From: Lorenzo Bettini Date: Tue, 31 Dec 2019 07:32:06 +0100 Subject: [PATCH] 80: assertj assertions Task-Url: http://github.com/LorenzoBettini/edelta/issues/80 --- edelta.parent/edelta.maven.plugin/pom.xml | 6 +++++ .../edelta/maven/plugin/EdeltaMojoTest.java | 26 ++++++++----------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/edelta.parent/edelta.maven.plugin/pom.xml b/edelta.parent/edelta.maven.plugin/pom.xml index 704c8774d..deeb14335 100644 --- a/edelta.parent/edelta.maven.plugin/pom.xml +++ b/edelta.parent/edelta.maven.plugin/pom.xml @@ -100,6 +100,12 @@ 1.6 test + + org.assertj + assertj-core + ${assertj-version} + test + diff --git a/edelta.parent/edelta.maven.plugin/src/test/java/edelta/maven/plugin/EdeltaMojoTest.java b/edelta.parent/edelta.maven.plugin/src/test/java/edelta/maven/plugin/EdeltaMojoTest.java index 85d7a6fd2..0222233ab 100644 --- a/edelta.parent/edelta.maven.plugin/src/test/java/edelta/maven/plugin/EdeltaMojoTest.java +++ b/edelta.parent/edelta.maven.plugin/src/test/java/edelta/maven/plugin/EdeltaMojoTest.java @@ -1,6 +1,6 @@ package edelta.maven.plugin; -import static org.junit.Assert.assertFalse; +import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; @@ -62,8 +62,7 @@ public void testProjectWithSkip() throws Exception { EdeltaMojo edeltaMojo = executeMojo(pomPath); File outputDirectory = new File(rule.getVariableValueFromObject(edeltaMojo, "outputDirectory").toString()); - assertNotNull(outputDirectory); - assertFalse(outputDirectory.exists()); + assertThat(outputDirectory).doesNotExist(); } @Test @@ -72,12 +71,10 @@ public void testProjectWithoutSources() throws Exception { EdeltaMojo edeltaMojo = executeMojo(pomPath); File outputDirectory = new File(rule.getVariableValueFromObject(edeltaMojo, "outputDirectory").toString()); - assertNotNull(outputDirectory); - assertFalse(outputDirectory.exists()); + assertThat(outputDirectory).doesNotExist(); File xtextTmpDirectory = new File(rule.getVariableValueFromObject(edeltaMojo, "tmpClassDirectory").toString()); - assertNotNull(xtextTmpDirectory); - assertTrue(xtextTmpDirectory.exists()); + assertThat(xtextTmpDirectory).exists(); } @Test @@ -89,8 +86,8 @@ public void testProjectWithoutEcore() throws Exception { new File( pomPath.getAbsolutePath(), rule.getVariableValueFromObject(edeltaMojo, "outputDirectory").toString()); - assertNotNull(outputDirectory); - assertTrue(outputDirectory.exists()); + assertThat(outputDirectory) + .isDirectoryContaining("glob:**com"); } @Test @@ -102,8 +99,8 @@ public void testProjectWithEcore() throws Exception { new File( pomPath.getAbsolutePath(), rule.getVariableValueFromObject(edeltaMojo, "outputDirectory").toString()); - assertNotNull(outputDirectory); - assertTrue(outputDirectory.exists()); + assertThat(outputDirectory) + .isDirectoryContaining("glob:**com"); } @Test @@ -115,14 +112,13 @@ public void testProjectWithOutputDirectory() throws Exception { new File( pomPath.getAbsolutePath(), "edelta-gen"); - assertNotNull(defaultOutputDirectory); - assertFalse(defaultOutputDirectory.exists()); + assertThat(defaultOutputDirectory).doesNotExist(); File outputDirectory = new File( pomPath.getAbsolutePath(), "alt-gen"); - assertNotNull(outputDirectory); - assertTrue(outputDirectory.exists()); + assertThat(outputDirectory) + .isDirectoryContaining("glob:**com"); } }