@Override public boolean equals(Object obj) { if (obj instanceof Suppression) { Suppression other = (Suppression) obj; return closeable.equals(other.closeable) && thrown.equals(other.thrown) && suppressed.equals(other.suppressed); } return false; }
@Test public void shouldReportStoryCancellation() { // Given Configuration configuration = mock(Configuration.class, Mockito.RETURNS_DEEP_STUBS); when(configuration.storyControls().dryRun()).thenReturn(false); StoryReporter reporter = mock(ConcurrentStoryReporter.class); when(configuration.storyReporter(Matchers.anyString())).thenReturn(reporter); Story story = mock(Story.class); String storyPath = "story/path"; when(story.getPath()).thenReturn(storyPath); RuntimeException expected = new RuntimeException(); when(story.getMeta()).thenThrow(expected); InjectableStepsFactory stepsFactory = mock(InjectableStepsFactory.class); MetaFilter metaFilter = mock(MetaFilter.class); State state = mock(State.class); // When long durationInSecs = 2; long timeoutInSecs = 1; StoryDuration storyDuration = new StoryDuration(durationInSecs, timeoutInSecs); try { StoryRunner runner = new StoryRunner(); runner.cancelStory(story, storyDuration); runner.run(configuration, stepsFactory, story, metaFilter, state); fail("A exception should be thrown"); } catch (Throwable e) { // Then assertThat(e.equals(expected), is(true)); } verify(reporter).storyCancelled(story, storyDuration); }
/** * Simulando chamadas recursivas, entra nas exception internas at� encontrar ou null ou a mesma * externa. * * @param t * @return */ private Throwable getAlternativeRootCause(Throwable t) { Throwable result = t; Throwable previousResult = null; while (result.getCause() != null && !result.equals(previousResult)) { previousResult = result; result = result.getCause(); } return result; }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; if (!super.equals(o)) return false; BadConfigTrigger that = (BadConfigTrigger) o; if (cause != null ? !cause.equals(that.cause) : that.cause != null) return false; if (config != null ? !config.equals(that.config) : that.config != null) return false; return true; }
@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; MockTestNGResult result = (MockTestNGResult) o; if (!myClassName.equals(result.myClassName)) return false; if (!myMethodName.equals(result.myMethodName)) return false; if (myThrowable != null ? !myThrowable.equals(result.myThrowable) : result.myThrowable != null) return false; // Probably incorrect - comparing Object[] arrays with Arrays.equals if (!Arrays.equals(myParams, result.myParams)) return false; return true; }