use of org.mockito.ArgumentCaptor in project OpenAM by OpenRock.
the class PolicyResourceDelegateTest method shouldHandleFailureToCreatePoliciesByDeletingCreatedPolicies.
@Test(expectedExceptions = ResourceException.class)
public void shouldHandleFailureToCreatePoliciesByDeletingCreatedPolicies() throws ResourceException {
//Given
//Given
Context context = mock(Context.class);
Set<JsonValue> policies = new HashSet<JsonValue>();
JsonValue policyOne = json(object(field("name", "POLICY_ONE")));
JsonValue policyTwo = json(object(field("name", "POLICY_TWO")));
policies.add(policyOne);
policies.add(policyTwo);
ResourceResponse createdPolicyOne = newResourceResponse("ID_1", "REVISION_1", json(object()));
ResourceException exception = mock(ResourceException.class);
Promise<ResourceResponse, ResourceException> createPolicyOnePromise = Promises.newResultPromise(createdPolicyOne);
Promise<ResourceResponse, ResourceException> createPolicyTwoPromise = Promises.newExceptionPromise(exception);
Promise<ResourceResponse, ResourceException> deletePolicyOnePromise = Promises.newResultPromise(createdPolicyOne);
given(policyResource.handleCreate(eq(context), Matchers.<CreateRequest>anyObject())).willReturn(createPolicyOnePromise).willReturn(createPolicyTwoPromise);
given(policyResource.handleDelete(eq(context), Matchers.<DeleteRequest>anyObject())).willReturn(deletePolicyOnePromise);
//When
try {
delegate.createPolicies(context, policies).getOrThrowUninterruptibly();
} catch (ResourceException e) {
//Then
ArgumentCaptor<DeleteRequest> requestCaptor = ArgumentCaptor.forClass(DeleteRequest.class);
verify(policyResource).handleDelete(eq(context), requestCaptor.capture());
assertThat(requestCaptor.getValue().getResourcePathObject().leaf()).isEqualTo("ID_1");
throw e;
}
}
use of org.mockito.ArgumentCaptor in project sakuli by ConSol.
the class TestCaseActionTest method testAddRelativeImagePaths.
@Test
public void testAddRelativeImagePaths() throws Exception {
Path currenPath = Paths.get(".").toAbsolutePath().normalize();
sample.setTcFile(currenPath.resolve("tc.js"));
ArgumentCaptor path = ArgumentCaptor.forClass(Path.class);
String picfolderName = "my_pic_folder";
testling.addImagePathsAsString(picfolderName);
verify(loaderMock).addImagePaths((Path[]) path.capture());
assertEquals(path.getValue().toString(), currenPath.toString() + File.separator + picfolderName);
}
use of org.mockito.ArgumentCaptor in project sakuli by ConSol.
the class TestCaseActionTest method testAddImagePaths.
@Test
public void testAddImagePaths() throws Exception {
ArgumentCaptor path = ArgumentCaptor.forClass(Path.class);
testling.addImagePathsAsString("/home");
verify(loaderMock).addImagePaths((Path[]) path.capture());
assertEquals(path.getValue().toString(), Paths.get("/home").normalize().toString());
}
Aggregations