PolicyResourceDelegateTest.java revision bb788488efdd119f14e88ccc5a3cf302e743bcc4
/*
* 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 2015 ForgeRock AS.
*/
public class PolicyResourceDelegateTest {
private PolicyResourceDelegate delegate;
private RequestHandler policyResource;
public void setup() {
}
@Test
public void shouldCreatePolicies() throws ResourceException {
//Given
//Given
Promise<ResourceResponse, ResourceException> createPolicyOnePromise = Promises.newResultPromise(createdPolicyOne);
Promise<ResourceResponse, ResourceException> createPolicyTwoPromise = Promises.newResultPromise(createdPolicyTwo);
//When
List<ResourceResponse> returnedPolicies = delegate.createPolicies(context, policies).getOrThrowUninterruptibly();
//Then
}
public void shouldHandleFailureToCreatePoliciesByDeletingCreatedPolicies() throws ResourceException {
//Given
//Given
Promise<ResourceResponse, ResourceException> createPolicyOnePromise = Promises.newResultPromise(createdPolicyOne);
Promise<ResourceResponse, ResourceException> createPolicyTwoPromise = Promises.newExceptionPromise(exception);
Promise<ResourceResponse, ResourceException> deletePolicyOnePromise = Promises.newResultPromise(createdPolicyOne);
//When
try {
} catch (ResourceException e) {
//Then
throw e;
}
}
public void shouldHandleFailureToDeleteFailedCreationOfPolicies() throws ResourceException {
//Given
//Given
Promise<ResourceResponse, ResourceException> createPolicyOnePromise = Promises.newResultPromise(createdPolicyOne);
Promise<ResourceResponse, ResourceException> createPolicyTwoPromise = Promises.newExceptionPromise(createException);
Promise<ResourceResponse, ResourceException> deletePolicyOnePromise = Promises.newExceptionPromise(deleteException);
//When
try {
} catch (ResourceException e) {
//Then
throw e;
}
}
@Test
public void shouldUpdatePolicies() throws ResourceException {
//Given
Promise<ResourceResponse, ResourceException> updatePolicyOnePromise = Promises.newResultPromise(updatedPolicyOne);
Promise<ResourceResponse, ResourceException> updatePolicyTwoPromise = Promises.newResultPromise(updatedPolicyTwo);
//When
List<ResourceResponse> returnedPolicies = delegate.updatePolicies(context, policies).getOrThrowUninterruptibly();
//Then
}
public void shouldHandleFailureToUpdatePolicies() throws ResourceException {
//Given
Promise<ResourceResponse, ResourceException> updatePolicyOnePromise = Promises.newResultPromise(updatedPolicyOne);
Promise<ResourceResponse, ResourceException> updatePolicyTwoPromise = Promises.newExceptionPromise(exception);
//When
//Then
//Expected ResourceException
}
@Test
public void shouldQueryPolicies() throws ResourceException {
//Given
//When
//Then
}
@Test
public void shouldQueryPoliciesWithHandler() throws ResourceException {
//Given
//When
//Then
}
@Test
public void shouldDeletePolicies() throws ResourceException {
//Given
Promise<ResourceResponse, ResourceException> deletePolicyOnePromise = Promises.newResultPromise(policyOne);
Promise<ResourceResponse, ResourceException> deletePolicyTwoPromise = Promises.newResultPromise(policyTwo);
//When
List<ResourceResponse> deletedPolicies = delegate.deletePolicies(context, policyIds).getOrThrowUninterruptibly();
//Then
}
public void shouldHandleFailureToDeletePolicies() throws ResourceException {
//Given
Promise<ResourceResponse, ResourceException> deletePolicyOnePromise = Promises.newResultPromise(policyOne);
Promise<ResourceResponse, ResourceException> deletePolicyTwoPromise = Promises.newExceptionPromise(exception);
//When
//Then
//Expected ResourceException
}
}