diff --git a/elasticsearch/src/test/java/org/elasticsearch/xpack/prelert/job/persistence/MockClientBuilder.java b/elasticsearch/src/test/java/org/elasticsearch/xpack/prelert/job/persistence/MockClientBuilder.java index 6cd46ea6c5e..3002c466b31 100644 --- a/elasticsearch/src/test/java/org/elasticsearch/xpack/prelert/job/persistence/MockClientBuilder.java +++ b/elasticsearch/src/test/java/org/elasticsearch/xpack/prelert/job/persistence/MockClientBuilder.java @@ -171,8 +171,10 @@ public class MockClientBuilder { ActionListener actionListener) throws InterruptedException, ExecutionException, IOException { DeleteIndexResponse response = DeleteIndexAction.INSTANCE.newResponse(); StreamInput si = mock(StreamInput.class); - when(si.readByte()).thenReturn((byte) 0x41); - when(si.readMap()).thenReturn(mock(Map.class)); + // this looks complicated but Mockito can't mock the final method + // DeleteIndexResponse.isAcknowledged() and the only way to create + // one with a true response is reading from a stream. + when(si.readByte()).thenReturn((byte) 0x01); response.readFrom(si); doAnswer(invocation -> {