@CheckForNull
Snapshot getBaseProjectSnapshot();
+ /**
+ * @throws IllegalStateException if cross project duplication flag has not been set
+ */
+ boolean isCrossProjectDuplicationEnabled();
+
}
@CheckForNull
private Snapshot baseProjectSnapshot;
+ @CheckForNull
+ private Boolean isCrossProjectDuplicationEnabled;
+
@Override
public void setAnalysisDate(Date date) {
checkState(analysisDate == null, "Analysis date has already been set");
return baseProjectSnapshot;
}
+ @Override
+ public void setIsCrossProjectDuplicationEnabled(boolean isCrossProjectDuplicationEnabled) {
+ checkState(this.isCrossProjectDuplicationEnabled == null, "Cross project duplication flag has already been set");
+ this.isCrossProjectDuplicationEnabled = isCrossProjectDuplicationEnabled;
+ }
+
+ @Override
+ public boolean isCrossProjectDuplicationEnabled() {
+ checkState(isCrossProjectDuplicationEnabled != null, "Cross project duplication flag has not been set");
+ return isCrossProjectDuplicationEnabled;
+ }
}
*/
void setBaseProjectSnapshot(@Nullable Snapshot baseProjectSnapshot);
+ /**
+ * @throws IllegalStateException if cross project duplication flag has already been set
+ */
+ void setIsCrossProjectDuplicationEnabled(boolean isCrossProjectDuplicationEnabled);
+
}
expectedException.expectMessage("Base project snapshot has already been set");
underTest.setBaseProjectSnapshot(BASE_PROJECT_SNAPSHOT);
}
+
+ @Test
+ public void isCrossProjectDuplicationEnabled_return_true() {
+ AnalysisMetadataHolderImpl underTest = new AnalysisMetadataHolderImpl();
+
+ underTest.setIsCrossProjectDuplicationEnabled(true);
+
+ assertThat(underTest.isCrossProjectDuplicationEnabled()).isEqualTo(true);
+ }
+
+ @Test
+ public void isCrossProjectDuplicationEnabled_return_false() {
+ AnalysisMetadataHolderImpl underTest = new AnalysisMetadataHolderImpl();
+
+ underTest.setIsCrossProjectDuplicationEnabled(false);
+
+ assertThat(underTest.isCrossProjectDuplicationEnabled()).isEqualTo(false);
+ }
+
+ @Test
+ public void isCrossProjectDuplicationEnabled_throws_ISE_when_holder_is_not_initialized() {
+ expectedException.expect(IllegalStateException.class);
+ expectedException.expectMessage("Cross project duplication flag has not been set");
+
+ new AnalysisMetadataHolderImpl().isCrossProjectDuplicationEnabled();
+ }
+
+ @Test
+ public void setIsCrossProjectDuplicationEnabled_throws_ISE_when_called_twice() {
+ AnalysisMetadataHolderImpl underTest = new AnalysisMetadataHolderImpl();
+ underTest.setIsCrossProjectDuplicationEnabled(true);
+
+ expectedException.expect(IllegalStateException.class);
+ expectedException.expectMessage("Cross project duplication flag has already been set");
+ underTest.setIsCrossProjectDuplicationEnabled(false);
+ }
}
return delegate.isFirstAnalysis();
}
+ @Override
+ public void setBaseProjectSnapshot(@Nullable Snapshot baseProjectSnapshot) {
+ delegate.setBaseProjectSnapshot(baseProjectSnapshot);
+ }
+
@Override
@CheckForNull
public Snapshot getBaseProjectSnapshot() {
}
@Override
- public void setBaseProjectSnapshot(@Nullable Snapshot baseProjectSnapshot) {
- delegate.setBaseProjectSnapshot(baseProjectSnapshot);
+ public boolean isCrossProjectDuplicationEnabled() {
+ return delegate.isCrossProjectDuplicationEnabled();
+ }
+
+ @Override
+ public void setIsCrossProjectDuplicationEnabled(boolean isCrossProjectDuplicationEnabled) {
+ delegate.setIsCrossProjectDuplicationEnabled(isCrossProjectDuplicationEnabled);
}
}