Skip to content

Commit

Permalink
fix: PR change requests 2
Browse files Browse the repository at this point in the history
Signed-off-by: Zvi Grinberg <zgrinber@redhat.com>
  • Loading branch information
zvigrinberg committed Dec 12, 2023
1 parent 68ed319 commit 0b73636
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import java.util.*;

import org.apache.camel.Body;
import org.apache.camel.Exchange;

import com.redhat.exhort.integration.providers.ProviderResponseHandler;
import com.redhat.exhort.model.DependencyTree;
Expand All @@ -36,13 +35,11 @@
@RegisterForReflection
public class TcResponseHandler extends ProviderResponseHandler {

// ObjectMapper mapper = ObjectMapperProducer.newInstance();

public Map<String, String> responseToMap(@Body Map<String, Map<String, List>> tcResponse)
throws IOException {
HashMap<String, String> recommendations = new HashMap<>();

Map<String, List> rec = (Map<String, List>) tcResponse.get("recommendations");
Map<String, List> rec = tcResponse.get("recommendations");
rec.entrySet().stream()
.forEach(
(entry) -> {
Expand All @@ -54,12 +51,6 @@ public Map<String, String> responseToMap(@Body Map<String, Map<String, List>> tc
return recommendations;
}

@Override
public void processResponseError(Exchange exchange) {
super.processResponseError(exchange);
exchange.getMessage().setBody(Map.of("recommendations", Map.of()));
}

@Override
protected String getProviderName() {
return "TrustedContent";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import jakarta.ws.rs.HttpMethod;
import jakarta.ws.rs.core.MediaType;

@ApplicationScoped
Expand All @@ -57,7 +58,7 @@ public void configure() {
.marshal()
.json()
.setHeader(Exchange.HTTP_PATH, constant(Constants.TRUSTED_CONTENT_PATH))
.setHeader(Exchange.HTTP_METHOD, constant("POST"))
.setHeader(Exchange.HTTP_METHOD, constant(HttpMethod.POST))
.setHeader(Exchange.CONTENT_TYPE, constant(MediaType.APPLICATION_JSON))
.circuitBreaker()
.faultToleranceConfiguration()
Expand All @@ -69,8 +70,8 @@ public void configure() {
.json(JsonLibrary.Jackson, Map.class)
.endCircuitBreaker()
.onFallback()
.setBody(constant(Map.of("recommendations", Map.of())))
.process(responseHandler::processResponseError)
.setBody(constant(Map.of("recommendations", Map.of())))
.end();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,6 @@ protected void stubTrustedContentRequests() {
server.stubFor(
post(Constants.TRUSTED_CONTENT_PATH)
.willReturn(aResponse().withStatus(200).withBody("{ \"recommendations\": {}\n" + "}")));
server.stubFor(
get(Constants.TRUSTED_CONTENT_PATH)
.willReturn(aResponse().withStatus(200).withBody("{ \"recommendations\": {}\n" + "}")));
}

protected void stubSnykRequests() {
Expand Down

0 comments on commit 0b73636

Please sign in to comment.