### Question:
RestLog { public String debugOperationAttemptAsPrincipal(String resource, String operation, Context context, String realm, Debug debug) { init(); Reject.ifNull(resource, operation, context, debug); final String principalName = PrincipalRestUtils.getPrincipalNameFromServerContext(context); StringBuilder sb = new StringBuilder(); sb.append(resource).append(" :: ").append(operation.toUpperCase()); sb.append(" attempted by "); sb.append(principalName == null ? "[unknown]" : principalName); if (realm != null) { sb.append(" in realm ").append(realm); } debug.message(sb.toString()); return principalName; } RestLog();   RestLog(LogMessageProvider msgProvider, Logger accessLogger, Logger authzLogger); String debugOperationAttemptAsPrincipal(String resource, String operation, Context context,
            String realm, Debug debug); void auditAccessMessage(String resource, String action, SSOToken token); void auditAccessDenied(String resource, String action, String authzModule, SSOToken token); void auditAccessGranted(String resource, String action, String authzModule, SSOToken token); static final String LOG_NAME; }### Answer:
@Test (expectedExceptions = NullPointerException.class) public void shouldFailWithNoResource() { restLog.debugOperationAttemptAsPrincipal(null, "", mockContext, null, mockDebug); }
@Test (expectedExceptions = NullPointerException.class) public void shouldFailWithNoOperation() { restLog.debugOperationAttemptAsPrincipal("", null, mockContext, null, mockDebug); }
@Test (expectedExceptions = NullPointerException.class) public void shouldFailWithNoContext() { restLog.debugOperationAttemptAsPrincipal(null, "", mockContext, null, mockDebug); }
@Test (expectedExceptions = NullPointerException.class) public void shouldFailWithNoDebug() { restLog.debugOperationAttemptAsPrincipal("", "", mockContext, null, null); }
@Test public void shouldReturnNullWithNoPrincipalAndMessage() { SSOTokenContext tokenContext = generateTestSSOTokenContext(null); String principal = restLog.debugOperationAttemptAsPrincipal("", "", tokenContext, null, mockDebug); assertNull(principal); verify(mockDebug).message(anyString()); }
@Test public void shouldReturnPrincipalAndMessage() throws ResourceException { SSOTokenContext tokenContext = generateTestSSOTokenContext("test"); String principal = restLog.debugOperationAttemptAsPrincipal("", "", tokenContext, null, mockDebug); assertEquals("test", principal); verify(mockDebug).message(anyString()); }