### Question:
JApiCmpMojo extends AbstractMojo { void breakBuildIfNecessary(List<JApiClass> jApiClasses, Parameter parameterParam, Options options, JarArchiveComparator jarArchiveComparator) throws MojoFailureException, MojoExecutionException { if (breakBuildBasedOnSemanticVersioning(parameterParam)) { options.setErrorOnSemanticIncompatibility(true); } if (breakBuildBasedOnSemanticVersioningForMajorVersionZero(parameterParam)) { options.setErrorOnSemanticIncompatibilityForMajorVersionZero(true); } if (breakBuildOnBinaryIncompatibleModifications(parameterParam)) { options.setErrorOnBinaryIncompatibility(true); } if (breakBuildOnSourceIncompatibleModifications(parameterParam)) { options.setErrorOnSourceIncompatibility(true); } if (breakBuildOnModificationsParameter(parameterParam)) { options.setErrorOnModifications(true); } if (!parameterParam.isBreakBuildIfCausedByExclusion()) { options.setErrorOnExclusionIncompatibility(false); } if (parameter != null && parameter.getIgnoreMissingOldVersion()) { options.setIgnoreMissingOldVersion(true); } if (parameter != null && parameter.getIgnoreMissingNewVersion()) { options.setIgnoreMissingNewVersion(true); } IncompatibleErrorOutput errorOutput = new IncompatibleErrorOutput(options, jApiClasses, jarArchiveComparator) { @Override protected void warn(String msg, Throwable error) { getLog().warn(msg, error); } }; try { errorOutput.generate(); } catch (JApiCmpException e) { if (e.getReason() == JApiCmpException.Reason.IncompatibleChange) { throw new MojoFailureException(e.getMessage()); } else { throw new MojoExecutionException("Error while checking for incompatible changes", e); } } }  void execute();  }### Answer:
@Test public void testBreakBuildIfNecessaryMultipleChanges() throws Exception { Options options = Options.newDefault(); JarArchiveComparatorOptions jarArchiveComparatorOptions = JarArchiveComparatorOptions.of(options); ClassesHelper.CompareClassesResult compareClassesResult = ClassesHelper.compareClasses(jarArchiveComparatorOptions, new ClassesHelper.ClassesGenerator() { @Override public List<CtClass> createOldClasses(ClassPool classPool) throws Exception { CtClass typeCtClass = CtClassBuilder.create().name("japicmp.SuperType").addToClassPool(classPool); CtClass ctClass = CtClassBuilder.create().name("japicmp.Test").withSuperclass(typeCtClass).addToClassPool(classPool); CtFieldBuilder.create().name("field").type(CtClass.intType).addToClass(ctClass); CtMethodBuilder.create().publicAccess().returnType(CtClass.voidType).name("method").addToClass(ctClass); return Arrays.asList(typeCtClass, ctClass); } @Override public List<CtClass> createNewClasses(ClassPool classPool) throws Exception { CtClass ctClass = CtClassBuilder.create().name("japicmp.Test").addToClassPool(classPool); return Collections.singletonList(ctClass); } }); JApiCmpMojo mojo = new JApiCmpMojo(); Parameter parameterParam = new Parameter(); parameterParam.setBreakBuildOnBinaryIncompatibleModifications(true); parameterParam.setBreakBuildOnSourceIncompatibleModifications(true); try { mojo.breakBuildIfNecessary(compareClassesResult.getjApiClasses(), parameterParam, options, compareClassesResult.getJarArchiveComparator()); fail("No exception thrown."); } catch (MojoFailureException e) { String msg = e.getMessage(); assertThat(msg, containsString("japicmp.SuperType:CLASS_REMOVED")); assertThat(msg, containsString("japicmp.Test.method():METHOD_REMOVED")); assertThat(msg, containsString("japicmp.Test.field:FIELD_REMOVED")); assertThat(msg, containsString("japicmp.Test:SUPERCLASS_REMOVED")); } }