use of org.gluu.oxtrust.api.server.model.GluuGroupApi in project oxTrust by GluuFederation.
the class GroupWebResourceTest method searchGroupTest.
@Test
public void searchGroupTest() {
String searchPattern = "manager";
String SEARCH_QUERY = "?" + ApiConstants.SEARCH_PATTERN + "=" + searchPattern + "&size=5";
HttpUriRequest request = new HttpGet(BASE_URL + ApiConstants.BASE_API_URL + ApiConstants.GROUPS + ApiConstants.SEARCH + SEARCH_QUERY);
HttpResponse response = handle(request);
Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
HttpEntity entity = response.getEntity();
try {
String content = EntityUtils.toString(entity);
GluuGroupApi[] groups = mapper.readValue(content, GluuGroupApi[].class);
Assert.assertTrue(groups.length >= 1);
} catch (ParseException | IOException e) {
e.printStackTrace();
Assert.assertTrue(false);
}
}
use of org.gluu.oxtrust.api.server.model.GluuGroupApi in project oxTrust by GluuFederation.
the class GroupWebResourceTest method createGroupTest.
@Test
public void createGroupTest() {
String name = "OxTrustApiGroup";
GluuGroupApi group = getGroup(name);
HttpPost request = new HttpPost(BASE_URL + ApiConstants.BASE_API_URL + ApiConstants.GROUPS);
try {
HttpEntity entity = new ByteArrayEntity(mapper.writeValueAsString(group).toString().getBytes("UTF-8"), ContentType.APPLICATION_FORM_URLENCODED);
request.setEntity(entity);
request.setHeader(CONTENT_TYPE, MediaType.APPLICATION_JSON);
HttpResponse response = handle(request);
Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
HttpEntity result = response.getEntity();
GluuGroupApi myGroup = mapper.readValue(EntityUtils.toString(result), GluuGroupApi.class);
Assert.assertEquals(myGroup.getDisplayName(), name);
Assert.assertEquals(myGroup.getStatus(), GluuStatus.ACTIVE);
} catch (ParseException | IOException e) {
e.printStackTrace();
Assert.assertTrue(false);
}
}
use of org.gluu.oxtrust.api.server.model.GluuGroupApi in project oxTrust by GluuFederation.
the class GroupWebResourceTest method getGroupByInumTest.
@Test
public void getGroupByInumTest() {
String inum = "60B7";
HttpUriRequest request = new HttpGet(BASE_URL + ApiConstants.BASE_API_URL + ApiConstants.GROUPS + "/" + inum);
HttpResponse response = handle(request);
Assert.assertEquals(HttpStatus.SC_OK, response.getStatusLine().getStatusCode());
HttpEntity entity = response.getEntity();
try {
String content = EntityUtils.toString(entity);
GluuGroupApi group = mapper.readValue(content, GluuGroupApi.class);
Assert.assertNotNull(group);
Assert.assertTrue(group.getDisplayName().contains("Manager"));
} catch (ParseException | IOException e) {
e.printStackTrace();
Assert.assertTrue(false);
}
}
Aggregations