@Override public void process(ReplyProcessor cp) { cp.authTokenCheckFailed(this); }
private void validateAuthTokenCheckFailed(MockConnectionFactory factory, Supplier<CompletableFuture<?>> futureSupplier) { CompletableFuture<?> future = futureSupplier.get(); factory.rp.authTokenCheckFailed(new WireCommands.AuthTokenCheckFailed(0, "SomeException")); AssertExtensions.assertThrows("", future::join, ex -> ex instanceof WireCommandFailedException && ex.getCause() instanceof AuthenticationException); }
@Override public Void answer(InvocationOnMock invocation) throws Throwable { connectionFactory.getProcessor(endpoint).authTokenCheckFailed(new WireCommands.AuthTokenCheckFailed(100, "SomeException")); return null; } }).doAnswer(new Answer<Void>() {
@Test public void truncateSegment() { MockConnectionFactory factory = new MockConnectionFactory(); CompletableFuture<Boolean> retVal = helper.truncateSegment("", "", 0L, 0L, new MockHostControllerStore(), factory, "", System.nanoTime()); factory.rp.authTokenCheckFailed(new WireCommands.AuthTokenCheckFailed(0, "SomeException")); AssertExtensions.assertThrows("", () -> retVal.join(), ex -> ex instanceof WireCommandFailedException && ex.getCause() instanceof AuthenticationException ); }
@Test public void abortTransaction() { MockConnectionFactory factory = new MockConnectionFactory(); CompletableFuture<Controller.TxnStatus> retVal = helper.abortTransaction("", "", 0L, new UUID(0, 0L), new MockHostControllerStore(), factory, ""); factory.rp.authTokenCheckFailed(new WireCommands.AuthTokenCheckFailed(0, "SomeException")); AssertExtensions.assertThrows("", () -> retVal.join(), ex -> ex instanceof WireCommandFailedException && ex.getCause() instanceof AuthenticationException ); }
@Test public void sealSegment() { MockConnectionFactory factory = new MockConnectionFactory(); CompletableFuture<Boolean> retVal = helper.sealSegment("", "", 0L, new MockHostControllerStore(), factory, "", System.nanoTime()); factory.rp.authTokenCheckFailed(new WireCommands.AuthTokenCheckFailed(0, "SomeException")); AssertExtensions.assertThrows("", () -> retVal.join(), ex -> ex instanceof WireCommandFailedException && ex.getCause() instanceof AuthenticationException ); }
@Test public void createTransaction() { MockConnectionFactory factory = new MockConnectionFactory(); CompletableFuture<UUID> retVal = helper.createTransaction("", "", 0L, new UUID(0, 0L), new MockHostControllerStore(), factory, ""); factory.rp.authTokenCheckFailed(new WireCommands.AuthTokenCheckFailed(0, "SomeException")); AssertExtensions.assertThrows("", () -> retVal.join(), ex -> ex instanceof WireCommandFailedException && ex.getCause() instanceof AuthenticationException ); }
@Test public void deleteSegment() { MockConnectionFactory factory = new MockConnectionFactory(); CompletableFuture<Boolean> retVal = helper.deleteSegment("", "", 0L, new MockHostControllerStore(), factory, "", System.nanoTime()); factory.rp.authTokenCheckFailed(new WireCommands.AuthTokenCheckFailed(0, "SomeException")); AssertExtensions.assertThrows("", () -> retVal.join(), ex -> ex instanceof WireCommandFailedException && ex.getCause() instanceof AuthenticationException ); }
@Test public void commitTransaction() { MockConnectionFactory factory = new MockConnectionFactory(); CompletableFuture<Controller.TxnStatus> retVal = helper.commitTransaction("", "", 0L, 0L, new UUID(0, 0L), new MockHostControllerStore(), factory, ""); factory.rp.authTokenCheckFailed(new WireCommands.AuthTokenCheckFailed(0, "SomeException")); AssertExtensions.assertThrows("", () -> retVal.join(), ex -> ex instanceof WireCommandFailedException && ex.getCause() instanceof AuthenticationException ); }
@Test public void getSegmentInfo() { MockConnectionFactory factory = new MockConnectionFactory(); CompletableFuture<WireCommands.StreamSegmentInfo> retVal = helper.getSegmentInfo("", "", 0L, new MockHostControllerStore(), factory, ""); factory.rp.authTokenCheckFailed(new WireCommands.AuthTokenCheckFailed(0, "SomeException")); AssertExtensions.assertThrows("", () -> retVal.join(), ex -> ex instanceof WireCommandFailedException && ex.getCause() instanceof AuthenticationException ); }
@Test public void updatePolicy() { MockConnectionFactory factory = new MockConnectionFactory(); CompletableFuture<Void> retVal = helper.updatePolicy("", "", ScalingPolicy.fixed(1), 0L, new MockHostControllerStore(), factory, "", System.nanoTime()); factory.rp.authTokenCheckFailed(new WireCommands.AuthTokenCheckFailed(0, "SomeException")); AssertExtensions.assertThrows("", () -> retVal.join(), ex -> ex instanceof WireCommandFailedException && ex.getCause() instanceof AuthenticationException ); }
@Test public void createSegment() { MockConnectionFactory factory = new MockConnectionFactory(); CompletableFuture<Boolean> retVal = helper.createSegment("", "", 0, ScalingPolicy.fixed(2), new MockHostControllerStore(), factory, "", Long.MIN_VALUE); factory.rp.authTokenCheckFailed(new WireCommands.AuthTokenCheckFailed(0, "SomeException")); AssertExtensions.assertThrows("", () -> retVal.join(), ex -> ex instanceof WireCommandFailedException && ex.getCause() instanceof AuthenticationException ); }