@Test
    void removeAllWithOneImageAndInvalidPattern() throws IOException {
        givenProjectWithResolvedImage(singleImageWithoutBuildOrRunWithRemoveNamePattern("%regex[[]"));

        givenRemoveMode("all");

        givenListOfImageNames("example:latest");

        Assertions.assertThrows(MojoExecutionException.class, this::whenMojoExecutes);

        thenListImagesIsNotCalled();
        thenRemoveImageIsNotCalledFor("example:latest");
    }
Mock project with one image that is removed by pattern
src/test/java/io/fabric8/maven/docker/RemoveMojoTest.java