final DistributionObject l1 = createBasicDistributionObject("thedistribution");
assertTrue("We just created a Stateful target object, is should not be registered", !sgo1.isRegistered());
// register sgo1 again and create an association in 1 go
Distribution2TargetAssociation lgw1 = runAndWaitForEvent(new Callable<Distribution2TargetAssociation>() {
public Distribution2TargetAssociation call() throws Exception {
sgo1.register();
return m_distribution2targetRepository.create(l1, sgo1.getTargetObject());
}
}, false, Distribution2TargetAssociation.TOPIC_ADDED, TargetObject.TOPIC_ADDED, TOPIC_STATUS_CHANGED);
// checks
nrRegistered =
m_statefulTargetRepository.get(
m_bundleContext.createFilter("(" + KEY_REGISTRATION_STATE + "=" + RegistrationState.Registered + ")"))
.size();
assert nrRegistered == 2 : "We expect to filter out two registered targets, but we find " + nrRegistered;
assertTrue("A stateful target object should be registered", sgo1.isRegistered());
assertTrue("The stateful target object should be associated to the distribution.", sgo1.isAssociated(l1, DistributionObject.class));
assertTrue("Both ends of distribution - stateful target should be satisfied.", lgw1.isSatisfied());
cleanUp();
}