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);
}
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);
}
Aggregations