use of org.wso2.charon.core.objects.Group in project charon by wso2.
the class GroupResourceManagerTest method getNewGroup.
private Group getNewGroup() throws BadRequestException, CharonException, InternalErrorException {
SCIMResourceTypeSchema schema = SCIMResourceSchemaManager.getInstance().getGroupResourceSchema();
JSONDecoder decoder = new JSONDecoder();
return decoder.decodeResource(NEW_GROUP_SCIM_OBJECT_STRING, schema, new Group());
}
use of org.wso2.charon.core.objects.Group in project charon by wso2.
the class GroupResourceManagerTest method dataToTestDeleteGroupFails.
@DataProvider(name = "dataForTestDeleteGroupFails")
public Object[][] dataToTestDeleteGroupFails() throws BadRequestException, CharonException, InternalErrorException {
Group group = getNewGroup();
String id = group.getId();
return new Object[][] { { id, ResponseCodeConstants.CODE_INTERNAL_ERROR }, { id, ResponseCodeConstants.CODE_RESOURCE_NOT_FOUND } };
}
use of org.wso2.charon.core.objects.Group in project charon by wso2.
the class GroupResourceManagerTest method testUpdateGroupWithPUTProvidedUserManagerHandlerIsNull.
@Test(dataProvider = "dataForTestUpdateGroupWithPUTProvidedUserManagerHandlerIsNull")
public void testUpdateGroupWithPUTProvidedUserManagerHandlerIsNull(String id, String scimObjectString, String attributes, String excludeAttributes, Object scimNewGroupObject, Object scimOldGroupObject) throws BadRequestException, CharonException, NotImplementedException, NotFoundException {
Group groupNew = (Group) scimNewGroupObject;
Group groupOld = (Group) scimOldGroupObject;
SCIMResourceTypeSchema schema = SCIMResourceSchemaManager.getInstance().getGroupResourceSchema();
abstractResourceManager.when(() -> AbstractResourceManager.getResourceEndpointURL(SCIMConstants.USER_ENDPOINT)).thenReturn(SCIM2_GROUP_ENDPOINT + "/" + GROUP_ID);
abstractResourceManager.when(() -> AbstractResourceManager.encodeSCIMException(any(InternalErrorException.class))).thenReturn(getEncodeSCIMExceptionObject(new InternalErrorException()));
Mockito.when(userManager.getGroup(id, ResourceManagerUtil.getAllAttributeURIs(schema))).thenReturn(groupOld);
Group validatedGroup = (Group) ServerSideValidator.validateUpdatedSCIMObject(groupOld, groupNew, schema);
Mockito.when(userManager.updateGroup(any(Group.class), any(Group.class), anyMap())).thenReturn(validatedGroup);
SCIMResponse scimResponse = groupResourceManager.updateWithPUT(id, scimObjectString, null, attributes, excludeAttributes);
Assert.assertEquals(scimResponse.getResponseStatus(), ResponseCodeConstants.CODE_INTERNAL_ERROR);
}
use of org.wso2.charon.core.objects.Group in project charon by wso2.
the class GroupResourceManagerTest method testUpdateGroupWithPUTNoUserExistsWithTheGivenUserName.
@Test(dataProvider = "dataForTestUpdateGroupWithPUTNotFoundException")
public void testUpdateGroupWithPUTNoUserExistsWithTheGivenUserName(String id, String scimObjectString, String attributes, String excludeAttributes, Object scimNewGroupObject, Object scimOldGroupObject) throws BadRequestException, CharonException, NotImplementedException, NotFoundException {
Group groupNew = (Group) scimNewGroupObject;
Group groupOld = (Group) scimOldGroupObject;
SCIMResourceTypeSchema schema = SCIMResourceSchemaManager.getInstance().getGroupResourceSchema();
abstractResourceManager.when(() -> AbstractResourceManager.getResourceEndpointURL(SCIMConstants.USER_ENDPOINT)).thenReturn(SCIM2_GROUP_ENDPOINT + "/" + GROUP_ID);
abstractResourceManager.when(() -> AbstractResourceManager.encodeSCIMException(any(NotFoundException.class))).thenReturn(getEncodeSCIMExceptionObject(new NotFoundException()));
Mockito.when(userManager.getGroup(id, ResourceManagerUtil.getAllAttributeURIs(schema))).thenReturn(null);
Group validatedGroup = (Group) ServerSideValidator.validateUpdatedSCIMObject(groupOld, groupNew, schema);
Mockito.when(userManager.updateGroup(any(Group.class), any(Group.class), anyMap())).thenReturn(validatedGroup);
SCIMResponse scimResponse = groupResourceManager.updateWithPUT(id, scimObjectString, userManager, attributes, excludeAttributes);
Assert.assertEquals(scimResponse.getResponseStatus(), ResponseCodeConstants.CODE_RESOURCE_NOT_FOUND);
}
use of org.wso2.charon.core.objects.Group in project charon by wso2.
the class GroupResourceManagerTest method dataToTestUpdateGroupWithPUTSuccess.
@DataProvider(name = "dataForTestUpdateGroupWithPUTSuccess")
public Object[][] dataToTestUpdateGroupWithPUTSuccess() throws BadRequestException, CharonException, InternalErrorException {
SCIMResourceTypeSchema schema = SCIMResourceSchemaManager.getInstance().getGroupResourceSchema();
JSONDecoder decoder = new JSONDecoder();
Group groupOld = decoder.decodeResource(NEW_GROUP_SCIM_OBJECT_STRING, schema, new Group());
String id = groupOld.getId();
Group groupNew = decoder.decodeResource(NEW_GROUP_SCIM_OBJECT_STRING_UPDATED, schema, new Group());
return new Object[][] { { id, NEW_GROUP_SCIM_OBJECT_STRING_UPDATED, "id", null, groupNew, groupOld } };
}
Aggregations