Search in sources :

Example 1 with NetworkRecipe

use of org.onap.so.db.catalog.beans.NetworkRecipe in project so by onap.

the class NetworkRestHandler method findNetworkRecipe.

public Recipe findNetworkRecipe(String action) throws NoRecipeException {
    String modelName = "GR-API-DEFAULT";
    NetworkRecipe recipe = catalogDbClient.getFirstNetworkRecipeByModelNameAndAction(modelName, action);
    if (recipe == null) {
        throw new NoRecipeException(String.format("Unable to locate default recipe for, Action: %s, Model Name: %s", action, modelName));
    }
    return recipe;
}
Also used : NetworkRecipe(org.onap.so.db.catalog.beans.NetworkRecipe) NoRecipeException(org.onap.so.apihandlerinfra.infra.rest.exception.NoRecipeException)

Example 2 with NetworkRecipe

use of org.onap.so.db.catalog.beans.NetworkRecipe in project so by onap.

the class QueryResourceRecipeTest method convertToJsonEmptyRecipe.

@Test
public void convertToJsonEmptyRecipe() {
    QueryResourceRecipe vnfQueryRR = new QueryResourceRecipe(new VnfRecipe());
    QueryResourceRecipe networkQueryRR = new QueryResourceRecipe(new NetworkRecipe());
    QueryResourceRecipe arQueryRR = new QueryResourceRecipe(new ArRecipe());
    String expected = "{\"orchestrationUri\":\"\",\"action\":\"\",\"description\":\"\",\"id\":\"\",\"recipeTimeout\":\"\",\"paramXSD\":\"\"}";
    assertEquals(expected, vnfQueryRR.JSON2(false, false));
    assertEquals(expected, networkQueryRR.JSON2(false, false));
    assertEquals(expected, arQueryRR.JSON2(false, false));
}
Also used : ArRecipe(org.onap.so.db.catalog.beans.ArRecipe) NetworkRecipe(org.onap.so.db.catalog.beans.NetworkRecipe) VnfRecipe(org.onap.so.db.catalog.beans.VnfRecipe) Test(org.junit.Test)

Example 3 with NetworkRecipe

use of org.onap.so.db.catalog.beans.NetworkRecipe in project so by onap.

the class CatalogDbClient method postNetworkRecipe.

public void postNetworkRecipe(NetworkRecipe recipe) {
    try {
        HttpHeaders headers = getHttpHeaders();
        HttpEntity<NetworkRecipe> entity = new HttpEntity<>(recipe, headers);
        restTemplate.exchange(UriComponentsBuilder.fromUriString(endpoint + "/networkRecipe").build().encode().toString(), HttpMethod.POST, entity, NetworkRecipe.class).getBody();
    } catch (HttpClientErrorException e) {
        if (HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()) {
            throw new EntityNotFoundException("Unable to find NetworkRecipe with  Id: " + recipe.getId());
        }
        throw e;
    }
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) NetworkRecipe(org.onap.so.db.catalog.beans.NetworkRecipe) HttpClientErrorException(org.springframework.web.client.HttpClientErrorException) HttpEntity(org.springframework.http.HttpEntity) EntityNotFoundException(javax.persistence.EntityNotFoundException)

Aggregations

NetworkRecipe (org.onap.so.db.catalog.beans.NetworkRecipe)3 EntityNotFoundException (javax.persistence.EntityNotFoundException)1 Test (org.junit.Test)1 NoRecipeException (org.onap.so.apihandlerinfra.infra.rest.exception.NoRecipeException)1 ArRecipe (org.onap.so.db.catalog.beans.ArRecipe)1 VnfRecipe (org.onap.so.db.catalog.beans.VnfRecipe)1 HttpEntity (org.springframework.http.HttpEntity)1 HttpHeaders (org.springframework.http.HttpHeaders)1 HttpClientErrorException (org.springframework.web.client.HttpClientErrorException)1