Search in sources :

Example 11 with Version

use of games.strategy.util.Version in project triplea by triplea-game.

the class DownloadFileDescriptionTest method testIsSkin.

@Test
public void testIsSkin() {
    final DownloadFileDescription testObj = new DownloadFileDescription("", "", "", new Version(0, 0), DownloadFileDescription.DownloadType.MAP_SKIN, DownloadFileDescription.MapCategory.EXPERIMENTAL);
    assertThat(testObj.isMapSkin(), is(true));
}
Also used : Version(games.strategy.util.Version) Test(org.junit.jupiter.api.Test)

Example 12 with Version

use of games.strategy.util.Version in project triplea by triplea-game.

the class DownloadFileDescriptionTest method testGetMapType.

@Test
public void testGetMapType() {
    final DownloadFileDescription testObj = new DownloadFileDescription("", "", "", new Version(0, 0), DownloadFileDescription.DownloadType.MAP, DownloadFileDescription.MapCategory.BEST);
    assertThat(testObj.getMapCategory(), is(DownloadFileDescription.MapCategory.BEST));
}
Also used : Version(games.strategy.util.Version) Test(org.junit.jupiter.api.Test)

Example 13 with Version

use of games.strategy.util.Version in project triplea by triplea-game.

the class DownloadFileDescriptionTest method testIsMap.

@Test
public void testIsMap() {
    final DownloadFileDescription testObj = new DownloadFileDescription("", "", "", new Version(0, 0), DownloadFileDescription.DownloadType.MAP, DownloadFileDescription.MapCategory.EXPERIMENTAL);
    assertThat(testObj.isMap(), is(true));
}
Also used : Version(games.strategy.util.Version) Test(org.junit.jupiter.api.Test)

Example 14 with Version

use of games.strategy.util.Version in project triplea by triplea-game.

the class LobbyPropertyFileParserTest method checkVersionSelection.

/**
 * YAML config has multple lobby configs depending on client version. Here we make sure the version checks
 * line up and we get the expected lobby config back.
 */
@Test
public void checkVersionSelection() throws Exception {
    final File testFile = createTempFile(testDataSet());
    final LobbyServerProperties result = LobbyPropertyFileParser.parse(testFile, new Version(TestData.clientCurrentVersion));
    assertThat(result.host, is(TestData.hostOther));
    assertThat(result.port, is(Integer.valueOf(TestData.portOther)));
    assertThat(result.serverMessage, is(""));
    assertThat(result.serverErrorMessage, is(""));
}
Also used : Version(games.strategy.util.Version) File(java.io.File) LobbyServerProperties(games.strategy.engine.lobby.client.login.LobbyServerProperties) Test(org.junit.jupiter.api.Test)

Example 15 with Version

use of games.strategy.util.Version in project triplea by triplea-game.

the class DownloadFileParser method parse.

public static List<DownloadFileDescription> parse(final InputStream is) {
    final JSONArray yamlData = new JSONArray(new Yaml().loadAs(is, List.class));
    final List<DownloadFileDescription> downloads = new ArrayList<>();
    OpenJsonUtils.stream(yamlData).map(JSONObject.class::cast).forEach(yaml -> {
        final String url = yaml.getString(Tags.url.toString());
        final String description = yaml.getString(Tags.description.toString());
        final String mapName = yaml.getString(Tags.mapName.toString());
        final Version version = new Version(yaml.getInt(Tags.version.toString()), 0);
        final DownloadFileDescription.DownloadType downloadType = OpenJsonUtils.optEnum(yaml, DownloadFileDescription.DownloadType.class, Tags.mapType.toString(), DownloadFileDescription.DownloadType.MAP);
        final DownloadFileDescription.MapCategory mapCategory = OpenJsonUtils.optEnum(yaml, DownloadFileDescription.MapCategory.class, Tags.mapCategory.toString(), DownloadFileDescription.MapCategory.EXPERIMENTAL);
        final String img = yaml.optString(Tags.img.toString());
        final DownloadFileDescription dl = new DownloadFileDescription(url, description, mapName, version, downloadType, mapCategory, img);
        downloads.add(dl);
    });
    return downloads;
}
Also used : Version(games.strategy.util.Version) JSONArray(com.github.openjson.JSONArray) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) Yaml(org.yaml.snakeyaml.Yaml)

Aggregations

Version (games.strategy.util.Version)19 Test (org.junit.jupiter.api.Test)7 GameEngineVersion (games.strategy.engine.GameEngineVersion)5 LobbyServerProperties (games.strategy.engine.lobby.client.login.LobbyServerProperties)3 File (java.io.File)3 IOException (java.io.IOException)2 List (java.util.List)2 JSONArray (com.github.openjson.JSONArray)1 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 ClientLogger (games.strategy.debug.ClientLogger)1 ClientContext (games.strategy.engine.ClientContext)1 ClientFileSystemHelper (games.strategy.engine.ClientFileSystemHelper)1 GameData (games.strategy.engine.data.GameData)1 GameDescription (games.strategy.engine.lobby.server.GameDescription)1 ResourceLoader (games.strategy.triplea.ResourceLoader)1 ClientSetting (games.strategy.triplea.settings.ClientSetting)1 SwingComponents (games.strategy.ui.SwingComponents)1 ObjectInputStream (java.io.ObjectInputStream)1 Timestamp (java.sql.Timestamp)1 ArrayList (java.util.ArrayList)1