@Test public void testComplexType() { Java8ComplexType value = new Java8ComplexType( Optional.of( new Java8ComplexType( Optional.empty(), Optional.empty(), Paths.get("bar"))), Optional.of("baz"), Paths.get("foo")); // Hint: set breakpoint in Feign's SynchronousMethodHandler#executeAndDecode to inspect serialized parameter. assertThat(service.getJava8ComplexType(value), is(value)); } }
@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 testList() { assertThat(service.getNullList()).isEmpty(); }
@Test public void testSet() { assertThat(service.getNullSet()).isEmpty(); }
@Test public void testOptional() { assertThat(service.getOptional("something"), is(Optional.of(ImmutableMap.of("something", "something")))); assertThat(service.getOptional(null), is(Optional.<ImmutableMap<String, String>>empty())); }
@Test public void testOptionalString() { assertThat(service.getOptionalString(null), is(Optional.empty())); assertThat(service.getOptionalString("foo"), is(Optional.of("foo"))); }
@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 testOptionalThrowsFordidden() { 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 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 testMap() { assertThat(service.getNullMap()).isEmpty(); } }