Search in sources :

Example 6 with TestJSONHelper

use of com.mercedesbenz.sechub.integrationtest.internal.TestJSONHelper in project sechub by mercedes-benz.

the class DeveloperAdministration method fetchProjectDescription.

public String fetchProjectDescription(String projectId) {
    String json = fetchProjectInfo(projectId);
    TestJSONHelper jsonHelper = TestJSONHelper.get();
    JsonNode jsonNode = jsonHelper.readTree(json);
    return jsonNode.get("description").textValue();
}
Also used : TestJSONHelper(com.mercedesbenz.sechub.integrationtest.internal.TestJSONHelper) JsonNode(com.fasterxml.jackson.databind.JsonNode)

Example 7 with TestJSONHelper

use of com.mercedesbenz.sechub.integrationtest.internal.TestJSONHelper in project sechub by mercedes-benz.

the class DeveloperAdministration method fetchProjectMetaData.

public String fetchProjectMetaData(String projectId) {
    String json = getRestHelper().getJSON(getUrlBuilder().buildAdminFetchProjectInfoUrl(projectId));
    TestJSONHelper jsonHelper = TestJSONHelper.get();
    JsonNode jsonNode = jsonHelper.readTree(json);
    JsonNode metaData = jsonNode.get("metaData");
    return metaData.toPrettyString();
}
Also used : TestJSONHelper(com.mercedesbenz.sechub.integrationtest.internal.TestJSONHelper) JsonNode(com.fasterxml.jackson.databind.JsonNode)

Example 8 with TestJSONHelper

use of com.mercedesbenz.sechub.integrationtest.internal.TestJSONHelper in project sechub by mercedes-benz.

the class CreateOverviewCSVExportAction method loadUserIds.

private List<String> loadUserIds() {
    String data = getContext().getAdministration().fetchUserList();
    TestJSONHelper jsonHelper = TestJSONHelper.get();
    JsonNode tree = jsonHelper.readTree(data);
    List<String> ids = new ArrayList<>();
    Iterator<JsonNode> iditerator = tree.elements();
    while (iditerator.hasNext()) {
        JsonNode dNode = iditerator.next();
        ids.add(dNode.asText());
    }
    outputAsTextOnSuccess("Found " + ids.size() + " users in system.");
    return ids;
}
Also used : ArrayList(java.util.ArrayList) TestJSONHelper(com.mercedesbenz.sechub.integrationtest.internal.TestJSONHelper) JsonNode(com.fasterxml.jackson.databind.JsonNode)

Example 9 with TestJSONHelper

use of com.mercedesbenz.sechub.integrationtest.internal.TestJSONHelper in project sechub by mercedes-benz.

the class CreateOverviewCSVExportAction method loadProjectIds.

private List<String> loadProjectIds() {
    String data = getContext().getAdministration().fetchProjectList();
    TestJSONHelper jsonHelper = TestJSONHelper.get();
    JsonNode tree = jsonHelper.readTree(data);
    List<String> projectIds = new ArrayList<>();
    Iterator<JsonNode> projectIditerator = tree.elements();
    while (projectIditerator.hasNext()) {
        JsonNode projectIdNode = projectIditerator.next();
        projectIds.add(projectIdNode.asText());
    }
    outputAsTextOnSuccess("Found " + projectIds.size() + " projects in system.");
    return projectIds;
}
Also used : ArrayList(java.util.ArrayList) TestJSONHelper(com.mercedesbenz.sechub.integrationtest.internal.TestJSONHelper) JsonNode(com.fasterxml.jackson.databind.JsonNode)

Example 10 with TestJSONHelper

use of com.mercedesbenz.sechub.integrationtest.internal.TestJSONHelper in project sechub by mercedes-benz.

the class DeveloperAdministration method createProject.

public String createProject(String projectId, String description, String owner, List<String> whiteListURLs, Map<String, String> metaData) {
    /* @formatter:off */
    StringBuilder json = new StringBuilder();
    if (description == null) {
        description = "";
    }
    TestJSONHelper jsonHelper = TestJSONHelper.get();
    json.append("{\n" + " \"apiVersion\":\"1.0\",\n" + " \"name\":\"" + projectId + "\",\n" + " \"owner\":\"" + owner + "\",\n" + " \"description\":\"" + description + "\"");
    if (!whiteListURLs.isEmpty()) {
        json.append(",\n \"whiteList\" : {\"uris\":[");
        for (Iterator<String> it = whiteListURLs.iterator(); it.hasNext(); ) {
            String url = it.next();
            json.append("\"" + url + "\"");
            if (it.hasNext()) {
                json.append(",");
            }
        }
        json.append("]\n");
        json.append("                 }\n");
    }
    if (!metaData.isEmpty()) {
        json.append(",\n \"metaData\" : {\n");
        for (Iterator<Map.Entry<String, String>> it = metaData.entrySet().iterator(); it.hasNext(); ) {
            Map.Entry<String, String> pair = it.next();
            String key = pair.getKey();
            String value = pair.getValue();
            json.append("\"" + key + "\":\"" + value + "\"");
            if (it.hasNext()) {
                json.append(",\n");
            }
        }
        json.append("\n}\n");
    }
    json.append("}\n");
    jsonHelper.assertValidJson(json.toString());
    /* @formatter:on */
    return getRestHelper().postJson(getUrlBuilder().buildAdminCreatesProjectUrl(), json.toString());
}
Also used : TestJSONHelper(com.mercedesbenz.sechub.integrationtest.internal.TestJSONHelper) Map(java.util.Map)

Aggregations

TestJSONHelper (com.mercedesbenz.sechub.integrationtest.internal.TestJSONHelper)11 JsonNode (com.fasterxml.jackson.databind.JsonNode)8 ArrayList (java.util.ArrayList)4 Map (java.util.Map)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 TypeReference (com.fasterxml.jackson.core.type.TypeReference)1 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)1 Grid (com.mercedesbenz.sechub.developertools.admin.export.Grid)1 Row (com.mercedesbenz.sechub.developertools.admin.export.Row)1 TestURLBuilder (com.mercedesbenz.sechub.test.TestURLBuilder)1 BufferedWriter (java.io.BufferedWriter)1 IOException (java.io.IOException)1 Path (java.nio.file.Path)1 SortedMap (java.util.SortedMap)1 TreeMap (java.util.TreeMap)1