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]"));
}
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\""));
}
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());
}
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());
}
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());
}
Aggregations