AuditServiceImplTest.java revision 92327eba2d504cf38480c3d35550967289071f68
/*
* The contents of this file are subject to the terms of the Common Development and
* Distribution License (the License). You may not use this file except in compliance with the
* License.
*
* You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
* specific language governing permission and limitations under the License.
*
* When distributing Covered Software, include this CDDL Header Notice in each file and include
* the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
* Header, with the fields enclosed by brackets [] replaced by your own identifying
* information: "Portions copyright [year] [name of copyright owner]".
*
* Copyright 2014-2015 ForgeRock AS.
*/
/**
* Test the audit service.
*/
public class AuditServiceImplTest {
//private Collection<Map<String, Object>> memory = new ArrayList<>();
@Test
public void testAuditServiceActivation() throws Exception {
//given
//when
//if test fails it will throw an exception
}
@Test
public void testAuditServiceCreate() throws Exception {
//given
.transactionId("transactionId")
.eventName("eventName")
.authentication("testuser@forgerock.com")
.toEvent();
//when
new RootContext(), createRequest);
//then
AssertJJsonValueAssert.assertThat(resourceResponse.getContent()).isEqualTo(createRequest.getContent());
}
@Test
public void testAuditServiceRead() throws Exception {
//given
//when
Promise<ResourceResponse, ResourceException> promise = auditService.handleRead(new RootContext(), readRequest);
//then
}
@Test
public void testAuditServiceUpdate() throws Exception {
//given
final UpdateRequest updateRequest =
//when
new RootContext(), updateRequest);
//then
}
@Test
public void testAuditServiceDelete() throws Exception {
//given
//when
new RootContext(), deleteRequest);
//then
}
@Test
public void testAuditServicePatch() throws Exception {
//given
final PatchRequest patchRequest =
//when
new RootContext(), patchRequest);
//then
}
@Test
public void testAuditServiceUnknownAction() throws Exception {
//given
//when
//then
try {
fail("expected to get BadRequestException");
} catch (BadRequestException e) {
// we're all good, this is what we expected.
} catch (InterruptedException | ResourceException e) {
fail("expected to get BadRequestException");
}
}
@Test
public void testActionForChangedFields() throws Exception {
//given - depends on 'mail' being configured as a watched field.
)),
))
)
);
ActionRequest changedFieldsRequest = Requests.newActionRequest("test", "id", getChangedWatchedFields.name());
// when
// then
}
@Test
public void testActionForChangedPassword() throws Exception {
// given
)),
))
)
);
ActionRequest changedPasswordRequest = Requests.newActionRequest("test", "id", getChangedPasswordFields.name());
//when
//then
}
@Test
public void testAuditServiceQuery() throws Exception {
//given
//when
Promise<QueryResponse, ResourceException> promise = auditService.handleQuery(new RootContext(), queryRequest,
//then
}
@Test
public void testExceptionFormmatter() throws Exception {
//given
.transactionId("transactionId")
.eventName("eventName")
.authentication("testuser@forgerock.com")
.toEvent();
//when
new RootContext(), createRequest);
//then
}
@Test
public void testAvailableHandlersAction() throws Exception {
//when
//then
.isEqualTo("org.forgerock.openidm.audit.events.handlers.impl.PassThroughAuditEventHandler");
// { "type": "object", "properties": { "message": { "type": "string" } } }
))
))
));
}
}
return auditService;
}
static class TestAuditEventBuilder<T extends TestAuditEventBuilder<T>>
extends AuditEventBuilder<T> {
@SuppressWarnings("rawtypes")
public static TestAuditEventBuilder<?> testAuditEventBuilder() {
return new TestAuditEventBuilder();
}
return self();
}
}
}