test_class.declarator: buildCapabilityProcess = new BuildCapabilityProcess()
test_class.modifier: private
test_class.original_string: private BuildCapabilityProcess buildCapabilityProcess = new BuildCapabilityProcess();
test_class.type: BuildCapabilityProcess
test_class.var_name: buildCapabilityProcess
test_class.file: component/core/src/test/java/fr/norad/visuwall/core/business/process/capabilities/BuildCapabilityProcessTest.java
test_class.identifier: BuildCapabilityProcessTest
test_case.body: @Test
      public void should_not_return_update_needed_when_still_building_in_software() throws Exception {
          Project project = initProject("42", false, "42", true);
  
          String[] buildIdToUpdate = buildCapabilityProcess.updateStatusAndReturnBuildsToUpdate(project);
  
          Assert.assertArrayEquals(new String[] {}, buildIdToUpdate);
          Assert.assertTrue(project.getLastBuild().isBuilding());
          Assert.assertEquals("42", project.getLastBuildId());
          Mockito.verify(buildCapabilityProcess.scheduler).schedule(Matchers.any(Runnable.class),
                  Matchers.any(Date.class));
      }
test_case.class_method_signature: BuildCapabilityProcessTest.should_not_return_update_needed_when_still_building_in_software()
test_case.full_signature: @Test public void should_not_return_update_needed_when_still_building_in_software()
test_case.identifier: should_not_return_update_needed_when_still_building_in_software
test_case.invocations: initProject updateStatusAndReturnBuildsToUpdate assertArrayEquals assertTrue isBuilding getLastBuild assertEquals getLastBuildId schedule verify any any
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void should_not_return_update_needed_when_still_building_in_software()
focal_class.declarator: LOG = LoggerFactory.getLogger(BuildCapabilityProcess.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger LOG = LoggerFactory.getLogger(BuildCapabilityProcess.class);
focal_class.type: Logger
focal_class.var_name: LOG
focal_class.declarator: scheduler
focal_class.modifier: @Autowired
focal_class.original_string: @Autowired
      TaskScheduler scheduler;
focal_class.type: TaskScheduler
focal_class.var_name: scheduler
focal_class.file: component/core/src/main/java/fr/norad/visuwall/core/business/process/capabilities/BuildCapabilityProcess.java
focal_class.identifier: BuildCapabilityProcess
focal_class.class_method_signature: BuildCapabilityProcess.updatePreviousCompletedBuild(Project project)
focal_class.full_signature: public void updatePreviousCompletedBuild(Project project)
focal_class.identifier: updatePreviousCompletedBuild
focal_class.modifiers: public
focal_class.parameters: (Project project)
focal_class.return: void
focal_class.signature: void updatePreviousCompletedBuild(Project project)
focal_class.class_method_signature: BuildCapabilityProcess.getCreatedWithContentBuild(Project project, String buildId)
focal_class.full_signature: private Build getCreatedWithContentBuild(Project project, String buildId)
focal_class.identifier: getCreatedWithContentBuild
focal_class.modifiers: private
focal_class.parameters: (Project project, String buildId)
focal_class.return: Build
focal_class.signature: Build getCreatedWithContentBuild(Project project, String buildId)
focal_class.class_method_signature: BuildCapabilityProcess.updateLastNotBuildingId(Project project)
focal_class.full_signature: public void updateLastNotBuildingId(Project project)
focal_class.identifier: updateLastNotBuildingId
focal_class.modifiers: public
focal_class.parameters: (Project project)
focal_class.return: void
focal_class.signature: void updateLastNotBuildingId(Project project)
focal_class.class_method_signature: BuildCapabilityProcess.updateBuild(Project project, String buildId)
focal_class.full_signature: public void updateBuild(Project project, String buildId)
focal_class.identifier: updateBuild
focal_class.modifiers: public
focal_class.parameters: (Project project, String buildId)
focal_class.return: void
focal_class.signature: void updateBuild(Project project, String buildId)
focal_class.class_method_signature: BuildCapabilityProcess.updateStatusAndReturnBuildsToUpdate(Project project)
focal_class.full_signature: public String[] updateStatusAndReturnBuildsToUpdate(Project project)
focal_class.identifier: updateStatusAndReturnBuildsToUpdate
focal_class.modifiers: public
focal_class.parameters: (Project project)
focal_class.return: String[]
focal_class.signature: String[] updateStatusAndReturnBuildsToUpdate(Project project)
focal_class.class_method_signature: BuildCapabilityProcess.getEstimatedFinishTimeRunner(final Project project, final Build build)
focal_class.full_signature:  Runnable getEstimatedFinishTimeRunner(final Project project, final Build build)
focal_class.identifier: getEstimatedFinishTimeRunner
focal_class.parameters: (final Project project, final Build build)
focal_class.return: Runnable
focal_class.signature: Runnable getEstimatedFinishTimeRunner(final Project project, final Build build)
focal_method.body: public String[] updateStatusAndReturnBuildsToUpdate(Project project) throws ProjectNotFoundException,
              BuildNotFoundException {
          try {
              String lastBuildId = project.getBuildConnection().getLastBuildId(project.getBuildProjectId());
              boolean lastBuilding = project.getBuildConnection().isBuilding(project.getBuildProjectId(), lastBuildId);
  
              String previousLastBuildId = project.getLastBuildId();
              boolean previousBuilding = false;
              try {
                  previousBuilding = project.getLastBuild().isBuilding();
              } catch (BuildNotFoundException e) {
                  LOG.debug("No lastBuild found to say the project was building before refresh " + project);
              }
  
              Build lastBuild = project.findCreatedBuild(lastBuildId);
  
              try {
                  if (previousBuilding == false && lastBuilding == false && !lastBuildId.equals(previousLastBuildId)) {
                      LOG.info("there is an already finished new build {}  {}", lastBuildId, project);
                      return new String[] { lastBuildId };
                  }
                  if (previousBuilding == false && lastBuilding == true) {
                      LOG.info("Build {} is now running {}", lastBuild.getBuildId(), project);
                      Runnable finishTimeRunner = getEstimatedFinishTimeRunner(project, lastBuild);
                      scheduler.schedule(finishTimeRunner, new Date());
                  }
                  if (previousBuilding == true && lastBuilding == true) {
                      if (!lastBuildId.equals(previousLastBuildId)) {
                          LOG.info("Previous build {} is over and a new build {} is already running {}", new Object[] {
                                  previousLastBuildId, lastBuildId, project });
                          project.getBuilds().get(previousLastBuildId).setEstimatedFinishTime(null);
                          project.getBuilds().get(previousLastBuildId).setBuilding(false);
                          Runnable finishTimeRunner = getEstimatedFinishTimeRunner(project, lastBuild);
                          scheduler.schedule(finishTimeRunner, new Date());
                          return new String[] { previousLastBuildId };
                      }
                      // building is still running
                  }
  
                  if (previousBuilding == true && lastBuilding == false) {
                      // build is over
                      project.getBuilds().get(previousLastBuildId).setEstimatedFinishTime(null);
                      project.getBuilds().get(previousLastBuildId).setBuilding(false);
                      if (!lastBuildId.equals(previousLastBuildId)) {
                          LOG.info("previous build {} is over and a new build {} is also over {}", new Object[] {
                                  previousLastBuildId, lastBuildId, project });
                          return new String[] { previousLastBuildId, lastBuildId };
                      }
                      LOG.info("Previous build {} is over and no new build ", previousLastBuildId, project);
                      return new String[] { previousLastBuildId };
                  }
              } finally {
                  lastBuild.setBuilding(lastBuilding);
                  project.setLastBuildId(lastBuildId);
              }
          } catch (BuildIdNotFoundException e) {
              LOG.debug("No last build id found to update project " + project);
          }
          return new String[] {};
      }
focal_method.class_method_signature: BuildCapabilityProcess.updateStatusAndReturnBuildsToUpdate(Project project)
focal_method.full_signature: public String[] updateStatusAndReturnBuildsToUpdate(Project project)
focal_method.identifier: updateStatusAndReturnBuildsToUpdate
focal_method.invocations: getLastBuildId getBuildConnection getBuildProjectId isBuilding getBuildConnection getBuildProjectId getLastBuildId isBuilding getLastBuild debug findCreatedBuild equals info info getBuildId getEstimatedFinishTimeRunner schedule equals info setEstimatedFinishTime get getBuilds setBuilding get getBuilds getEstimatedFinishTimeRunner schedule setEstimatedFinishTime get getBuilds setBuilding get getBuilds equals info info setBuilding setLastBuildId debug
focal_method.modifiers: public
focal_method.parameters: (Project project)
focal_method.return: String[]
focal_method.signature: String[] updateStatusAndReturnBuildsToUpdate(Project project)