//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testPutProfileNonexistingFails() public virtual void testPutProfileNonexistingFails() { User userUpdate = MockProvider.createMockUserUpdate(); UserQuery sampleUserQuery = mock(typeof(UserQuery)); when(identityServiceMock.createUserQuery()).thenReturn(sampleUserQuery); when(sampleUserQuery.userId("aNonExistingUser")).thenReturn(sampleUserQuery); when(sampleUserQuery.singleResult()).thenReturn(null); UserProfileDto updateDto = UserProfileDto.fromUser(userUpdate); given().pathParam("id", "aNonExistingUser").body(updateDto).contentType(ContentType.JSON).then().then().expect().statusCode(Status.NOT_FOUND.StatusCode).contentType(ContentType.JSON).body("type", equalTo(typeof(InvalidRequestException).Name)).body("message", equalTo("User with id aNonExistingUser does not exist")).when().put(USER_PROFILE_URL); // nothing was saved verify(identityServiceMock, never()).saveUser(any(typeof(User))); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testPutProfileThrowsAuthorizationException() public virtual void testPutProfileThrowsAuthorizationException() { User initialUser = MockProvider.createMockUser(); User userUpdate = MockProvider.createMockUserUpdate(); UserQuery sampleUserQuery = mock(typeof(UserQuery)); when(identityServiceMock.createUserQuery()).thenReturn(sampleUserQuery); when(sampleUserQuery.userId(MockProvider.EXAMPLE_USER_ID)).thenReturn(sampleUserQuery); when(sampleUserQuery.singleResult()).thenReturn(initialUser); string message = "exception expected"; doThrow(new AuthorizationException(message)).when(identityServiceMock).saveUser(any(typeof(User))); UserProfileDto updateDto = UserProfileDto.fromUser(userUpdate); given().pathParam("id", MockProvider.EXAMPLE_USER_ID).body(updateDto).contentType(ContentType.JSON).then().statusCode(Status.FORBIDDEN.StatusCode).contentType(ContentType.JSON).body("type", equalTo(typeof(AuthorizationException).Name)).body("message", equalTo(message)).when().put(USER_PROFILE_URL); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testPutProfile() public virtual void testPutProfile() { User initialUser = MockProvider.createMockUser(); User userUpdate = MockProvider.createMockUserUpdate(); UserQuery sampleUserQuery = mock(typeof(UserQuery)); when(identityServiceMock.createUserQuery()).thenReturn(sampleUserQuery); when(sampleUserQuery.userId(MockProvider.EXAMPLE_USER_ID)).thenReturn(sampleUserQuery); when(sampleUserQuery.singleResult()).thenReturn(initialUser); UserProfileDto updateDto = UserProfileDto.fromUser(userUpdate); given().pathParam("id", MockProvider.EXAMPLE_USER_ID).body(updateDto).contentType(ContentType.JSON).then().statusCode(Status.NO_CONTENT.StatusCode).when().put(USER_PROFILE_URL); // password was updated verify(initialUser).Email = updateDto.Email; verify(initialUser).FirstName = updateDto.FirstName; verify(initialUser).LastName = updateDto.LastName; // and then saved verify(identityServiceMock).saveUser(initialUser); }