@Test(expected = RuntimeException.class) public void testTransformUnhandledType() { final JSONObject request = new JSONObject(); final JSONObject personObj = new JSONObject(); personObj.accumulate("type", "NOTSET"); personObj.accumulate("name", "something"); JSONArray recipientArr = new JSONArray(); recipientArr.add(personObj); request.accumulate(key, recipientArr); sut.transform(request, 0L); }
public Serializable transform(final JSONObject request, final Long userEntityId) { JSONArray entities = request.getJSONArray(reqKey); List<String> accountIds = new ArrayList<String>(); for (int i = 0; i < entities.size(); i++) { JSONObject req = entities.getJSONObject(i); EntityType type = EntityType.valueOf(req.getString("type")); switch (type) { case PERSON: accountIds.add(req.getString("name")); break; default: throw new IllegalArgumentException("Unhandled type."); } } return new ArrayList<Long>(getPeopleIdsByAccountIdsMapper.execute(accountIds)); }
MultiUserPersistenceRequestTransformer implements PersistenceDataSourceRequestTransformer { public Serializable transform(final JSONObject request, final Long userEntityId) { JSONArray entities = request.getJSONArray(reqKey); List<String> accountIds = new ArrayList<String>(); for (int i = 0; i < entities.size(); i++) { JSONObject req = entities.getJSONObject(i); EntityType type = EntityType.valueOf(req.getString("type")); switch (type) { case PERSON: accountIds.add(req.getString("name")); break; default: throw new IllegalArgumentException("Unhandled type."); } } return new ArrayList<Long>(getPeopleIdsByAccountIdsMapper.execute(accountIds)); } }
MultiUserPersistenceRequestTransformer implements PersistenceDataSourceRequestTransformer { public Serializable transform(final JSONObject request, final Long userEntityId) { JSONArray entities = request.getJSONArray(reqKey); List<String> accountIds = new ArrayList<String>(); for (int i = 0; i < entities.size(); i++) { JSONObject req = entities.getJSONObject(i); EntityType type = EntityType.valueOf(req.getString("type")); switch (type) { case PERSON: accountIds.add(req.getString("name")); break; default: throw new IllegalArgumentException("Unhandled type."); } } return new ArrayList<Long>(getPeopleIdsByAccountIdsMapper.execute(accountIds)); } MultiUserPersistenceRequestTransformer(
            final DomainMapper<List<String>, List<Long>> inGetPeopleIdsByAccountIdsMapper, final String inReqKey); }
MultiUserPersistenceRequestTransformer implements PersistenceDataSourceRequestTransformer { public Serializable transform(final JSONObject request, final Long userEntityId) { JSONArray entities = request.getJSONArray(reqKey); List<String> accountIds = new ArrayList<String>(); for (int i = 0; i < entities.size(); i++) { JSONObject req = entities.getJSONObject(i); EntityType type = EntityType.valueOf(req.getString("type")); switch (type) { case PERSON: accountIds.add(req.getString("name")); break; default: throw new IllegalArgumentException("Unhandled type."); } } return new ArrayList<Long>(getPeopleIdsByAccountIdsMapper.execute(accountIds)); } MultiUserPersistenceRequestTransformer(
            final DomainMapper<List<String>, List<Long>> inGetPeopleIdsByAccountIdsMapper, final String inReqKey); Serializable transform(final JSONObject request, final Long userEntityId); }
MultiUserPersistenceRequestTransformer implements PersistenceDataSourceRequestTransformer { public Serializable transform(final JSONObject request, final Long userEntityId) { JSONArray entities = request.getJSONArray(reqKey); List<String> accountIds = new ArrayList<String>(); for (int i = 0; i < entities.size(); i++) { JSONObject req = entities.getJSONObject(i); EntityType type = EntityType.valueOf(req.getString("type")); switch (type) { case PERSON: accountIds.add(req.getString("name")); break; default: throw new IllegalArgumentException("Unhandled type."); } } return new ArrayList<Long>(getPeopleIdsByAccountIdsMapper.execute(accountIds)); } MultiUserPersistenceRequestTransformer(
            final DomainMapper<List<String>, List<Long>> inGetPeopleIdsByAccountIdsMapper, final String inReqKey); Serializable transform(final JSONObject request, final Long userEntityId);  }