//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testGroupMembersResourceOptionsUnauthorized() public virtual void testGroupMembersResourceOptionsUnauthorized() { string fullMembersUrl = "http://localhost:" + PORT + TEST_RESOURCE_ROOT_PATH + "/group/" + MockProvider.EXAMPLE_GROUP_ID + "/members"; Authentication authentication = new Authentication(MockProvider.EXAMPLE_USER_ID, null); when(identityServiceMock.CurrentAuthentication).thenReturn(authentication); when(authorizationServiceMock.isUserAuthorized(MockProvider.EXAMPLE_USER_ID, null, DELETE, GROUP_MEMBERSHIP, MockProvider.EXAMPLE_GROUP_ID)).thenReturn(false); when(authorizationServiceMock.isUserAuthorized(MockProvider.EXAMPLE_USER_ID, null, CREATE, GROUP_MEMBERSHIP, MockProvider.EXAMPLE_GROUP_ID)).thenReturn(false); Group sampleGroup = MockProvider.createMockGroup(); GroupQuery sampleGroupQuery = mock(typeof(GroupQuery)); when(identityServiceMock.createGroupQuery()).thenReturn(sampleGroupQuery); when(sampleGroupQuery.groupId(MockProvider.EXAMPLE_GROUP_ID)).thenReturn(sampleGroupQuery); when(sampleGroupQuery.singleResult()).thenReturn(sampleGroup); when(processEngineConfigurationMock.AuthorizationEnabled).thenReturn(true); given().pathParam("id", MockProvider.EXAMPLE_GROUP_ID).then().expect().statusCode(Status.OK.StatusCode).body("links[0].href", equalTo(fullMembersUrl)).body("links[0].method", equalTo(HttpMethod.GET)).body("links[0].rel", equalTo("self")).body("links[1]", nullValue()).body("links[2]", nullValue()).when().options(GROUP_MEMBERS_URL); verify(identityServiceMock, times(2)).CurrentAuthentication; verify(authorizationServiceMock, times(1)).isUserAuthorized(MockProvider.EXAMPLE_USER_ID, null, DELETE, GROUP_MEMBERSHIP, MockProvider.EXAMPLE_GROUP_ID); verify(authorizationServiceMock, times(1)).isUserAuthorized(MockProvider.EXAMPLE_USER_ID, null, CREATE, GROUP_MEMBERSHIP, MockProvider.EXAMPLE_GROUP_ID); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testGroupCreateThrowsAuthorizationException() public virtual void testGroupCreateThrowsAuthorizationException() { Group newGroup = MockProvider.createMockGroup(); string message = "exception expected"; when(identityServiceMock.newGroup(newGroup.Id)).thenThrow(new AuthorizationException(message)); given().body(GroupDto.fromGroup(newGroup)).contentType(ContentType.JSON).then().expect().statusCode(Status.FORBIDDEN.StatusCode).contentType(ContentType.JSON).body("type", equalTo(typeof(AuthorizationException).Name)).body("message", equalTo(message)).when().post(GROUP_CREATE_URL); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testReadOnlyGroupUpdateFails() public virtual void testReadOnlyGroupUpdateFails() { Group groupUdpdate = MockProvider.createMockGroup(); when(identityServiceMock.ReadOnly).thenReturn(true); given().pathParam("id", MockProvider.EXAMPLE_GROUP_ID).body(GroupDto.fromGroup(groupUdpdate)).contentType(ContentType.JSON).then().expect().statusCode(Status.FORBIDDEN.StatusCode).contentType(ContentType.JSON).body("type", equalTo(typeof(InvalidRequestException).Name)).body("message", equalTo("Identity service implementation is read-only.")).when().put(GROUP_URL); verify(identityServiceMock, never()).saveGroup(groupUdpdate); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testGetSingleGroup() public virtual void testGetSingleGroup() { Group sampleGroup = MockProvider.createMockGroup(); GroupQuery sampleGroupQuery = mock(typeof(GroupQuery)); when(identityServiceMock.createGroupQuery()).thenReturn(sampleGroupQuery); when(sampleGroupQuery.groupId(MockProvider.EXAMPLE_GROUP_ID)).thenReturn(sampleGroupQuery); when(sampleGroupQuery.singleResult()).thenReturn(sampleGroup); given().pathParam("id", MockProvider.EXAMPLE_GROUP_ID).then().expect().statusCode(Status.OK.StatusCode).body("id", equalTo(MockProvider.EXAMPLE_GROUP_ID)).body("name", equalTo(MockProvider.EXAMPLE_GROUP_NAME)).when().get(GROUP_URL); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testGroupCreateExistingFails() public virtual void testGroupCreateExistingFails() { Group newGroup = MockProvider.createMockGroup(); when(identityServiceMock.newGroup(MockProvider.EXAMPLE_GROUP_ID)).thenReturn(newGroup); doThrow(new ProcessEngineException("")).when(identityServiceMock).saveGroup(newGroup); given().body(GroupDto.fromGroup(newGroup)).contentType(ContentType.JSON).then().expect().statusCode(Status.INTERNAL_SERVER_ERROR.StatusCode).contentType(ContentType.JSON).body("type", equalTo(typeof(ProcessEngineException).Name)).when().post(GROUP_CREATE_URL); verify(identityServiceMock).newGroup(MockProvider.EXAMPLE_GROUP_ID); verify(identityServiceMock).saveGroup(newGroup); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testGroupCreate() public virtual void testGroupCreate() { Group newGroup = MockProvider.createMockGroup(); when(identityServiceMock.newGroup(MockProvider.EXAMPLE_GROUP_ID)).thenReturn(newGroup); given().body(GroupDto.fromGroup(newGroup)).contentType(ContentType.JSON).then().expect().statusCode(Status.NO_CONTENT.StatusCode).when().post(GROUP_CREATE_URL); verify(identityServiceMock).newGroup(MockProvider.EXAMPLE_GROUP_ID); verify(newGroup).Name = MockProvider.EXAMPLE_GROUP_NAME; verify(identityServiceMock).saveGroup(newGroup); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testGroupResourceOptionsUnauthenticated() public virtual void testGroupResourceOptionsUnauthenticated() { string fullGroupUrl = "http://localhost:" + PORT + TEST_RESOURCE_ROOT_PATH + "/group/" + MockProvider.EXAMPLE_GROUP_ID; Group sampleGroup = MockProvider.createMockGroup(); GroupQuery sampleGroupQuery = mock(typeof(GroupQuery)); when(identityServiceMock.createGroupQuery()).thenReturn(sampleGroupQuery); when(sampleGroupQuery.groupId(MockProvider.EXAMPLE_GROUP_ID)).thenReturn(sampleGroupQuery); when(sampleGroupQuery.singleResult()).thenReturn(sampleGroup); when(processEngineConfigurationMock.AuthorizationEnabled).thenReturn(true); given().pathParam("id", MockProvider.EXAMPLE_GROUP_ID).then().expect().statusCode(Status.OK.StatusCode).body("links[0].href", equalTo(fullGroupUrl)).body("links[0].method", equalTo(HttpMethod.GET)).body("links[0].rel", equalTo("self")).body("links[1].href", equalTo(fullGroupUrl)).body("links[1].method", equalTo(HttpMethod.DELETE)).body("links[1].rel", equalTo("delete")).body("links[2].href", equalTo(fullGroupUrl)).body("links[2].method", equalTo(HttpMethod.PUT)).body("links[2].rel", equalTo("update")).when().options(GROUP_URL); verify(identityServiceMock, times(2)).CurrentAuthentication; }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testUpdateExistingGroup() public virtual void testUpdateExistingGroup() { Group initialGroup = MockProvider.createMockGroup(); Group groupUpdate = MockProvider.createMockGroupUpdate(); GroupQuery sampleGroupQuery = mock(typeof(GroupQuery)); when(identityServiceMock.createGroupQuery()).thenReturn(sampleGroupQuery); when(sampleGroupQuery.groupId(MockProvider.EXAMPLE_GROUP_ID)).thenReturn(sampleGroupQuery); when(sampleGroupQuery.singleResult()).thenReturn(initialGroup); given().pathParam("id", MockProvider.EXAMPLE_GROUP_ID).body(GroupDto.fromGroup(groupUpdate)).contentType(ContentType.JSON).then().expect().statusCode(Status.NO_CONTENT.StatusCode).when().put(GROUP_URL); // initial group was updated verify(initialGroup).Name = groupUpdate.Name; // and then saved verify(identityServiceMock).saveGroup(initialGroup); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testUpdateGroupThrowsAuthorizationException() public virtual void testUpdateGroupThrowsAuthorizationException() { Group initialGroup = MockProvider.createMockGroup(); Group groupUpdate = MockProvider.createMockGroupUpdate(); GroupQuery sampleGroupQuery = mock(typeof(GroupQuery)); when(identityServiceMock.createGroupQuery()).thenReturn(sampleGroupQuery); when(sampleGroupQuery.groupId(MockProvider.EXAMPLE_GROUP_ID)).thenReturn(sampleGroupQuery); when(sampleGroupQuery.singleResult()).thenReturn(initialGroup); string message = "exception expected"; doThrow(new AuthorizationException(message)).when(identityServiceMock).saveGroup(any(typeof(Group))); given().pathParam("id", MockProvider.EXAMPLE_GROUP_ID).body(GroupDto.fromGroup(groupUpdate)).contentType(ContentType.JSON).then().expect().statusCode(Status.FORBIDDEN.StatusCode).contentType(ContentType.JSON).body("type", equalTo(typeof(AuthorizationException).Name)).body("message", equalTo(message)).when().put(GROUP_URL); // initial group was updated verify(initialGroup).Name = groupUpdate.Name; }