Search in sources :

Example 96 with AssertionFailedError

use of org.opentest4j.AssertionFailedError in project assertj-core by assertj.

the class ShouldBeEqual_Test method should_use_actual_and_expected_representation_in_AssertionFailedError_actual_and_expected_fields.

@Test
void should_use_actual_and_expected_representation_in_AssertionFailedError_actual_and_expected_fields() {
    // GIVEN
    byte[] actual = { 1, 2, 3 };
    byte[] expected = { 1, 2, 4 };
    ThrowingCallable code = () -> then(actual).as("numbers").isEqualTo(expected);
    // WHEN
    AssertionFailedError error = catchThrowableOfType(code, AssertionFailedError.class);
    // THEN
    then(error.getActual().getValue()).isEqualTo("[1, 2, 3]");
    then(error.getExpected().getValue()).isEqualTo("[1, 2, 4]");
    then(error).hasMessage(format("[numbers] %n" + "expected: [1, 2, 4]%n" + " but was: [1, 2, 3]"));
}
Also used : ThrowingCallable(org.assertj.core.api.ThrowableAssert.ThrowingCallable) AssertionFailedError(org.opentest4j.AssertionFailedError) Test(org.junit.jupiter.api.Test)

Example 97 with AssertionFailedError

use of org.opentest4j.AssertionFailedError in project assertj-core by assertj.

the class ShouldBeEqual_newAssertionError_without_JUnit_Test method check.

private void check(AssertionError error) throws Exception {
    verify(constructorInvoker).newInstance(AssertionFailedError.class.getName(), new Class<?>[] { String.class, Object.class, Object.class }, format("[Jedi] %n" + "expected: \"Yoda\"%n" + " but was: \"Luke\""), STANDARD_REPRESENTATION.toStringOf("Yoda"), STANDARD_REPRESENTATION.toStringOf("Luke"));
    assertThat(error).isNotInstanceOf(ComparisonFailure.class).isInstanceOf(AssertionFailedError.class);
    AssertionFailedError assertionFailedError = (AssertionFailedError) error;
    assertThat(assertionFailedError.getActual().getValue()).isEqualTo(STANDARD_REPRESENTATION.toStringOf("Luke"));
    assertThat(assertionFailedError.getExpected().getValue()).isEqualTo(STANDARD_REPRESENTATION.toStringOf("Yoda"));
    assertThat(error).hasMessage(format("[Jedi] %n" + "expected: \"Yoda\"%n" + " but was: \"Luke\""));
}
Also used : ComparisonFailure(org.junit.ComparisonFailure) AssertionFailedError(org.opentest4j.AssertionFailedError)

Example 98 with AssertionFailedError

use of org.opentest4j.AssertionFailedError in project hub-alert by blackducksoftware.

the class SettingsProxyControllerTestIT method testCreateTwice.

@Test
@WithMockUser(roles = AlertIntegrationTestConstants.ROLE_ALERT_ADMIN)
void testCreateTwice() throws Exception {
    createDefaultSettingsProxyModel().orElseThrow(AssertionFailedError::new);
    SettingsProxyModel newSettingsProxyModel = new SettingsProxyModel(null, AlertRestConstants.DEFAULT_CONFIGURATION_NAME, "newHostname", 678);
    String url = AlertRestConstants.SETTINGS_PROXY_PATH;
    MockHttpServletRequestBuilder request = MockMvcRequestBuilders.post(new URI(url)).with(SecurityMockMvcRequestPostProcessors.user("admin").roles(AlertIntegrationTestConstants.ROLE_ALERT_ADMIN)).with(SecurityMockMvcRequestPostProcessors.csrf()).content(gson.toJson(newSettingsProxyModel)).contentType(contentType);
    mockMvc.perform(request).andExpect(MockMvcResultMatchers.status().isBadRequest());
}
Also used : MockHttpServletRequestBuilder(org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder) SettingsProxyModel(com.synopsys.integration.alert.common.rest.model.SettingsProxyModel) AssertionFailedError(org.opentest4j.AssertionFailedError) URI(java.net.URI) WithMockUser(org.springframework.security.test.context.support.WithMockUser) AlertIntegrationTest(com.synopsys.integration.alert.util.AlertIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 99 with AssertionFailedError

use of org.opentest4j.AssertionFailedError in project hub-alert by blackducksoftware.

the class SettingsProxyControllerTestIT method testUpdate.

@Test
@WithMockUser(roles = AlertIntegrationTestConstants.ROLE_ALERT_ADMIN)
void testUpdate() throws Exception {
    createDefaultSettingsProxyModel().orElseThrow(AssertionFailedError::new);
    SettingsProxyModel newSettingsProxyModel = new SettingsProxyModel(null, AlertRestConstants.DEFAULT_CONFIGURATION_NAME, "newHostname", 678);
    String url = AlertRestConstants.SETTINGS_PROXY_PATH;
    MockHttpServletRequestBuilder request = MockMvcRequestBuilders.put(new URI(url)).with(SecurityMockMvcRequestPostProcessors.user("admin").roles(AlertIntegrationTestConstants.ROLE_ALERT_ADMIN)).with(SecurityMockMvcRequestPostProcessors.csrf()).content(gson.toJson(newSettingsProxyModel)).contentType(contentType);
    mockMvc.perform(request).andExpect(MockMvcResultMatchers.status().isNoContent());
}
Also used : MockHttpServletRequestBuilder(org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder) SettingsProxyModel(com.synopsys.integration.alert.common.rest.model.SettingsProxyModel) AssertionFailedError(org.opentest4j.AssertionFailedError) URI(java.net.URI) WithMockUser(org.springframework.security.test.context.support.WithMockUser) AlertIntegrationTest(com.synopsys.integration.alert.util.AlertIntegrationTest) Test(org.junit.jupiter.api.Test)

Example 100 with AssertionFailedError

use of org.opentest4j.AssertionFailedError in project hub-alert by blackducksoftware.

the class SettingsProxyControllerTestIT method testDelete.

@Test
@WithMockUser(roles = AlertIntegrationTestConstants.ROLE_ALERT_ADMIN)
void testDelete() throws Exception {
    createDefaultSettingsProxyModel().orElseThrow(AssertionFailedError::new);
    String url = AlertRestConstants.SETTINGS_PROXY_PATH;
    MockHttpServletRequestBuilder request = MockMvcRequestBuilders.delete(new URI(url)).with(SecurityMockMvcRequestPostProcessors.user("admin").roles(AlertIntegrationTestConstants.ROLE_ALERT_ADMIN)).with(SecurityMockMvcRequestPostProcessors.csrf());
    mockMvc.perform(request).andExpect(MockMvcResultMatchers.status().isNoContent());
}
Also used : MockHttpServletRequestBuilder(org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder) AssertionFailedError(org.opentest4j.AssertionFailedError) URI(java.net.URI) WithMockUser(org.springframework.security.test.context.support.WithMockUser) AlertIntegrationTest(com.synopsys.integration.alert.util.AlertIntegrationTest) Test(org.junit.jupiter.api.Test)

Aggregations

AssertionFailedError (org.opentest4j.AssertionFailedError)153 Test (org.junit.jupiter.api.Test)72 AssertionTestUtils.expectAssertionFailedError (org.junit.jupiter.api.AssertionTestUtils.expectAssertionFailedError)12 AlertIntegrationTest (com.synopsys.integration.alert.util.AlertIntegrationTest)8 IOException (java.io.IOException)8 URI (java.net.URI)8 WithMockUser (org.springframework.security.test.context.support.WithMockUser)8 MockHttpServletRequestBuilder (org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder)8 Collectors (java.util.stream.Collectors)5 File (java.io.File)4 ArrayList (java.util.ArrayList)4 ThrowingCallable (org.assertj.core.api.ThrowableAssert.ThrowingCallable)4 GeneCentricEntry (org.uniprot.core.genecentric.GeneCentricEntry)4 GeneCentricDocument (org.uniprot.store.search.document.genecentric.GeneCentricDocument)4 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)3 SettingsProxyModel (com.synopsys.integration.alert.common.rest.model.SettingsProxyModel)3 Search (io.zulia.client.command.builder.Search)3 SearchResult (io.zulia.client.result.SearchResult)3 ExecutionException (java.util.concurrent.ExecutionException)3 Assertions (org.junit.jupiter.api.Assertions)3