Project implements Serializable, Runnable { Element getModifications(final boolean buildWasForced) { setState(ProjectState.MODIFICATIONSET); final ModificationSet modificationSet = projectConfig.getModificationSet(); if (modificationSet == null) { debug("no modification set, nothing to detect."); if (buildWasForced) { info("no modification set but build was forced"); return new Element("modifications"); } if (!requiremodification) { info("no modification set but no modifications required"); return new Element("modifications"); } return null; } final boolean checkNewChangesFirst = checkOnlySinceLastBuild(); Element modifications; if (checkNewChangesFirst) { debug("getting changes since last build"); modifications = modificationSet.retrieveModificationsAsElement(lastBuild, progress); } else { debug("getting changes since last successful build"); modifications = modificationSet.retrieveModificationsAsElement(lastSuccessfulBuild, progress); } if (!modificationSet.isModified()) { info("No modifications found, build not necessary."); if (buildAfterFailed && !wasLastBuildSuccessful) { info("Building anyway, since buildAfterFailed is true and last build failed."); } else if (!requiremodification) { info("Building anyway, since modifications not required"); } else { if (buildWasForced) { info("Building anyway, since build was explicitly forced."); } else { return null; } } } if (checkNewChangesFirst) { debug("new changes found; now getting complete set"); modifications = modificationSet.retrieveModificationsAsElement(lastSuccessfulBuild, progress); } return modifications; } Project(); void execute(); void run(); void forceBuildWithTarget(String buildTarget); void forceBuildWithTarget(String buildTarget, Map<String, String> addedProperties); void serializeProject(); void setLabelIncrementer(final LabelIncrementer incrementer); LabelIncrementer getLabelIncrementer(); void setName(final String projectName); String getName(); void setLabel(final String newLabel); String getLabel(); void setLastBuild(final String newLastBuild); void setLastSuccessfulBuild(final String newLastSuccessfulBuild); String getLastBuild(); boolean getBuildForced(); void setBuildForced(boolean forceNewBuildNow); String getLastSuccessfulBuild(); String getLogDir(); long getBuildInterval(); void overrideBuildInterval(final long sleepMillis); boolean isPaused(); void setPaused(final boolean paused); void setBuildAfterFailed(final boolean rebuildEvenWithNoNewModifications); String getStatus(); String getStatusWithQueuePosition(); ProjectState getState(); void setBuildQueue(final BuildQueue buildQueue); String getBuildStartTime(); Log getLog(); boolean isLastBuildSuccessful(); void start(); void stop(); String toString(); void addBuildProgressListener(final BuildProgressListener listener); void addBuildResultListener(final BuildResultListener listener); void setProjectConfig(final ProjectConfig projectConfig); boolean equals(final Object arg0); int hashCode(); void register(final MBeanServer server); ProjectConfig getProjectConfig(); Date getLastBuildDate(); Progress getProgress(); List<String> getLogLabels(); String[] getLogLabelLines(final String logLabel, final int firstLine);  }
@Test public void testGetModifications() { MockModificationSet modSet = new MockModificationSet(); Element modifications = modSet.retrieveModificationsAsElement(null, null); projectConfig.add(modSet); project.init(); modSet.setModified(true); assertEquals(modifications, project.getModifications(false)); assertEquals(modifications, project.getModifications(true)); modSet.setModified(false); assertEquals(null, project.getModifications(false)); assertEquals(modifications, project.getModifications(true)); }