Skip to content

Commit

Permalink
Add tests and document chages
Browse files Browse the repository at this point in the history
  • Loading branch information
EtienneLamoureux committed Feb 8, 2021
1 parent a7212ca commit 95960d5
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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-<version>.jar <command> <arguments> [<flags>]`
9. Run it using `java -jar reverse-flhook-<version>.jar <command> <arguments> [<flags>]`

#### Example
```cmd
Expand Down
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
@@ -1 +1 @@
rootProject.name = 'reverseFLHook'
rootProject.name = 'reverse-flhook'
Original file line number Diff line number Diff line change
@@ -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());
}
}

0 comments on commit 95960d5

Please sign in to comment.