TimestampValidator implements Validator { @Override public Credential validate(Credential credential, RequestData data) throws WSSecurityException { if (credential == null || credential.getTimestamp() == null) { throw new WSSecurityException(ErrorCode.FAILURE, "noCredential"); } WSSConfig wssConfig = data.getWssConfig(); if (wssConfig == null) { throw new WSSecurityException(ErrorCode.FAILURE, "WSSConfig cannot be null"); } CONNECTTimestamp timeStamp = new CONNECTTimestamp(credential.getTimestamp()); validate(timeStamp, data); return credential; }  @Override Credential validate(Credential credential, RequestData data);  }
@Test(expected = WSSecurityException.class) public void validate_NullCredential() throws WSSecurityException { final Credential credential = null; final RequestData data = mock(RequestData.class); final TimestampValidator validator = new TimestampValidator(); validator.validate(credential, data); }
@Test(expected = WSSecurityException.class) public void validate_NullData() throws WSSecurityException { final Credential credential = mock(Credential.class); final RequestData data = mock(RequestData.class); final Timestamp timestamp = mock(Timestamp.class); when(credential.getTimestamp()).thenReturn(timestamp); final TimestampValidator validator = new TimestampValidator(); validator.validate(credential, data); }