private void verifyPersist(Object message) throws Exception { verifyPersist(message, new Same(message), true); }
@Test public void subCall() { Tracer tracer = mock(Tracer.class); InProcessExecutable victim = new InProcessExecutable(tracer); ExecutionContext ctx = mock(ExecutionContext.class); OperationKey expectedOp = new OperationKey(new ServiceVersion(1,0),"Wibble","wobble"); OperationKey op = new OperationKey(expectedOp, "_IN_PROCESS"); Object[] args = new Object[1]; ExecutionObserver obs = mock(ExecutionObserver.class); ExecutionVenue venue = mock(ExecutionVenue.class); TimeConstraints constraints = mock(TimeConstraints.class); RequestUUID parentUuid = new RequestUUIDImpl(); when(ctx.getRequestUUID()).thenReturn(parentUuid); when(ctx.isTransportSecure()).thenReturn(false); IdentityChain mockIdentityChain = new IdentityChainImpl(); when(ctx.getIdentity()).thenReturn(mockIdentityChain); GeoLocationDetails mockLocation = mock(GeoLocationDetails.class); when(ctx.getLocation()).thenReturn(mockLocation); when(ctx.getReceivedTime()).thenReturn(new Date(0L)); when(ctx.getRequestTime()).thenReturn(new Date(0L)); when(ctx.getTransportSecurityStrengthFactor()).thenReturn(0); victim.execute(ctx, op, args, obs, venue, constraints); ArgumentCaptor<ExecutionContext> arg1 = ArgumentCaptor.forClass(ExecutionContext.class); ArgumentCaptor<OperationKey> arg2 = ArgumentCaptor.forClass(OperationKey.class); ArgumentCaptor<Object[]> arg3 = ArgumentCaptor.forClass(Object[].class); ArgumentCaptor<ExecutionObserver> arg4 = ArgumentCaptor.forClass(ExecutionObserver.class); ArgumentCaptor<TimeConstraints> arg5 = ArgumentCaptor.forClass(TimeConstraints.class); // moved from this as it was failing and v hard to work out which bit was failing // verify(venue, times(1)).execute(argThat(isSubContextOf(ctx)),eq(new OperationKey(op, null)),same(args), // argThat(isTracingEndObserver(obs, parentUuid, op, tracer)),same(constraints)); verify(venue, times(1)).execute(arg1.capture(), arg2.capture(), arg3.capture(), arg4.capture(), arg5.capture()); assertThat(arg1.getValue(), isSubContextOf(ctx)); assertThat(arg2.getValue(), new Equals(expectedOp)); assertThat(arg3.getValue(), new Same(args)); assertThat(arg4.getValue(), isTracingEndObserver(obs, parentUuid, expectedOp, tracer)); assertThat(arg5.getValue(), new Same(constraints)); }