@Test
public void itFailsBuildOfBranchWhenItHasMalformedFiles() throws Exception {

  when(malformedFileService.getMalformedFiles(anyInt()))
      .thenReturn(ImmutableSet.of(new MalformedFile(1, "config", "/.blazar.yaml", "this is a test malformed file")));
  when(moduleService.getByBranch(1)).thenReturn(ImmutableSet.of(activeModule, inactiveModule));
  boolean[] moduleBuildFailed = {false};
  doAnswer(invocation ->  {
    RepositoryBuild build = (RepositoryBuild) invocation.getArguments()[0];
    Module module = (Module) invocation.getArguments()[1];
    assertThat(module.equals(activeModule));
    assertThat(build.equals(launchingBuild));
    moduleBuildFailed[0] = true;
    return null;
  }).when(moduleBuildService).createFailedBuild(any(), any());
  boolean[] repoBuildFailed = {false};
  doAnswer(invocation -> {
    RepositoryBuild build = (RepositoryBuild) invocation.getArguments()[0];
    assertThat(build).isEqualTo(launchingBuild);
    repoBuildFailed[0] = true;
    return null;
  }).when(repositoryBuildService).fail(any());
  buildVisitor.visitLaunching(launchingBuild);
  assertThat(repoBuildFailed[0]).isTrue();
  assertThat(moduleBuildFailed[0]).isTrue();
}