use of org.apache.archiva.components.rest.model.PagedResult in project archiva by apache.
the class NativeRepositoryGroupServiceTest method testRemoveRepositoryFromGroup404.
@Test
void testRemoveRepositoryFromGroup404() {
String token = getAdminToken();
try {
Map<String, Object> jsonAsMap = new HashMap<>();
jsonAsMap.put("id", "group_001");
jsonAsMap.put("name", "group_001");
jsonAsMap.put("repositories", Arrays.asList("internal"));
Response response = given().spec(getRequestSpec(token)).contentType(JSON).when().body(jsonAsMap).post("").prettyPeek().then().statusCode(201).extract().response();
assertNotNull(response);
RepositoryGroup result = response.getBody().jsonPath().getObject("", RepositoryGroup.class);
assertNotNull(result);
response = given().spec(getRequestSpec(token)).contentType(JSON).when().get("").then().statusCode(200).extract().response();
assertNotNull(response);
PagedResult resultList = response.getBody().jsonPath().getObject("", PagedResult.class);
assertEquals(1, resultList.getPagination().getTotalCount());
assertNotNull(result.getRepositories());
assertEquals(1, result.getRepositories().size());
assertTrue(result.getRepositories().contains("internal"));
response = given().spec(getRequestSpec(token)).contentType(JSON).when().body(jsonAsMap).delete("group_001/repositories/internalxx").prettyPeek().then().statusCode(404).extract().response();
assertNotNull(response);
ArchivaRestError error = response.getBody().jsonPath().getObject("", ArchivaRestError.class);
assertNotNull(error);
} finally {
given().spec(getRequestSpec(token)).contentType(JSON).when().delete("group_001");
}
}
use of org.apache.archiva.components.rest.model.PagedResult in project archiva by apache.
the class NativeRepositoryGroupServiceTest method testRemoveRepositoryGroup.
@Test
void testRemoveRepositoryGroup() {
String token = getAdminToken();
List<String> groups = new ArrayList<>();
try {
for (int i = 0; i < 10; i++) {
String groupName = String.format("group_%03d", i);
groups.add(groupName);
Map<String, Object> jsonAsMap = new HashMap<>();
jsonAsMap.put("id", groupName);
jsonAsMap.put("name", groupName);
Response response = given().spec(getRequestSpec(token)).contentType(JSON).when().body(jsonAsMap).post("").then().statusCode(201).extract().response();
assertNotNull(response);
RepositoryGroup result = response.getBody().jsonPath().getObject("", RepositoryGroup.class);
assertNotNull(result);
}
Response response = given().spec(getRequestSpec(token)).contentType(JSON).when().delete("group_001").then().statusCode(200).extract().response();
assertNotNull(response);
response = given().spec(getRequestSpec(token)).contentType(JSON).when().get("").then().statusCode(200).extract().response();
assertNotNull(response);
PagedResult resultList = response.getBody().jsonPath().getObject("", PagedResult.class);
assertEquals(9, resultList.getPagination().getTotalCount());
response = given().spec(getRequestSpec(token)).contentType(JSON).when().delete("group_005").then().statusCode(200).extract().response();
assertNotNull(response);
response = given().spec(getRequestSpec(token)).contentType(JSON).when().get("").then().statusCode(200).extract().response();
assertNotNull(response);
resultList = response.getBody().jsonPath().getObject("", PagedResult.class);
assertEquals(8, resultList.getPagination().getTotalCount());
} finally {
for (String groupName : groups) {
if (!("group_001".equals(groupName) || "group_005".equals(groupName))) {
given().spec(getRequestSpec(token)).contentType(JSON).when().delete(groupName);
}
}
}
}
use of org.apache.archiva.components.rest.model.PagedResult in project archiva by apache.
the class NativeRepositoryGroupServiceTest method testAddMultipleGroups.
@Test
void testAddMultipleGroups() {
String token = getAdminToken();
List<String> groups = new ArrayList<>();
try {
for (int i = 0; i < 10; i++) {
String groupName = String.format("group_%03d", i);
groups.add(groupName);
Map<String, Object> jsonAsMap = new HashMap<>();
jsonAsMap.put("id", groupName);
jsonAsMap.put("name", groupName);
Response response = given().spec(getRequestSpec(token)).contentType(JSON).when().body(jsonAsMap).post("").then().statusCode(201).extract().response();
assertNotNull(response);
RepositoryGroup result = response.getBody().jsonPath().getObject("", RepositoryGroup.class);
assertNotNull(result);
}
Response response = given().spec(getRequestSpec(token)).contentType(JSON).when().get("").then().statusCode(200).extract().response();
assertNotNull(response);
PagedResult resultList = response.getBody().jsonPath().getObject("", PagedResult.class);
assertEquals(10, resultList.getPagination().getTotalCount());
} finally {
for (String groupName : groups) {
given().spec(getRequestSpec(token)).contentType(JSON).when().delete(groupName);
}
}
}
use of org.apache.archiva.components.rest.model.PagedResult in project archiva by apache.
the class NativeRepositoryGroupServiceTest method testRemoveRepositoryFromGroup.
@Test
void testRemoveRepositoryFromGroup() {
String token = getAdminToken();
try {
Map<String, Object> jsonAsMap = new HashMap<>();
jsonAsMap.put("id", "group_001");
jsonAsMap.put("name", "group_001");
jsonAsMap.put("repositories", Arrays.asList("internal"));
Response response = given().spec(getRequestSpec(token)).contentType(JSON).when().body(jsonAsMap).post("").prettyPeek().then().statusCode(201).extract().response();
assertNotNull(response);
RepositoryGroup result = response.getBody().jsonPath().getObject("", RepositoryGroup.class);
assertNotNull(result);
response = given().spec(getRequestSpec(token)).contentType(JSON).when().get("").then().statusCode(200).extract().response();
assertNotNull(response);
PagedResult resultList = response.getBody().jsonPath().getObject("", PagedResult.class);
assertEquals(1, resultList.getPagination().getTotalCount());
assertNotNull(result.getRepositories());
assertEquals(1, result.getRepositories().size());
assertTrue(result.getRepositories().contains("internal"));
response = given().spec(getRequestSpec(token)).contentType(JSON).when().body(jsonAsMap).delete("group_001/repositories/internal").prettyPeek().then().statusCode(200).extract().response();
assertNotNull(response);
result = response.getBody().jsonPath().getObject("", RepositoryGroup.class);
assertNotNull(result);
assertEquals(0, result.getRepositories().size());
} finally {
given().spec(getRequestSpec(token)).contentType(JSON).when().delete("group_001").then().statusCode(200);
}
}
Aggregations