@Test public void testCreateObj() { final Obj obj = mock(Obj.class); final Obj resultObj = mock(Obj.class); when(restTemplate.postForObject(eq(Obj.CREATE_WITH_ID_URI), eq(obj), Matchers.<Class<Obj>>any(), eq(PROJECT_ID))) .thenReturn(resultObj); final Obj result = service.createObj(project, obj); assertThat(result, is(notNullValue())); }
@SuppressWarnings("unchecked") public <T extends Obj> T createObj(Project project, T obj) { notNull(project, "project"); notNull(project.getId(), "project.id"); notNull(obj, "obj"); final T response; try { response = restTemplate.postForObject(Obj.CREATE_WITH_ID_URI, obj, (Class<T>)obj.getClass(), project.getId()); } catch (GoodDataRestException | RestClientException e) { throw new ObjCreateException(obj, e); } if (response == null) { throw new ObjCreateException("Received empty response from API call.", obj); } return response; }
MetadataService extends AbstractService { @SuppressWarnings("unchecked") public <T extends Obj> T createObj(Project project, T obj) { notNull(project, "project"); notNull(project.getId(), "project.id"); notNull(obj, "obj"); final T response; try { response = restTemplate.postForObject(Obj.CREATE_WITH_ID_URI, obj, (Class<T>)obj.getClass(), project.getId()); } catch (GoodDataRestException | RestClientException e) { throw new ObjCreateException(obj, e); } if (response == null) { throw new ObjCreateException("Received empty response from API call.", obj); } return response; } }
MetadataService extends AbstractService { @SuppressWarnings("unchecked") public <T extends Obj> T createObj(Project project, T obj) { notNull(project, "project"); notNull(project.getId(), "project.id"); notNull(obj, "obj"); final T response; try { response = restTemplate.postForObject(Obj.CREATE_WITH_ID_URI, obj, (Class<T>)obj.getClass(), project.getId()); } catch (GoodDataRestException | RestClientException e) { throw new ObjCreateException(obj, e); } if (response == null) { throw new ObjCreateException("Received empty response from API call.", obj); } return response; } MetadataService(final RestTemplate restTemplate, final GoodDataSettings settings); }
MetadataService extends AbstractService { @SuppressWarnings("unchecked") public <T extends Obj> T createObj(Project project, T obj) { notNull(project, "project"); notNull(project.getId(), "project.id"); notNull(obj, "obj"); final T response; try { response = restTemplate.postForObject(Obj.CREATE_WITH_ID_URI, obj, (Class<T>)obj.getClass(), project.getId()); } catch (GoodDataRestException | RestClientException e) { throw new ObjCreateException(obj, e); } if (response == null) { throw new ObjCreateException("Received empty response from API call.", obj); } return response; } MetadataService(final RestTemplate restTemplate, final GoodDataSettings settings); @SuppressWarnings("unchecked") T createObj(Project project, T obj); T getObjByUri(String uri, Class<T> cls); Collection<Obj> getObjsByUris(Project project, Collection<String> uris); @SuppressWarnings("unchecked") T updateObj(T obj); void removeObj(Obj obj); void removeObjByUri(String uri); T getObjById(Project project, String id, Class<T> cls); String getObjUri(Project project, Class<T> cls, Restriction... restrictions); T getObj(Project project, Class<T> cls, Restriction... restrictions); Collection<Entry> find(Project project, Class<T> cls, Restriction... restrictions); Collection<String> findUris(Project project,
                                                             Class<T> cls,
                                                             Restriction... restrictions); @SuppressWarnings("unchecked") Collection<Entry> usedBy(Project project, Obj obj, boolean nearest, Class<? extends Obj>... types); @SuppressWarnings("unchecked") Collection<Entry> usedBy(Project project, String uri, boolean nearest, Class<? extends Obj>... types); @SuppressWarnings("unchecked") Collection<Usage> usedBy(Project project, Collection<String> uris, boolean nearest, Class<? extends Obj>... types); Collection<String> findUris(Project project, Restriction... restrictions); Map<String, String> identifiersToUris(Project project, Collection<String> identifiers); List<AttributeElement> getAttributeElements(Attribute attribute); List<AttributeElement> getAttributeElements(DisplayForm displayForm); }
MetadataService extends AbstractService { @SuppressWarnings("unchecked") public <T extends Obj> T createObj(Project project, T obj) { notNull(project, "project"); notNull(project.getId(), "project.id"); notNull(obj, "obj"); final T response; try { response = restTemplate.postForObject(Obj.CREATE_WITH_ID_URI, obj, (Class<T>)obj.getClass(), project.getId()); } catch (GoodDataRestException | RestClientException e) { throw new ObjCreateException(obj, e); } if (response == null) { throw new ObjCreateException("Received empty response from API call.", obj); } return response; } MetadataService(final RestTemplate restTemplate, final GoodDataSettings settings); @SuppressWarnings("unchecked") T createObj(Project project, T obj); T getObjByUri(String uri, Class<T> cls); Collection<Obj> getObjsByUris(Project project, Collection<String> uris); @SuppressWarnings("unchecked") T updateObj(T obj); void removeObj(Obj obj); void removeObjByUri(String uri); T getObjById(Project project, String id, Class<T> cls); String getObjUri(Project project, Class<T> cls, Restriction... restrictions); T getObj(Project project, Class<T> cls, Restriction... restrictions); Collection<Entry> find(Project project, Class<T> cls, Restriction... restrictions); Collection<String> findUris(Project project,
                                                             Class<T> cls,
                                                             Restriction... restrictions); @SuppressWarnings("unchecked") Collection<Entry> usedBy(Project project, Obj obj, boolean nearest, Class<? extends Obj>... types); @SuppressWarnings("unchecked") Collection<Entry> usedBy(Project project, String uri, boolean nearest, Class<? extends Obj>... types); @SuppressWarnings("unchecked") Collection<Usage> usedBy(Project project, Collection<String> uris, boolean nearest, Class<? extends Obj>... types); Collection<String> findUris(Project project, Restriction... restrictions); Map<String, String> identifiersToUris(Project project, Collection<String> identifiers); List<AttributeElement> getAttributeElements(Attribute attribute); List<AttributeElement> getAttributeElements(DisplayForm displayForm); static final UriTemplate OBJ_TEMPLATE; }