createBasicTargetObject("testAutoApproveTarget");
return null;
}
}, false, TargetObject.TOPIC_ADDED, TOPIC_ADDED);
final StatefulTargetObject sgo =
m_statefulTargetRepository.get(
m_bundleContext.createFilter("(" + TargetObject.KEY_ID + "=" + "testAutoApproveTarget)")).get(0);
// Set up some deployment information for the target.
final FeatureObject g = runAndWaitForEvent(new Callable<FeatureObject>() {
public FeatureObject call() throws Exception {
ArtifactObject b = createBasicBundleObject("myBundle", "1.0", null);
FeatureObject g = createBasicFeatureObject("myFeature");
DistributionObject l = createBasicDistributionObject("myDistribution");
m_artifact2featureRepository.create(b, g);
m_feature2distributionRepository.create(g, l);
m_distribution2targetRepository.create(l, sgo.getTargetObject());
return g;
}
}, false, ArtifactObject.TOPIC_ADDED, FeatureObject.TOPIC_ADDED, DistributionObject.TOPIC_ADDED,
Artifact2FeatureAssociation.TOPIC_ADDED, Feature2DistributionAssociation.TOPIC_ADDED,
Distribution2TargetAssociation.TOPIC_ADDED, TOPIC_STATUS_CHANGED);
assertTrue("We added some deployment information, so the target should need approval.", sgo.needsApprove());
sgo.setAutoApprove(true);
assertTrue("Turning on the autoapprove should not automatically approve whatever was waiting.", sgo.needsApprove());
runAndWaitForEvent(new Callable<Object>() {
public Object call() throws Exception {
sgo.approve();
return null;
}
}, false, TOPIC_STATUS_CHANGED);
assertFalse("We approved the new version by hand, so we should not need approval.", sgo.needsApprove());
runAndWaitForEvent(new Callable<Object>() {
public Object call() throws Exception {
ArtifactObject b = createBasicBundleObject("myBundle2", "1.0", null);
m_artifact2featureRepository.create(b, g);
return null;
}
}, false, ArtifactObject.TOPIC_ADDED, Artifact2FeatureAssociation.TOPIC_ADDED, TOPIC_STATUS_CHANGED,
TOPIC_STATUS_CHANGED);
assertFalse("With autoapprove on, adding new deployment information should still not need approval (at least, after the two CHANGED events).", sgo.needsApprove());
runAndWaitForEvent(new Callable<Object>() {
public Object call() throws Exception {
m_statefulTargetRepository.unregister(sgo.getID());
return null;
}
}, false, TOPIC_STATUS_CHANGED, TOPIC_REMOVED);
}