From 8d32d0fd16b222c5c7d81b507744a1ab908facb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Ka=C5=88ka?= Date: Tue, 5 Nov 2024 14:44:35 +0100 Subject: [PATCH] [Enhancement kbss-cvut/termit-ui#530] Fix removePublishesEventAndDropsGraph test --- .../termit/persistence/dao/VocabularyDaoTest.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/test/java/cz/cvut/kbss/termit/persistence/dao/VocabularyDaoTest.java b/src/test/java/cz/cvut/kbss/termit/persistence/dao/VocabularyDaoTest.java index 23b72777c..02af22e4c 100644 --- a/src/test/java/cz/cvut/kbss/termit/persistence/dao/VocabularyDaoTest.java +++ b/src/test/java/cz/cvut/kbss/termit/persistence/dao/VocabularyDaoTest.java @@ -30,6 +30,7 @@ import cz.cvut.kbss.termit.event.AssetPersistEvent; import cz.cvut.kbss.termit.event.AssetUpdateEvent; import cz.cvut.kbss.termit.event.RefreshLastModifiedEvent; +import cz.cvut.kbss.termit.event.VocabularyEvent; import cz.cvut.kbss.termit.event.VocabularyWillBeRemovedEvent; import cz.cvut.kbss.termit.model.Glossary; import cz.cvut.kbss.termit.model.Model; @@ -761,10 +762,14 @@ void removePublishesEventAndDropsGraph() { transactional(() -> sut.remove(vocabulary)); - ArgumentCaptor eventCaptor = ArgumentCaptor.forClass(VocabularyWillBeRemovedEvent.class); - verify(eventPublisher).publishEvent(eventCaptor.capture()); + ArgumentCaptor eventCaptor = ArgumentCaptor.forClass(VocabularyWillBeRemovedEvent.class); + verify(eventPublisher, atLeastOnce()).publishEvent(eventCaptor.capture()); - VocabularyWillBeRemovedEvent event = eventCaptor.getValue(); + VocabularyWillBeRemovedEvent event = (VocabularyWillBeRemovedEvent) eventCaptor + .getAllValues().stream() + .filter(e -> e instanceof VocabularyWillBeRemovedEvent) + .findAny().orElseThrow(); + assertNotNull(event); assertEquals(event.getVocabularyIri(), vocabulary.getUri());