Search in sources :

Example 1 with TestWith

use of com.googlecode.zohhak.api.TestWith in project faf-java-server by FAForever.

the class DivisionServiceTest method testGetCurrentPlayerDivision.

@TestWith({ "1,   0.0f,  1", "1,   1.0f,  1", "1,  10.0f,  1", "1,  10.1f,  2", "1,  30.0f,  2", "2,  10.0f,  4", "2,  99.9f,  6", "3, 999.0f,  9" })
public void testGetCurrentPlayerDivision(int league, float score, int expectedDivisionId) throws Exception {
    PlayerDivisionInfo info = new PlayerDivisionInfo();
    info.setPlayer(player1);
    info.setLeague(league);
    info.setScore(score);
    when(playerDivisionInfoRepository.findByPlayerAndSeason(player1, serverProperties.getLadder1v1().getSeason())).thenReturn(info);
    Division result = instance.getCurrentPlayerDivision(player1).get();
    assertEquals(result.getId(), expectedDivisionId);
}
Also used : PlayerDivisionInfo(com.faforever.server.entity.PlayerDivisionInfo) Division(com.faforever.server.entity.Division) TestWith(com.googlecode.zohhak.api.TestWith)

Example 2 with TestWith

use of com.googlecode.zohhak.api.TestWith in project knotx by Cognifide.

the class MultiMapConverterTest method fromJsonObject_whenNotEmptyJson_expectSizeOfMultiMap.

@TestWith({ "{\"mapKey1\":[\"A\",\"B\",\"C\"]};1", "{\"mapKey1\":[\"A\"],\"mapKey2\":[\"B\"]};2", "{\"mapKey1\":[\"A\"],\"mapKey2\":[\"B\"],\"mapKey3\":[\"C\"]};3" })
public void fromJsonObject_whenNotEmptyJson_expectSizeOfMultiMap(JsonObject jsonObject, int multimapSize) throws Exception {
    final MultiMap multiMap = MultiMapConverter.fromJsonObject(jsonObject);
    assertThat(multiMap.size(), equalTo(multimapSize));
}
Also used : MultiMap(io.vertx.reactivex.core.MultiMap) TestWith(com.googlecode.zohhak.api.TestWith)

Example 3 with TestWith

use of com.googlecode.zohhak.api.TestWith in project knotx by Cognifide.

the class MultiMapConverterTest method toJsonObject_whenMultiMapWithMultipleEntries_expectJsonObjectWithJsonArrays.

@TestWith({ "mapKey1:A,B,C;{\"mapKey1\":[\"A\",\"B\",\"C\"]}", "mapKey1:A,B,C,D;{\"mapKey1\":[\"A\",\"B\",\"C\",\"D\"]}", "mapKey1:A,B,C,D,E;{\"mapKey1\":[\"A\",\"B\",\"C\",\"D\",\"E\"]}", "mapKey1:A|mapKey2:B;{\"mapKey1\":[\"A\"],\"mapKey2\":[\"B\"]}", "mapKey1:A|mapKey2:B|mapKey3:C;{\"mapKey1\":[\"A\"],\"mapKey2\":[\"B\"],\"mapKey3\":[\"C\"]}", "mapKey1:A,B|mapKey2:C,D|mapKey3:E,F;{\"mapKey1\":[\"A\",\"B\"],\"mapKey2\":[\"C\",\"D\"],\"mapKey3\":[\"E\",\"F\"]}", "mapKey1:A,B,C|mapKey2:A,B,C|mapKey3:A,B,C;{\"mapKey1\":[\"A\",\"B\",\"C\"],\"mapKey2\":[\"A\",\"B\",\"C\"],\"mapKey3\":[\"A\",\"B\",\"C\"]}" })
public void toJsonObject_whenMultiMapWithMultipleEntries_expectJsonObjectWithJsonArrays(MultiMap multiMap, String expectedJson) throws Exception {
    JsonObject jsonObject = MultiMapConverter.toJsonObject(multiMap);
    assertThat(jsonObject.toString(), sameJSONAs(expectedJson).allowingAnyArrayOrdering());
}
Also used : JsonObject(io.vertx.core.json.JsonObject) TestWith(com.googlecode.zohhak.api.TestWith)

Example 4 with TestWith

use of com.googlecode.zohhak.api.TestWith in project knotx by Cognifide.

the class FragmentContentExtractorTest method unwrappedContent_withString_expectDefinedContent.

@TestWith(value = { "simple_default_snippet.txt;simple_snippet-expected_content.txt", "complex_default_snippet.txt;complex_snippet-expected_content.txt", "simple_custom_snippet.txt;simple_snippet-expected_content.txt", "complex_custom_snippet.txt;complex_snippet-expected_content.txt" })
public void unwrappedContent_withString_expectDefinedContent(String snippetFileName, String expectedContentFileName) throws Exception {
    final String expectedContent = readText(expectedContentFileName);
    final Element element = FragmentContentExtractor.unwrapContent(readText(snippetFileName));
    assertThat(element.toString(), equalsToWithHtmlFormatting(expectedContent));
}
Also used : Element(org.jsoup.nodes.Element) TestWith(com.googlecode.zohhak.api.TestWith)

Example 5 with TestWith

use of com.googlecode.zohhak.api.TestWith in project knotx by Cognifide.

the class UnprocessedFragmentStrategyTest method ignore_whenConfiguredSnippetTag_expectIgnoredContent.

@TestWith({ "simple_snippet.txt;simple_snippet-expected_ignored_content.txt;script", "customTag_snippet.txt;simple_snippet-expected_ignored_content.txt;knotx:snippet", // when fragment is a raw fragment, it is not ignored
"raw_fragment.txt;raw_fragment.txt;script" })
public void ignore_whenConfiguredSnippetTag_expectIgnoredContent(Fragment fragment, String expectedContentFileName, String snippetTagName) throws Exception {
    final String unwrappedContent = UnprocessedFragmentStrategy.IGNORE.get(fragment, new SnippetPatterns(snippetTagName));
    final String expectedContent = FileReader.readText(expectedContentFileName);
    assertThat(unwrappedContent, equalToIgnoringWhiteSpace(expectedContent));
}
Also used : SnippetPatterns(io.knotx.fragments.SnippetPatterns) TestWith(com.googlecode.zohhak.api.TestWith)

Aggregations

TestWith (com.googlecode.zohhak.api.TestWith)9 SnippetPatterns (io.knotx.fragments.SnippetPatterns)3 Element (org.jsoup.nodes.Element)2 Division (com.faforever.server.entity.Division)1 PlayerDivisionInfo (com.faforever.server.entity.PlayerDivisionInfo)1 ServiceEntry (io.knotx.knot.service.service.ServiceEntry)1 JsonObject (io.vertx.core.json.JsonObject)1 MultiMap (io.vertx.reactivex.core.MultiMap)1