Exemplo n.º 1
0
  @Test
  public void addsUserId() {

    // given
    final ILoggingEvent loggingEvent =
        createLoggingEvent().with(createThrowableProxy()).withMdcProperty("userId", "someId");

    // when
    final NotificationVO notification = converter.convertToNotification(loggingEvent);
    final EventVO event = notification.getEvents().get(0);

    // then
    assertThat(event.getUserId(), is("someId"));
  }
Exemplo n.º 2
0
  @Test
  public void addsReleaseStageFromConfigurationToEvent() {

    // given
    configuration.setReleaseStage("someReleaseStage");
    final ILoggingEvent loggingEvent = createLoggingEvent().with(createThrowableProxy());

    // when
    final NotificationVO notification = converter.convertToNotification(loggingEvent);
    final EventVO event = notification.getEvents().get(0);

    // then
    assertThat(event.getReleaseStage(), is("someReleaseStage"));
  }
Exemplo n.º 3
0
  @Test
  public void convertsThrowableProxyMessageToExceptionMessage() {
    // given
    final ILoggingEvent loggingEvent =
        createLoggingEvent().with(createThrowableProxy().withMessage("someMessage"));

    // when
    final NotificationVO notification = converter.convertToNotification(loggingEvent);
    final EventVO event = notification.getEvents().get(0);
    final ExceptionVO exception = event.getExceptions().get(0);

    // then
    assertThat(exception.getMessage(), is("someMessage"));
  }
Exemplo n.º 4
0
  @Test
  public void addsDataFromMetaDataProvider() {

    // given
    configuration.setMetaDataProviderClassName(TestMetaDataProvider.class.getName());
    final ILoggingEvent loggingEvent =
        createLoggingEvent().with(createThrowableProxy()).withMdcProperty("someProp", "someValue");

    // when
    final NotificationVO notification = converter.convertToNotification(loggingEvent);
    final EventVO event = notification.getEvents().get(0);

    // then
    final TabVO tab = event.getMetaData().getTabsByName().get("someTab");
    assertThat(tab, hasKeyValuePair("someProp", "someValue"));
  }
Exemplo n.º 5
0
  @Test
  public void convertsStackTraceElementProxyClassNameAndMethodNameToStackTraceMethod() {
    // given
    final ILoggingEvent loggingEvent =
        createLoggingEvent()
            .with(
                createThrowableProxy()
                    .addStackTraceElementProxy(
                        createStackTraceElement()
                            .withDeclaringClass("com.some.package.SomeClassName")
                            .withMethodName("someMethodName")));
    // when
    final NotificationVO notification = converter.convertToNotification(loggingEvent);
    final EventVO event = notification.getEvents().get(0);
    final ExceptionVO exception = event.getExceptions().get(0);
    final StackTraceVO stackTrace = exception.getStackTrace().get(0);

    // then
    assertThat(stackTrace.getMethod(), is("com.some.package.SomeClassName.someMethodName"));
  }
Exemplo n.º 6
0
  @Test
  public void setsStackTraceAsNotInProjectWhenStackTraceElementClassNameIsMarkedAsSuch() {
    // given
    final ILoggingEvent loggingEvent =
        createLoggingEvent()
            .with(
                createThrowableProxy()
                    .addStackTraceElementProxy(
                        createStackTraceElement()
                            .withDeclaringClass("com.some.package.SomeClassName")
                            .withMethodName("someMethodName")
                            .withFileName("SomeFileName")));
    // when
    final NotificationVO notification = converter.convertToNotification(loggingEvent);
    final EventVO event = notification.getEvents().get(0);
    final ExceptionVO exception = event.getExceptions().get(0);
    final StackTraceVO stackTrace = exception.getStackTrace().get(0);

    // then
    assertThat(stackTrace.isInProject(), is(Boolean.FALSE));
  }