@SuppressWarnings("unchecked") @Test public void testRepresentValidOrg() throws ResourceException, IOException { final Variant variant = context.mock(Variant.class); final List<BackgroundItem> capabilities = new ArrayList(1); capabilities.add(backgrounItemMock); final Set<Person> coordinators = new HashSet<Person>(); coordinators.add(personMock); setupCommonInitExpectations("validOrg"); context.checking(new Expectations() { { oneOf(entityMapper).findByShortName(with(any(String.class))); will(returnValue(orgMock)); oneOf(orgMock).getCapabilities(); will(returnValue(capabilities)); oneOf(backgrounItemMock).getName(); will(returnValue("testCapability")); oneOf(orgMock).getCoordinators(); will(returnValue(coordinators)); oneOf(personMock).getOpenSocialId(); will(returnValue("testAcctountId")); } }); sut.init(restContext, request, response); Representation actual = sut.represent(variant); assertEquals("MediaType should be application/json", MediaType.APPLICATION_JSON, actual.getMediaType()); JSONObject json = JSONObject.fromObject(actual.getText()); JSONArray results = json.getJSONArray(CompositeEntityCapabilityResource.CAP_ARRAY_KEY); assertNotNull("JSON text isn't right", results); assertEquals("JSON array size isn't right", 1, results.size()); results = json.getJSONArray(CompositeEntityCapabilityResource.COORD_ARRAY_KEY); assertNotNull("JSON text isn't right", results); assertEquals("JSON array size isn't right", 1, results.size()); context.assertIsSatisfied(); }
@Override public Representation represent(final Variant variant) throws ResourceException { verifyEntityShortNameParam(); CompositeEntity ent = this.getEntityByShortName(entityShortName); Representation rep = new StringRepresentation(convertEntityToJSONObject(ent).toString(), MediaType.APPLICATION_JSON); rep.setExpirationDate(new Date(0L)); return rep; }
CompositeEntityCapabilityResource extends WritableResource { @Override public Representation represent(final Variant variant) throws ResourceException { verifyEntityShortNameParam(); CompositeEntity ent = this.getEntityByShortName(entityShortName); Representation rep = new StringRepresentation(convertEntityToJSONObject(ent).toString(), MediaType.APPLICATION_JSON); rep.setExpirationDate(new Date(0L)); return rep; } }
CompositeEntityCapabilityResource extends WritableResource { @Override public Representation represent(final Variant variant) throws ResourceException { verifyEntityShortNameParam(); CompositeEntity ent = this.getEntityByShortName(entityShortName); Representation rep = new StringRepresentation(convertEntityToJSONObject(ent).toString(), MediaType.APPLICATION_JSON); rep.setExpirationDate(new Date(0L)); return rep; }  }
CompositeEntityCapabilityResource extends WritableResource { @Override public Representation represent(final Variant variant) throws ResourceException { verifyEntityShortNameParam(); CompositeEntity ent = this.getEntityByShortName(entityShortName); Representation rep = new StringRepresentation(convertEntityToJSONObject(ent).toString(), MediaType.APPLICATION_JSON); rep.setExpirationDate(new Date(0L)); return rep; }  void setEntityMapper(final CompositeEntityMapper inEntMapper); @Override Representation represent(final Variant variant); @Override void storeRepresentation(final Representation entity); JSONObject convertEntityToJSONObject(final CompositeEntity inEntInfo); }
CompositeEntityCapabilityResource extends WritableResource { @Override public Representation represent(final Variant variant) throws ResourceException { verifyEntityShortNameParam(); CompositeEntity ent = this.getEntityByShortName(entityShortName); Representation rep = new StringRepresentation(convertEntityToJSONObject(ent).toString(), MediaType.APPLICATION_JSON); rep.setExpirationDate(new Date(0L)); return rep; }  void setEntityMapper(final CompositeEntityMapper inEntMapper); @Override Representation represent(final Variant variant); @Override void storeRepresentation(final Representation entity); JSONObject convertEntityToJSONObject(final CompositeEntity inEntInfo); static final String CAP_ARRAY_KEY; static final String COORD_ARRAY_KEY; static final String URL_SHORTNAME_KEY; }