BodyFactory { @Deprecated public Body from(Throwable throwable, String description) { if (throwable == null) { return new Body.Builder().bodyContent(message(description)).build(); } return from(new RollbarThrowableWrapper(throwable), description); }  @Deprecated Body from(Throwable throwable, String description); Body from(ThrowableWrapper throwableWrapper, String description);  }
@Test public void shouldBuildBodyWithDescription() { Body body1 = sut.from((Throwable) null, DESCRIPTION); assertThat(body1.getContents(), is(instanceOf(Message.class))); assertThat(((Message) body1.getContents()).getBody(), is(DESCRIPTION)); Body body2 = sut.from((ThrowableWrapper) null, DESCRIPTION); assertThat(body2.getContents(), is(instanceOf(Message.class))); assertThat(((Message) body2.getContents()).getBody(), is(DESCRIPTION)); }
@Test public void shouldBuildBodyWithTraceAsContent() { Throwable throwable = buildSimpleThrowable(); Body body = sut.from(throwable, DESCRIPTION); assertThat(body.getContents(), is(instanceOf(Trace.class))); verifyTrace((Trace) body.getContents(), throwable, DESCRIPTION); }
@Test public void shouldBuildBodyWithTraceChainAsContent() { Throwable throwable = buildNestedThrowable(); Body body = sut.from(throwable, DESCRIPTION); assertThat(body.getContents(), is(instanceOf(TraceChain.class))); verifyTraceChain((TraceChain) body.getContents(), throwable); }
@Test public void shouldBuildBodyWithTraceAsContentFromThrowableWrapper() { Throwable throwable = buildSimpleThrowable(); ThrowableWrapper throwableWrapper = new RollbarThrowableWrapper(throwable); Body body = sut.from(throwableWrapper, DESCRIPTION); assertThat(body.getContents(), is(instanceOf(Trace.class))); verifyTrace((Trace) body.getContents(), throwable, DESCRIPTION); }
@Test public void shouldBuildBodyWithTraceChainAsContentFromThrowableWrapper() { Throwable throwable = buildNestedThrowable(); ThrowableWrapper throwableWrapper = new RollbarThrowableWrapper(throwable); Body body = sut.from(throwableWrapper, DESCRIPTION); assertThat(body.getContents(), is(instanceOf(TraceChain.class))); verifyTraceChain((TraceChain) body.getContents(), throwable); }