diff --git a/README.md b/README.md index 2227780..647c419 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ See the [help file](/src/main/resources/help.txt). 6. Save and close the new file 7. Open a command prompt 8. Navigate to the jar location -9. Run it using `java -jar reverseFLHook-.jar []` +9. Run it using `java -jar reverse-flhook-.jar []` #### Example ```cmd diff --git a/build.gradle b/build.gradle index be086a0..632adeb 100644 --- a/build.gradle +++ b/build.gradle @@ -2,6 +2,7 @@ plugins { id 'org.springframework.boot' version '2.4.2' id 'io.spring.dependency-management' version '1.0.11.RELEASE' id 'java' + id 'eclipse' } group = 'com.etiennelamoureux' diff --git a/settings.gradle b/settings.gradle index 2103be1..cb52d2c 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1 +1 @@ -rootProject.name = 'reverseFLHook' +rootProject.name = 'reverse-flhook' diff --git a/src/test/java/com/etiennelamoureux/reverseflhook/jump/HyperspaceCoordinatesServiceTest.java b/src/test/java/com/etiennelamoureux/reverseflhook/jump/HyperspaceCoordinatesServiceTest.java new file mode 100644 index 0000000..bc504de --- /dev/null +++ b/src/test/java/com/etiennelamoureux/reverseflhook/jump/HyperspaceCoordinatesServiceTest.java @@ -0,0 +1,66 @@ +package com.etiennelamoureux.reverseflhook.jump; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.mockito.Mockito.when; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; + +@ExtendWith(MockitoExtension.class) +public class HyperspaceCoordinatesServiceTest { + private static final String SYSTEM = "system"; + private static final String BASE = "base"; + private static final float X = 1; + private static final float Y = 2; + private static final float Z = 3; + private static final Coordinates COORDS = new Coordinates(X, Y, Z); + + @Mock + private CoordinatesRepository coordinatesRepository; + + @InjectMocks + private HyperspaceCoordinatesService hyperspaceCoordinatesService; + + @Test + public void givenNotAdminWhenSurveyingCoordsThenBlur() { + HyperspaceCoordinates hyperspaceCoordinates = + hyperspaceCoordinatesService.survey(SYSTEM, X, Y, Z); + + assertNotEquals(COORDS, hyperspaceCoordinates.getCoordinates()); + } + + @Test + public void givenNotAdminWhenSurveyingBaseThenBlur() { + when(coordinatesRepository.findOneBySystemAndBase(SYSTEM, BASE)) + .thenReturn(new Coordinates(X, Y, Z)); + + HyperspaceCoordinates hyperspaceCoordinates = hyperspaceCoordinatesService.survey(SYSTEM, BASE); + + assertNotEquals(COORDS, hyperspaceCoordinates.getCoordinates()); + } + + @Test + public void givenAdminWhenSurveyingCoordsThenDontBlur() { + hyperspaceCoordinatesService.isAdminMode(); + + HyperspaceCoordinates hyperspaceCoordinates = + hyperspaceCoordinatesService.survey(SYSTEM, X, Y, Z); + + assertEquals(COORDS, hyperspaceCoordinates.getCoordinates()); + } + + @Test + public void givenAdminWhenSurveyingBaseThenDontBlur() { + when(coordinatesRepository.findOneBySystemAndBase(SYSTEM, BASE)) + .thenReturn(new Coordinates(X, Y, Z)); + hyperspaceCoordinatesService.isAdminMode(); + + HyperspaceCoordinates hyperspaceCoordinates = hyperspaceCoordinatesService.survey(SYSTEM, BASE); + + assertEquals(COORDS, hyperspaceCoordinates.getCoordinates()); + } +}