Search in sources :

Example 1 with ApiVersion

use of com.quorum.tessera.version.ApiVersion in project tessera by ConsenSys.

the class VersionResourceTest method getVersionsNoPrefix.

@Test
public void getVersionsNoPrefix() {
    // Make sure that elements are defined in unnatural order to test sorting
    List<Double> versions = List.of(03.00, 01.00, 02.00);
    JsonArray result;
    try (var apiVersionMockedStatic = mockStatic(ApiVersion.class)) {
        apiVersionMockedStatic.when(ApiVersion::versions).thenReturn(versions.stream().map(String::valueOf).collect(Collectors.toList()));
        result = instance.getVersions();
        apiVersionMockedStatic.verify(ApiVersion::versions);
        apiVersionMockedStatic.verifyNoMoreInteractions();
    }
    JsonArrayBuilder jsonArrayBuilder = Json.createArrayBuilder();
    versions.stream().sorted().map(String::valueOf).forEach(v -> jsonArrayBuilder.add(v));
    JsonArray expected = jsonArrayBuilder.build();
    assertThat(result).containsExactlyElementsOf(expected);
}
Also used : JsonArray(jakarta.json.JsonArray) ApiVersion(com.quorum.tessera.version.ApiVersion) JsonArrayBuilder(jakarta.json.JsonArrayBuilder) Test(org.junit.Test)

Example 2 with ApiVersion

use of com.quorum.tessera.version.ApiVersion in project tessera by ConsenSys.

the class VersionResourceTest method getVersions.

@Test
public void getVersions() {
    // Make sure that elements are defined in unnatural order to test sorting
    List<Double> versions = List.of(03.00, 01.00, 02.00);
    JsonArray result;
    try (var apiVersionMockedStatic = mockStatic(ApiVersion.class)) {
        apiVersionMockedStatic.when(ApiVersion::versions).thenReturn(versions.stream().map(String::valueOf).map(s -> "v" + s).collect(Collectors.toList()));
        result = instance.getVersions();
        apiVersionMockedStatic.verify(ApiVersion::versions);
        apiVersionMockedStatic.verifyNoMoreInteractions();
    }
    JsonArrayBuilder jsonArrayBuilder = Json.createArrayBuilder();
    versions.stream().sorted().map(String::valueOf).forEach(v -> jsonArrayBuilder.add(v));
    JsonArray expected = jsonArrayBuilder.build();
    assertThat(result).containsExactlyElementsOf(expected);
}
Also used : JsonArray(jakarta.json.JsonArray) ApiVersion(com.quorum.tessera.version.ApiVersion) JsonArrayBuilder(jakarta.json.JsonArrayBuilder) Test(org.junit.Test)

Aggregations

ApiVersion (com.quorum.tessera.version.ApiVersion)2 JsonArray (jakarta.json.JsonArray)2 JsonArrayBuilder (jakarta.json.JsonArrayBuilder)2 Test (org.junit.Test)2