BasicClient implements SLIClient { @Override public String create(final Entity e) throws IOException, URISyntaxException, SLIClientException { return create(e, null); } BasicClient(final RESTClient restClient); @Override String create(final Entity e); @Override String create(final Entity e, String resourceUrl); @Override void read(List<Entity> entities, final String type, final Query query); @Override void read(final List<Entity> entities, final String type, final String id, final Query query); @Override List<Entity> read(final String resourceUrl, Query query); @Override List<Entity> read(final String resourceUrl); @Override void update(final Entity e); @Override void delete(final String entityType, final String entityId); @Override void delete(Entity e); Response getResource(final List<Entity> entities, URL resourceURL, Query query); @Override Response getHomeResource(Entity home); String sessionCheck(final String token); @Override RESTClient getRESTClient();  }
@Test public void testCreate() throws IOException, URISyntaxException, SLIClientException { Entity e = new GenericEntity(ResourceNames.STUDENTS, studentData); Response r = mock(Response.class); when(r.getStatus()).thenReturn(201); when(r.getHeader("Location")).thenReturn("http: when(restClient.postRequest(any(URL.class), anyString())).thenReturn(r); assertEquals("42", underTest.create(e)); Entity e2 = new GenericEntity("", studentData); assertEquals("42", underTest.create(e2, "students")); assertEquals("42", underTest.create(e2, "/students")); assertEquals("42", underTest.create(e2, "http: verify(restClient, times(4)).postRequest(new URL("http: mapper.writeValueAsString(studentData)); Entity e3 = new GenericEntity("", resourceWithLinks); assertEquals(1, e3.getLinks().size()); Set<String> keySet = e3.getLinkMap().keySet(); assertEquals(1, keySet.size()); for (String key : keySet) { assertEquals("Google", key); assertEquals("http", e3.getLinkMap().get(key).getProtocol()); assertEquals("www.google.com", e3.getLinkMap().get(key).getHost()); } }