use of com.faforever.api.config.FafApiProperties.Map in project faf-java-api by FAForever.
the class MapServiceTest method notCorrectAuthor.
@Test
public void notCorrectAuthor() throws IOException {
String zipFilename = "scmp_037.zip";
Player me = new Player();
me.setId(1);
Player bob = new Player();
bob.setId(2);
com.faforever.api.data.domain.Map map = new com.faforever.api.data.domain.Map().setAuthor(bob);
when(mapRepository.findOneByDisplayName(any())).thenReturn(Optional.of(map));
try (InputStream inputStream = loadMapResourceAsStream(zipFilename)) {
try {
byte[] mapData = ByteStreams.toByteArray(inputStream);
instance.uploadMap(mapData, zipFilename, me, true);
fail();
} catch (ApiException e) {
assertThat(e, apiExceptionWithCode(ErrorCode.MAP_NOT_ORIGINAL_AUTHOR));
}
verify(mapRepository, never()).save(any(com.faforever.api.data.domain.Map.class));
}
}
use of com.faforever.api.config.FafApiProperties.Map in project faf-java-api by FAForever.
the class MapServiceTest method versionExistsAlready.
@Test
public void versionExistsAlready() throws IOException {
String zipFilename = "scmp_037.zip";
Player me = new Player();
me.setId(1);
com.faforever.api.data.domain.Map map = new com.faforever.api.data.domain.Map().setAuthor(me).setVersions(Collections.singletonList(new MapVersion().setVersion(1)));
when(mapRepository.findOneByDisplayName(any())).thenReturn(Optional.of(map));
try (InputStream inputStream = loadMapResourceAsStream(zipFilename)) {
try {
byte[] mapData = ByteStreams.toByteArray(inputStream);
instance.uploadMap(mapData, zipFilename, me, true);
fail();
} catch (ApiException e) {
assertThat(e, apiExceptionWithCode(ErrorCode.MAP_VERSION_EXISTS));
}
verify(mapRepository, never()).save(any(com.faforever.api.data.domain.Map.class));
}
}
Aggregations