use of net.nemerosa.ontrack.client.ClientNotFoundException in project ontrack by nemerosa.
the class ArtifactoryClientImpl method getBuildNumbers.
@Override
public List<String> getBuildNumbers(String buildName) {
try {
JsonNode node = jsonClient.get("/api/build/%s", buildName);
List<String> numbers = new ArrayList<>();
node.path("buildsNumbers").forEach((JsonNode numberNode) -> {
String number = StringUtils.stripStart(numberNode.path("uri").asText(), "/");
if (StringUtils.isNotBlank(number)) {
numbers.add(number);
}
});
return numbers;
} catch (ClientNotFoundException ex) {
// When the build is not defined, returns no build number
return Collections.emptyList();
}
}
use of net.nemerosa.ontrack.client.ClientNotFoundException in project ontrack by nemerosa.
the class ArtifactoryClientImplTest method buildNumbersEmptyForBuildNotFound.
@Test
public void buildNumbersEmptyForBuildNotFound() {
JsonClient jsonClient = mock(JsonClient.class);
when(jsonClient.get("/api/build/%s", "PROJECT")).thenThrow(new ClientNotFoundException("Not found"));
ArtifactoryClientImpl client = new ArtifactoryClientImpl(jsonClient);
assertEquals(Collections.<String>emptyList(), client.getBuildNumbers("PROJECT"));
}
Aggregations