NinjaDefault implements Ninja { public boolean isDiagnosticsEnabled() { return ninjaProperties.isDev() && ninjaProperties.getBooleanWithDefault(NinjaConstant.DIAGNOSTICS_KEY_NAME, Boolean.TRUE); }  boolean isDiagnosticsEnabled(); @Override void onRouteRequest(Context.Impl context); @Override void renderErrorResultAndCatchAndLogExceptions(
            Result result, Context context); @Override void onFrameworkStart(); @Override void onFrameworkShutdown(); @Override Result onException(Context context, Exception exception); Result onException(Context context, Exception exception, Result underlyingResult); Result getRenderingExceptionResult(Context context, RenderingException exception, Result underlyingResult); @Deprecated Result getInternalServerErrorResult(Context context, Exception exception); @Override Result getInternalServerErrorResult(Context context, Exception exception, Result underlyingResult); @Override Result getNotFoundResult(Context context); @Override Result getNotFoundResult(Context context, RequestNotFoundException exception); @Override Result getBadRequestResult(Context context, BadRequestException exception); @Override Result getUnauthorizedResult(Context context); @Override Result getForbiddenResult(Context context); @Override Result getForbiddenResult(Context context, ForbiddenRequestException exception);  }
@Test public void testIsDiagnosticsEnabled_TrueInDevAndWithProperNinjaPropertiesConfig() { Mockito.when(ninjaProperties.getBooleanWithDefault(NinjaConstant.DIAGNOSTICS_KEY_NAME, Boolean.TRUE)).thenReturn(true); Mockito.when(ninjaProperties.isDev()).thenReturn(true); assertThat(ninjaDefault.isDiagnosticsEnabled(), equalTo(true)); verify(ninjaProperties).isDev(); verify(ninjaProperties).getBooleanWithDefault(NinjaConstant.DIAGNOSTICS_KEY_NAME, Boolean.TRUE); }
@Test public void testIsDiagnosticsEnabled_FalseDisabledWhenNotInDev() { Mockito.when(ninjaProperties.isDev()).thenReturn(false); assertThat(ninjaDefault.isDiagnosticsEnabled(), equalTo(false)); verify(ninjaProperties).isDev(); verify(ninjaProperties, Mockito.never()).getBooleanWithDefault(NinjaConstant.DIAGNOSTICS_KEY_NAME, Boolean.TRUE); }
@Test public void testIsDiagnosticsEnabled_FalseWheInDevButDisabledInNinjaPropertiesConfig() { Mockito.when(ninjaProperties.getBooleanWithDefault(NinjaConstant.DIAGNOSTICS_KEY_NAME, Boolean.TRUE)).thenReturn(false); Mockito.when(ninjaProperties.isDev()).thenReturn(true); assertThat(ninjaDefault.isDiagnosticsEnabled(), equalTo(false)); verify(ninjaProperties).isDev(); verify(ninjaProperties).getBooleanWithDefault(NinjaConstant.DIAGNOSTICS_KEY_NAME, Boolean.TRUE); }