SafeUtils { public List<String> getPoliciesForManagedSafes(JsonNode policiesNode) throws JsonProcessingException, IOException { List<String> adminPolicies = new ArrayList<String>(); if (!ObjectUtils.isEmpty(policiesNode)) { if (policiesNode.isContainerNode()) { Iterator<JsonNode> elementsIterator = policiesNode.elements(); while (elementsIterator.hasNext()) { JsonNode element = elementsIterator.next(); String policy = element.asText(); if (!StringUtils.isEmpty(policy) && policy.startsWith("s_")) { adminPolicies.add(element.asText()); } } } } return adminPolicies; } SafeUtils(); List<String> getPoliciesForManagedSafes(JsonNode policiesNode); String[] getManagedSafes(String[] policies, String safeType); boolean canAddOrRemoveUser(UserDetails userDetails, SafeUser safeUser, String action); Safe getSafeMetaData(String token, String safeType, String safeName); Safe getSafeInfo(JsonNode dataNode);  }
@Test public void test_getPoliciesForManagedSafes_successfully() throws IOException { ObjectMapper objMapper = new ObjectMapper(); Response response = getMockResponse(HttpStatus.OK, true, "{\"client_token\":\"8zyIbj3i9hXJFuIPC5AzeUK3\",\"admin\":\"no\",\"access\":{},\"policies\":[\"approle_normal_user\",\"default\",\"s_users_ert\"],\"lease_duration\":1800000}"); JsonNode policiesJsonNode = objMapper.readTree(response.getResponse().toString()).get("policies"); List<String> expectedAdminPolicies = new ArrayList<>(); expectedAdminPolicies.add("s_users_ert"); List<String> adminPolicies = safeUtils.getPoliciesForManagedSafes(policiesJsonNode); assertEquals(expectedAdminPolicies, adminPolicies); }