@Override public List<EDITOR> readAll(CONTEXT context) { Response response = context .getSession() .given() .contentType(getContentType()) .header(Headers.acceptJson()) .get( "/rest/applications/{variantID}/installations", context.getParent().getVariantID()); UnexpectedResponseException.verifyResponse(response, HttpStatus.SC_OK); List<EDITOR> editors = new ArrayList<EDITOR>(); JsonPath jsonPath = response.jsonPath(); List<Map<String, ?>> items = jsonPath.getList(""); for (int i = 0; i < items.size(); i++) { jsonPath.setRoot("[" + i + "]"); EDITOR editor = demarshall(context, jsonPath); editors.add(editor); } return editors; }
@Override public EDITOR demarshall(CONTEXT context, JsonPath jsonPath) { EDITOR editor = context.createEditor(); editor.setId(jsonPath.getString("id")); editor.setPlatform(jsonPath.getString("platform")); editor.setEnabled(jsonPath.getBoolean("enabled")); editor.setOperatingSystem(jsonPath.getString("operatingSystem")); editor.setOsVersion(jsonPath.getString("osVersion")); editor.setAlias(jsonPath.getString("alias")); editor.setDeviceType(jsonPath.getString("deviceType")); editor.setDeviceToken(jsonPath.getString("deviceToken")); editor.setSimplePushEndpoint(jsonPath.getString("simplePushEndpoint")); HashSet<String> categories = new HashSet<String>(); List<String> jsonCategories = jsonPath.getList("categories"); if (jsonCategories != null) { for (String jsonCategory : jsonCategories) { categories.add(jsonCategory); } } editor.setCategories(categories); return editor; }