@Test public void testCborResponse() { GuavaOptionalComplexType value = new GuavaOptionalComplexType( com.google.common.base.Optional.of( new GuavaOptionalComplexType( com.google.common.base.Optional.absent(), com.google.common.base.Optional.absent(), Paths.get("bar"))), com.google.common.base.Optional.of("baz"), Paths.get("foo")); assertThat(service.getCborResponse(value), is(value)); }
@Test public void testComplexType() { GuavaOptionalComplexType value = new GuavaOptionalComplexType( com.google.common.base.Optional.of( new GuavaOptionalComplexType( com.google.common.base.Optional.absent(), com.google.common.base.Optional.absent(), Paths.get("bar"))), com.google.common.base.Optional.of("baz"), Paths.get("foo")); // Hint: set breakpoint in Feign's SynchronousMethodHandler#executeAndDecode to inspect serialized parameter. assertThat(service.getGuavaComplexType(value), is(value)); }
@Test public void testCannotReturnStringWithMediaTypeJson() throws Exception { assertThatThrownBy(() -> service.getJsonString("foo")) .isInstanceOf(FeignException.class) .hasMessageStartingWith("Unrecognized token 'foo': was expecting 'null', 'true', 'false' or NaN"); }
@Test public void testThrowsFordidden() { try { service.getThrowsForbidden(null); fail(); } catch (RemoteException e) { assertThat(e.getMessage(), containsString("RemoteException: PERMISSION_DENIED (Default:PermissionDenied)")); assertThat(e.getError().errorCode(), is("PERMISSION_DENIED")); } }
@Test public void testOptionalThrowsNotAuthorized() { try { service.getOptionalThrowsNotAuthorized(null); fail(); } catch (RemoteException e) { assertThat(e.getMessage(), containsString("RemoteException: javax.ws.rs.NotAuthorizedException")); assertThat(e.getError().errorCode(), is("javax.ws.rs.NotAuthorizedException")); } }
@Test public void testNonOptional() { assertThat(service.getNonOptional("something"), is(ImmutableMap.of("something", "something"))); assertThat(service.getNonOptional(null), is(ImmutableMap.<String, String>of())); }
@Test public void testOptionalThrowsForbbbden() { try { service.getOptionalThrowsForbidden(null); fail(); } catch (RemoteException e) { assertThat(e.getMessage(), containsString("RemoteException: PERMISSION_DENIED (Default:PermissionDenied)")); assertThat(e.getError().errorCode(), is("PERMISSION_DENIED")); } }
@Test public void testOptional() { assertThat(service.getOptional("something"), is(com.google.common.base.Optional.of(ImmutableMap.of("something", "something")))); assertThat(service.getOptional(null), is(com.google.common.base.Optional.<ImmutableMap<String, String>>absent())); }
@Test public void testOptionalString() { assertThat(service.getOptionalString(null), is(com.google.common.base.Optional.absent())); assertThat(service.getOptionalString("foo"), is(com.google.common.base.Optional.of("foo"))); }