Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Events predicate #793

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft

Events predicate #793

wants to merge 3 commits into from

Conversation

stbischof
Copy link
Contributor

@timothyjward any thoughts on that?

Signed-off-by: Stefan Bischof <stbischof@bipolis.org>
Signed-off-by: Stefan Bischof <stbischof@bipolis.org>
Signed-off-by: Stefan Bischof <stbischof@bipolis.org>
@timothyjward
Copy link
Contributor

Can you give an example of a test using these new predicates, and how it compares to the existing support? I can't quite wrap my head around how "normal usage" will look

@stbischof
Copy link
Contributor Author

stbischof commented Feb 7, 2024

exampleIntegrationTest() throws Exception {
		MonitoringAssertion.executeAndObserve(() -> {

			ServiceRegistration<Serializable> sr = bc.registerService(Serializable.class, new Serializable() {},
				Dictionaries.dictionaryOf("k", "v0"));

			sr.setProperties(Dictionaries.dictionaryOf("k", "v1"));
			sr.setProperties(Dictionaries.dictionaryOf("k", "v2"));
			sr.unregister();

		})
			.untilNoMoreServiceEventWithin(100l)// main stop-condition criteria
			.assertWithTimeoutThat(3000)// timeout to granite a stop
			.hasNoThrowable()// not exception thrown while executed
			.isNotTimedOut()// check that NOT timed-out
			.hasServiceEventsInOrder(//
				listOf(ServiceEventConditions.matches(ServiceEvent.REGISTERED, "(k=v0)"), //
					ServiceEventConditions.typeModifiedAndObjectClass(Serializable.class), //
					ServiceEventConditions.typeUnregisteringAndObjectClass(Serializable.class)))//
			.hasServiceEventsInExactOrder(//
				listOf(ServiceEventConditions.typeRegisteredWith(Serializable.class, mapOf("k", "v0")), //
					ServiceEventConditions.typeModifiedAndObjectClass(Serializable.class), //
					ServiceEventConditions.typeModifiedAndObjectClass(Serializable.class), //
					ServiceEventConditions.matches(ServiceEvent.UNREGISTERING, Serializable.class, mapOf("k", "v2"))))//
			.hasAtLeastNServiceEventModifiedWith(2, Serializable.class)//
			.hasAtMostNServiceEventModifiedWith(2, Serializable.class)//
			.hasExactlyNServiceEventModifiedWith(2, Serializable.class)//
			.hasExactlyOneServiceEventRegisteredWith(Serializable.class)//
			.hasAtLeastOneServiceEventModifiedWith(Serializable.class)//
			.hasAtLeastOneServiceEventUnregisteringWith(Serializable.class)//
			.hasAtLeastOneServiceEventWith(ServiceEvent.REGISTERED, "(k=v0)")//
			.hasAtLeastOneServiceEventRegisteredWith(Serializable.class, mapOf("k", "v0"))//
			.hasAtLeastOneServiceEventModifiedWith(Serializable.class, mapOf("k", "v1"))//
			.hasAtLeastOneServiceEventUnregisteringWith(Serializable.class, mapOf("k", "v2"))//
			.hasAtLeastOneServiceEventWith(ServiceEvent.REGISTERED, Serializable.class)

			.hasNoServiceEventWith(ServiceEvent.REGISTERED, "(k=v4)");

'''

@stbischof
Copy link
Contributor Author

stbischof commented Feb 7, 2024


exampleIntegrationTest() throws Exception {
 		MonitoringAssertion.executeAndObserve(() -> {
 			ServiceRegistration<Serializable> sr = bc.registerService(Serializable.class, new Serializable() {}, 				Dictionaries.dictionaryOf("k", "v0"));
 			sr.setProperties(Dictionaries.dictionaryOf("k", "v1"));
 			sr.setProperties(Dictionaries.dictionaryOf("k", "v2"));
 			sr.unregister();
 		})
 			.untilNoMoreServiceEventWithin(100l)// main stop-condition criteria
 			.assertWithTimeoutThat(3000)// timeout to granite a stop
 			.hasNoThrowable()// not exception thrown while executed
 			.isNotTimedOut()// check that NOT timed-out
 			.hasServiceEventsInOrder(//
 				listOf(ServiceEventConditions.matches(ServiceEvent.REGISTERED, "(k=v0)"), //
 					ServiceEventConditions.typeModifiedAndObjectClass(Serializable.class), //
 					ServiceEventConditions.typeUnregisteringAndObjectClass(Serializable.class)))//
 			.hasServiceEventsInExactOrder(//
 				listOf(ServiceEventConditions.typeRegisteredWith(Serializable.class, mapOf("k", "v0")), //
 					ServiceEventConditions.typeModifiedAndObjectClass(Serializable.class), //
 					ServiceEventConditions.typeModifiedAndObjectClass(Serializable.class), //
 					ServiceEventConditions.matches(ServiceEvent.UNREGISTERING, Serializable.class, mapOf("k", "v2"))))//
 			.hasAtLeastNServiceEventModifiedWith(2, Serializable.class)//
 			.hasAtMostNServiceEventModifiedWith(2, Serializable.class)//
 			.hasExactlyNServiceEventModifiedWith(2, Serializable.class)//
 			.hasExactlyOneServiceEventRegisteredWith(Serializable.class)//
 			.hasAtLeastOneServiceEventModifiedWith(Serializable.class)//
 			.hasAtLeastOneServiceEventUnregisteringWith(Serializable.class)//
 			.hasAtLeastOneServiceEventWith(ServiceEvent.REGISTERED, "(k=v0)")//
 			.hasAtLeastOneServiceEventRegisteredWith(Serializable.class, mapOf("k", "v0"))//
 			.hasAtLeastOneServiceEventModifiedWith(Serializable.class, mapOf("k", "v1"))//
 			.hasAtLeastOneServiceEventUnregisteringWith(Serializable.class, mapOf("k", "v2"))//
 			.hasAtLeastOneServiceEventWith(ServiceEvent.REGISTERED, Serializable.class)
 			.hasNoServiceEventWith(ServiceEvent.REGISTERED, "(k=v4)"); 

This was First though. Wen hooking in fw or Service Events aus waif for something

@stbischof stbischof marked this pull request as draft February 7, 2024 17:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants