@Test
  public void testCreateContainerBuilder_exceptionMessageHasPackageSuggestionIfProjectIsWar()
      throws IOException {
    String expectedMessage =
        "Obtaining project build output files failed; make sure you have "
            + "packaged your project before trying to build the image. (Did you accidentally run \"mvn clean "
            + "jib:build\" instead of \"mvn clean package jib:build\"?)";

    when(mockMavenProject.getPackaging()).thenReturn("war");
    when(mockTempDirectoryProvider.newDirectory()).thenThrow(IOException.class);

    for (ContainerizingMode containerizingMode : ContainerizingMode.values()) {
      IOException thrownException =
          assertThrows(
              IOException.class,
              () ->
                  mavenProjectProperties.createJibContainerBuilder(
                      mockJavaContainerBuilder, containerizingMode));
      assertThat(thrownException).hasMessageThat().isEqualTo(expectedMessage);
    }
  }
Helper for reading back layers in a {@link BuildContext}.
jib-maven-plugin/src/test/java/com/google/cloud/tools/jib/maven/MavenProjectPropertiesTest.java