Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ProjectTypeCheckerTest.java #294

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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);
}
}
Loading