use of feign.mock.MockClient in project feign by OpenFeign.
the class AbstractMetricsTestBase method decoderExceptionCounterHasUriLabelWithPathExpression.
@Test
public void decoderExceptionCounterHasUriLabelWithPathExpression() {
final AtomicReference<FeignException.NotFound> notFound = new AtomicReference<>();
final SourceWithPathExpressions source = Feign.builder().client(new MockClient().ok(HttpMethod.GET, "/get/123", "1234567890abcde")).decoder((response, type) -> {
notFound.set(new FeignException.NotFound("test", response.request(), null, null));
throw notFound.get();
}).addCapability(createMetricCapability()).target(new MockTarget<>(MicrometerCapabilityTest.SourceWithPathExpressions.class));
FeignException.NotFound thrown = assertThrows(FeignException.NotFound.class, () -> source.get("123", "0x3456789"));
assertSame(notFound.get(), thrown);
final Map<METRIC_ID, METRIC> decoderMetrics = getFeignMetrics().entrySet().stream().filter(entry -> isDecoderMetric(entry.getKey())).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
decoderMetrics.keySet().forEach(metricId -> assertThat("Expect all Decoder metric names to include uri as aggregated path expression:" + metricId, doesMetricIncludeUri(metricId, "/get/{id}")));
}
use of feign.mock.MockClient in project feign by OpenFeign.
the class SpringContractTest method setup.
@Before
public void setup() throws IOException {
mockClient = new MockClient().noContent(HttpMethod.GET, "/health").noContent(HttpMethod.GET, "/health/1").noContent(HttpMethod.GET, "/health/1?deep=true").noContent(HttpMethod.GET, "/health/1?deep=true&dryRun=true").ok(HttpMethod.GET, "/health/generic", "{}");
resource = Feign.builder().contract(new SpringContract()).encoder(new JacksonEncoder()).decoder(new JacksonDecoder()).client(mockClient).target(new MockTarget<>(HealthResource.class));
}
use of feign.mock.MockClient in project feign by OpenFeign.
the class AbstractMetricsTestBase method decoderPropagatesUncheckedException.
@Test
public void decoderPropagatesUncheckedException() {
final AtomicReference<FeignException.NotFound> notFound = new AtomicReference<>();
final SimpleSource source = Feign.builder().client(new MockClient().ok(HttpMethod.GET, "/get", "1234567890abcde")).decoder((response, type) -> {
notFound.set(new FeignException.NotFound("test", response.request(), null, null));
throw notFound.get();
}).addCapability(createMetricCapability()).target(new MockTarget<>(MicrometerCapabilityTest.SimpleSource.class));
FeignException.NotFound thrown = assertThrows(FeignException.NotFound.class, () -> source.get("0x3456789"));
assertSame(notFound.get(), thrown);
}
use of feign.mock.MockClient in project feign by OpenFeign.
the class JsonCodecTest method setUp.
@Before
public void setUp() {
mockClient = new MockClient();
github = Feign.builder().decoder(new JsonDecoder()).encoder(new JsonEncoder()).client(mockClient).target(new MockTarget<>(GitHub.class));
}
Aggregations