コード例 #1
0
 @BeforeInjecting
 public void copyTestFiles() throws IOException {
   dataFolder = temporaryFolder.newFolder();
   File playerFolder =
       new File(dataFolder, FileUtils.makePath("playerdata", SAMPLE_UUID.toString()));
   if (!playerFolder.mkdirs()) {
     throw new IllegalStateException("Cannot create '" + playerFolder.getAbsolutePath() + "'");
   }
   Files.copy(
       TestHelper.getJarPath(FileUtils.makePath(SOURCE_FOLDER, "sample-folder", "data.json")),
       new File(playerFolder, "data.json").toPath());
 }
コード例 #2
0
  @Test
  public void shouldSavePlayerData() {
    // given
    Player player = mock(Player.class);
    UUID uuid = UUID.nameUUIDFromBytes("New player".getBytes());
    given(player.getUniqueId()).willReturn(uuid);
    given(permissionsManager.getPrimaryGroup(player)).willReturn("primary-grp");
    given(player.isOp()).willReturn(true);
    given(player.getWalkSpeed()).willReturn(1.2f);
    given(player.getFlySpeed()).willReturn(0.8f);
    given(player.getAllowFlight()).willReturn(true);

    World world = mock(World.class);
    given(world.getName()).willReturn("player-world");
    Location location = new Location(world, 0.2, 102.25, -89.28, 3.02f, 90.13f);
    given(spawnLoader.getPlayerLocationOrSpawn(player)).willReturn(location);

    // when
    limboPlayerStorage.saveData(player);

    // then
    File playerFile =
        new File(dataFolder, FileUtils.makePath("playerdata", uuid.toString(), "data.json"));
    assertThat(playerFile.exists(), equalTo(true));
    // TODO ljacqu 20160711: Check contents of file
  }