### Question:
BuildHelper { public BuildResults buildAndDeploy(final Module module) { return buildAndDeploy(module, DeploymentMode.VALIDATED); } BuildHelper(); @Inject  BuildHelper(final POMService pomService,
                       final ExtendedM2RepoService m2RepoService,
                       final KieModuleService moduleService,
                       final DeploymentVerifier deploymentVerifier,
                       final LRUBuilderCache cache,
                       final Instance<PostBuildHandler> handlers,
                       final Instance<User> identity); BuildResult build(final Module module); IncrementalBuildResults addPackageResource(final Path resource); IncrementalBuildResults deletePackageResource(final Path resource); IncrementalBuildResults updatePackageResource(final Path resource); IncrementalBuildResults applyBatchResourceChanges(final Module module,
                                                             final Map<Path, Collection<ResourceChange>> changes); BuildResults buildExceptionResults(Exception e,
                                              GAV gav); BuildResults buildAndDeploy(final Module module); BuildResults buildAndDeploy(final Module module,
                                       final DeploymentMode mode); BuildResults buildAndDeploy(final Module module,
                                       final boolean suppressHandlers); BuildResults buildAndDeploy(final Module module,
                                       final boolean suppressHandlers,
                                       final DeploymentMode mode);  }### Answer:
@Test public void testBuildAndDeployNonSnapshotNotDeployed() { final GAV gav = new GAV(GROUP_ID, ARTIFACT_ID, VERSION); prepareBuildAndDeploy(rootPath, gav, false); buildHelper.buildAndDeploy(module); verify(buildHelper, times(1)).buildAndDeploy(eq(module), eq(DeploymentMode.VALIDATED)); verifyBuildAndDeploy(module, gav); }
@Test public void testBuildAndDeployNonSnapshotAlreadyDeployed() { final GAV gav = new GAV(GROUP_ID, ARTIFACT_ID, VERSION); prepareBuildAndDeploy(rootPath, gav, true); Exception exception = null; try { buildHelper.buildAndDeploy(module); } catch (Exception e) { exception = e; } verify(buildHelper, times(1)).buildAndDeploy(eq(module), eq(DeploymentMode.VALIDATED)); assertNotNull(exception); assertTrue(exception instanceof GAVAlreadyExistsException); assertEquals(gav, ((GAVAlreadyExistsException) exception).getGAV()); }
@Test public void testBuildAndDeploySnapshot() { final GAV gav = new GAV(GROUP_ID, ARTIFACT_ID, SNAPSHOT_VERSION); prepareBuildAndDeploy(snapshotRootPath, gav); buildHelper.buildAndDeploy(module); verify(buildHelper, times(1)).buildAndDeploy(eq(module), eq(DeploymentMode.VALIDATED)); verifyBuildAndDeploySnapshot(module, gav); }
@Test public void testBuildAndDeploySuppressHandlersNonSnapshot() { final GAV gav = new GAV(GROUP_ID, ARTIFACT_ID, VERSION); prepareBuildAndDeploy(rootPath, gav); buildHelper.buildAndDeploy(module, true); verify(buildHelper, times(1)).buildAndDeploy(eq(module), eq(true), eq(DeploymentMode.VALIDATED)); verifyBuildAndDeploy(module, gav); }
@Test public void testBuildAndDeploySuppressHandlersSnapshot() { final GAV gav = new GAV(GROUP_ID, ARTIFACT_ID, SNAPSHOT_VERSION); prepareBuildAndDeploy(snapshotRootPath, gav); buildHelper.buildAndDeploy(module, true); verify(buildHelper, times(1)).buildAndDeploy(eq(module), eq(true), eq(DeploymentMode.VALIDATED)); verifyBuildAndDeploySnapshot(module, gav); }