@Test(description = "This method tests the behaviour of createGroup method under valid and invalid scenarios")
public void testCreateGroup() throws GroupManagementException, GroupAlreadyExistException {

    PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class, "getGroupManagementProviderService"))
            .toReturn(groupManagementProviderService);
    PowerMockito.stub(PowerMockito.method(PrivilegedCarbonContext.class, "getThreadLocalCarbonContext"))
            .toReturn(context);
    Response response = groupManagementService.createGroup(null);
    Assert.assertEquals(response.getStatus(), Response.Status.BAD_REQUEST.getStatusCode(),
            "createGroup request succeeded with the group equals to null");
    Mockito.doNothing().when(groupManagementProviderService)
            .createGroup(Mockito.any(), Mockito.any(), Mockito.any());
    response = groupManagementService.createGroup(new DeviceGroup());
    Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode(),
            "createGroup request failed for a request with valid parameters");
    Mockito.reset(groupManagementProviderService);
    Mockito.doThrow(new GroupManagementException()).when(groupManagementProviderService)
            .createGroup(Mockito.any(), Mockito.any(), Mockito.any());
    response = groupManagementService.createGroup(new DeviceGroup());
    Assert.assertEquals(response.getStatus(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(),
            "createGroup request succeeded for a request with in-valid parameters");
    Mockito.reset(groupManagementProviderService);
    Mockito.doThrow(new GroupAlreadyExistException()).when(groupManagementProviderService)
            .createGroup(Mockito.any(), Mockito.any(), Mockito.any());
    response = groupManagementService.createGroup(new DeviceGroup());
    Assert.assertEquals(response.getStatus(), Response.Status.CONFLICT.getStatusCode(),
            "createGroup request succeeded for a request with in-valid parameters");
}