-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add `MarkerMock` * Add to test * Fix behavior and add test --------- Co-authored-by: Thorinwasher <37477983+Thorinwasher@users.noreply.github.com>
- Loading branch information
1 parent
392cf5f
commit 7becc19
Showing
4 changed files
with
95 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/main/java/be/seeseemelk/mockbukkit/entity/MarkerMock.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package be.seeseemelk.mockbukkit.entity; | ||
|
||
import be.seeseemelk.mockbukkit.ServerMock; | ||
import org.bukkit.entity.Entity; | ||
import org.bukkit.entity.EntityType; | ||
import org.bukkit.entity.Marker; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.UUID; | ||
|
||
/** | ||
* Mock implementation of a {@link Marker}. | ||
*/ | ||
public class MarkerMock extends EntityMock implements Marker | ||
{ | ||
|
||
/** | ||
* Constructs a new {@link MarkerMock} on the provided {@link ServerMock} with a specified {@link UUID}. | ||
* | ||
* @param server The server to create the entity on. | ||
* @param uuid The UUID of the entity. | ||
*/ | ||
public MarkerMock(@NotNull ServerMock server, @NotNull UUID uuid) | ||
{ | ||
super(server, uuid); | ||
} | ||
|
||
@Override | ||
public @NotNull EntityType getType() | ||
{ | ||
return EntityType.MARKER; | ||
} | ||
|
||
@Override | ||
public boolean addPassenger(@NotNull Entity passenger) | ||
{ | ||
return false; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
src/test/java/be/seeseemelk/mockbukkit/entity/MarkerMockTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package be.seeseemelk.mockbukkit.entity; | ||
|
||
import be.seeseemelk.mockbukkit.MockBukkit; | ||
import be.seeseemelk.mockbukkit.ServerMock; | ||
import org.bukkit.entity.EntityType; | ||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.UUID; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
|
||
public class MarkerMockTest | ||
{ | ||
|
||
private MarkerMock marker; | ||
private ServerMock server; | ||
|
||
@BeforeEach | ||
void setUp() | ||
{ | ||
server = MockBukkit.mock(); | ||
marker = new MarkerMock(server, UUID.randomUUID()); | ||
} | ||
|
||
@AfterEach | ||
void tearDown() | ||
{ | ||
MockBukkit.unmock(); | ||
} | ||
|
||
@Test | ||
void testType() | ||
{ | ||
assertEquals(EntityType.MARKER, marker.getType()); | ||
} | ||
|
||
@Test | ||
void testCannotAddPassenger() | ||
{ | ||
assertFalse(marker.addPassenger(new SimpleEntityMock(server))); | ||
assertEquals(0, marker.getPassengers().size()); | ||
} | ||
} |