Skip to content

Conversation

@stbischof
Copy link
Contributor

@timothyjward any thoughts on that?

Signed-off-by: Stefan Bischof <[email protected]>
Signed-off-by: Stefan Bischof <[email protected]>
@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
@github-actions
Copy link

This pull request has been automatically marked as stale because it has not had recent activity. Given the limited bandwidth of the team, it will be closed if no further activity occurs. If you intend to work on this pull request, please reopen the PR. Thank you for your contributions.

@github-actions github-actions bot added the stale label Mar 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants