//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testChangeCredentials() public virtual void testChangeCredentials() { User initialUser = MockProvider.createMockUser(); UserQuery sampleUserQuery = mock(typeof(UserQuery)); when(identityServiceMock.createUserQuery()).thenReturn(sampleUserQuery); when(sampleUserQuery.userId(MockProvider.EXAMPLE_USER_ID)).thenReturn(sampleUserQuery); when(sampleUserQuery.singleResult()).thenReturn(initialUser); Authentication authentication = MockProvider.createMockAuthentication(); when(identityServiceMock.CurrentAuthentication).thenReturn(authentication); when(identityServiceMock.checkPassword(MockProvider.EXAMPLE_USER_ID, MockProvider.EXAMPLE_USER_PASSWORD)).thenReturn(true); UserCredentialsDto dto = new UserCredentialsDto(); dto.Password = "******"; dto.AuthenticatedUserPassword = MockProvider.EXAMPLE_USER_PASSWORD; given().pathParam("id", MockProvider.EXAMPLE_USER_ID).contentType(ContentType.JSON).body(dto).then().statusCode(Status.NO_CONTENT.StatusCode).when().put(USER_CREDENTIALS_URL); verify(identityServiceMock).CurrentAuthentication; verify(identityServiceMock).checkPassword(MockProvider.EXAMPLE_USER_ID, MockProvider.EXAMPLE_USER_PASSWORD); // password was updated verify(initialUser).Password = dto.Password; // and then saved verify(identityServiceMock).saveUser(initialUser); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testChangeCredentialsWithWrongAuthenticatedUserPassword() public virtual void testChangeCredentialsWithWrongAuthenticatedUserPassword() { User initialUser = MockProvider.createMockUser(); UserQuery sampleUserQuery = mock(typeof(UserQuery)); when(identityServiceMock.createUserQuery()).thenReturn(sampleUserQuery); when(sampleUserQuery.userId(MockProvider.EXAMPLE_USER_ID)).thenReturn(sampleUserQuery); when(sampleUserQuery.singleResult()).thenReturn(initialUser); Authentication authentication = MockProvider.createMockAuthentication(); when(identityServiceMock.CurrentAuthentication).thenReturn(authentication); when(identityServiceMock.checkPassword(MockProvider.EXAMPLE_USER_ID, MockProvider.EXAMPLE_USER_PASSWORD)).thenReturn(false); UserCredentialsDto dto = new UserCredentialsDto(); dto.Password = "******"; dto.AuthenticatedUserPassword = MockProvider.EXAMPLE_USER_PASSWORD; given().pathParam("id", MockProvider.EXAMPLE_USER_ID).contentType(ContentType.JSON).body(dto).then().statusCode(Status.BAD_REQUEST.StatusCode).contentType(ContentType.JSON).body("type", equalTo("InvalidRequestException")).body("message", equalTo("The given authenticated user password is not valid.")).when().put(USER_CREDENTIALS_URL); }