Skip to content

Commit

Permalink
Add unit test for #26
Browse files Browse the repository at this point in the history
  • Loading branch information
hdpe committed Jul 8, 2018
1 parent 4e2cce6 commit 706a184
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.util.List;

import org.junit.Before;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
Expand Down Expand Up @@ -108,6 +109,9 @@ public abstract static class AbstractClassTypeResource {
}

public interface InterfaceTypeResource {

@LinkedResource
List<Entity> linked();
}

private JavassistClientProxyFactory proxyFactory;
Expand Down Expand Up @@ -264,6 +268,21 @@ public void createWithResourceWithProxiedInterfaceContentReturnsProxy() throws E
assertThat(resource, is(allOf(isA(InterfaceTypeResource.class), not(sameInstance(content)))));
}

@Test
@Ignore
public void createWithResourceWithProxiedInterfaceContentReturnsProxyWithLinkedResources() throws Exception {
InterfaceTypeResource content = instantiateProxyOfInterfaceType(InterfaceTypeResource.class);

when(restOperations.getResources(URI.create("http://www.example.com/association/linked"),
Entity.class)).thenReturn(new Resources<>(asList(new Resource<>(new Entity(),
new Link("http://www.example.com/1", Link.REL_SELF)))));

InterfaceTypeResource resource = proxyFactory.create(new Resource<>(content,
new Link("http://www.example.com/association/linked", "linked")), restOperations);

assertThat(resource.linked().get(0).getId(), is(URI.create("http://www.example.com/1")));
}

@Test
public void createWithUnconstructableEntityResourceThrowsException() {
thrown.expect(ClientProxyException.class);
Expand Down

0 comments on commit 706a184

Please sign in to comment.