@Test(expected = RuntimeException.class) public void testTransformInvalidId() { final String rqst = "{'fromApp':[{'name':'4;','type':'person'}]}"; final JSONObject request = (JSONObject) JSONSerializer.toJSON(rqst); String result = (String) sut.transform(request, null); }
@Override public Serializable transform(final JSONObject request, final Long userEntityId) { JSONArray apps = request.getJSONArray("fromApp"); StringBuilder queryTerm = new StringBuilder(); for (int i = 0; i < apps.size(); i++) { if (i > 0) { queryTerm.append(" "); } JSONObject app = apps.getJSONObject(i); char typePrefix = getTypePrefix(app); queryTerm.append(typePrefix); String appId = app.getString("name"); if (!APP_ID_REGEX.matcher(appId).matches()) { throw new IllegalArgumentException("Invalid app id."); } queryTerm.append(appId); } return queryTerm.toString(); }
AppSourcePersistenceRequestTransformer implements PersistenceDataSourceRequestTransformer { @Override public Serializable transform(final JSONObject request, final Long userEntityId) { JSONArray apps = request.getJSONArray("fromApp"); StringBuilder queryTerm = new StringBuilder(); for (int i = 0; i < apps.size(); i++) { if (i > 0) { queryTerm.append(" "); } JSONObject app = apps.getJSONObject(i); char typePrefix = getTypePrefix(app); queryTerm.append(typePrefix); String appId = app.getString("name"); if (!APP_ID_REGEX.matcher(appId).matches()) { throw new IllegalArgumentException("Invalid app id."); } queryTerm.append(appId); } return queryTerm.toString(); } }
AppSourcePersistenceRequestTransformer implements PersistenceDataSourceRequestTransformer { @Override public Serializable transform(final JSONObject request, final Long userEntityId) { JSONArray apps = request.getJSONArray("fromApp"); StringBuilder queryTerm = new StringBuilder(); for (int i = 0; i < apps.size(); i++) { if (i > 0) { queryTerm.append(" "); } JSONObject app = apps.getJSONObject(i); char typePrefix = getTypePrefix(app); queryTerm.append(typePrefix); String appId = app.getString("name"); if (!APP_ID_REGEX.matcher(appId).matches()) { throw new IllegalArgumentException("Invalid app id."); } queryTerm.append(appId); } return queryTerm.toString(); }  }
AppSourcePersistenceRequestTransformer implements PersistenceDataSourceRequestTransformer { @Override public Serializable transform(final JSONObject request, final Long userEntityId) { JSONArray apps = request.getJSONArray("fromApp"); StringBuilder queryTerm = new StringBuilder(); for (int i = 0; i < apps.size(); i++) { if (i > 0) { queryTerm.append(" "); } JSONObject app = apps.getJSONObject(i); char typePrefix = getTypePrefix(app); queryTerm.append(typePrefix); String appId = app.getString("name"); if (!APP_ID_REGEX.matcher(appId).matches()) { throw new IllegalArgumentException("Invalid app id."); } queryTerm.append(appId); } return queryTerm.toString(); }  @Override Serializable transform(final JSONObject request, final Long userEntityId); }
AppSourcePersistenceRequestTransformer implements PersistenceDataSourceRequestTransformer { @Override public Serializable transform(final JSONObject request, final Long userEntityId) { JSONArray apps = request.getJSONArray("fromApp"); StringBuilder queryTerm = new StringBuilder(); for (int i = 0; i < apps.size(); i++) { if (i > 0) { queryTerm.append(" "); } JSONObject app = apps.getJSONObject(i); char typePrefix = getTypePrefix(app); queryTerm.append(typePrefix); String appId = app.getString("name"); if (!APP_ID_REGEX.matcher(appId).matches()) { throw new IllegalArgumentException("Invalid app id."); } queryTerm.append(appId); } return queryTerm.toString(); }  @Override Serializable transform(final JSONObject request, final Long userEntityId);  }