From 7bc2b5aabedc478065250e09b10ba07713373c01 Mon Sep 17 00:00:00 2001 From: MD SHAHIL <96812916+Shahil093@users.noreply.github.com> Date: Mon, 11 Dec 2023 10:45:49 +0530 Subject: [PATCH] Update ProjectTypeCheckerTest.java Method Naming and Display Name: Renamed the test methods to provide clearer names and added @DisplayName annotations And Added Assertions Static Import, Reduced Visibility of Test Methods. --- .../flyfly/utils/ProjectTypeCheckerTest.java | 79 ++++++++++--------- 1 file changed, 40 insertions(+), 39 deletions(-) diff --git a/FlySpring/flyfly/src/test/java/com/flyspring/flyfly/utils/ProjectTypeCheckerTest.java b/FlySpring/flyfly/src/test/java/com/flyspring/flyfly/utils/ProjectTypeCheckerTest.java index df54a05a0..6e0cf7e7e 100644 --- a/FlySpring/flyfly/src/test/java/com/flyspring/flyfly/utils/ProjectTypeCheckerTest.java +++ b/FlySpring/flyfly/src/test/java/com/flyspring/flyfly/utils/ProjectTypeCheckerTest.java @@ -1,55 +1,56 @@ package com.flyspring.flyfly.utils; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.*; import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; +import java.nio.file.*; -public class ProjectTypeCheckerTest { +import static org.junit.jupiter.api.Assertions.*; - private ProjectTypeChecker projectTypeChecker; +class ProjectTypeCheckerTest { - @BeforeEach - public void setup() { - projectTypeChecker = new ProjectTypeChecker(); - } + private ProjectTypeChecker projectTypeChecker; - @Test - public void testIsMavenProject() throws IOException { - // Create a temporary directory and file - Path tempDirectory = Files.createTempDirectory("tempDir"); - Path tempFile = Files.createTempFile(tempDirectory, "test", ".txt"); + @BeforeEach + void setUp() { + projectTypeChecker = new ProjectTypeChecker(); + } - // Check that the file is not named "pom.xml" - Assertions.assertFalse(tempFile.toFile().getName().equals("pom.xml")); + @Test + @DisplayName("Test whether the directory is not a Maven project") + void testIsNotMavenProject() throws IOException { + // Create a temporary directory and file + Path tempDirectory = Files.createTempDirectory("tempDir"); + Path tempFile = Files.createTempFile(tempDirectory, "test", ".txt"); - // Move to the temporary directory and check if it is a Maven project - System.setProperty("user.dir", tempDirectory.toString()); - Assertions.assertFalse(projectTypeChecker.isMavenProject()); + // Check that the file is not named "pom.xml" + assertFalse(tempFile.toFile().getName().equals("pom.xml")); - // Delete the temporary directory and file - Files.deleteIfExists(tempFile); - Files.deleteIfExists(tempDirectory); - } + // Move to the temporary directory and check if it is a Maven project + System.setProperty("user.dir", tempDirectory.toString()); + assertFalse(projectTypeChecker.isMavenProject()); - @Test - public void testIsGradleProject() throws IOException { - // Create a temporary directory and file - Path tempDirectory = Files.createTempDirectory("tempDir"); - Path tempFile = Files.createTempFile(tempDirectory, "test", ".txt"); + // Delete the temporary directory and file + Files.deleteIfExists(tempFile); + Files.deleteIfExists(tempDirectory); + } - // Check that the file is not named "build.gradle" - Assertions.assertFalse(tempFile.toFile().getName().equals("build.gradle")); + @Test + @DisplayName("Test whether the directory is not a Gradle project") + void testIsNotGradleProject() throws IOException { + // Create a temporary directory and file + Path tempDirectory = Files.createTempDirectory("tempDir"); + Path tempFile = Files.createTempFile(tempDirectory, "test", ".txt"); - // Move to the temporary directory and check if it is a Gradle project - System.setProperty("user.dir", tempDirectory.toString()); - Assertions.assertFalse(projectTypeChecker.isGradleProject()); + // Check that the file is not named "build.gradle" + assertFalse(tempFile.toFile().getName().equals("build.gradle")); - // Delete the temporary directory and file - Files.deleteIfExists(tempFile); - Files.deleteIfExists(tempDirectory); - } + // Move to the temporary directory and check if it is a Gradle project + System.setProperty("user.dir", tempDirectory.toString()); + assertFalse(projectTypeChecker.isGradleProject()); + + // Delete the temporary directory and file + Files.deleteIfExists(tempFile); + Files.deleteIfExists(tempDirectory); + } }