@Test public void hasDescriptorTest() throws Exception { DocumentReference user = new DocumentReference("xwiki", "XWiki", "UserA"); when(wikiDescriptorManager.getMainWikiId()).thenReturn("xwiki"); ExecutionContext executionContext = new ExecutionContext(); when(execution.getContext()).thenReturn(executionContext); RecordableEventDescriptor descriptor1 = mock(RecordableEventDescriptor.class); RecordableEventDescriptor descriptor2 = mock(RecordableEventDescriptor.class); when(descriptor1.getEventType()).thenReturn("eventType1"); when(descriptor2.getEventType()).thenReturn("eventType2"); when(recordableEventDescriptorManager.getRecordableEventDescriptors(true)).thenReturn( Arrays.asList(descriptor1, descriptor2)); assertTrue(mocker.getComponentUnderTest().hasDescriptor("eventType1", user)); assertFalse(mocker.getComponentUnderTest().hasDescriptor("eventType3", user)); List<RecordableEventDescriptor> descriptorList = (List<RecordableEventDescriptor>) executionContext .getProperty("RecordableEventDescriptorHelperCache_xwiki:XWiki.UserA"); assertNotNull(descriptorList); assertTrue(descriptorList.contains(descriptor1)); assertTrue(descriptorList.contains(descriptor2)); assertEquals(2, descriptorList.size()); }
public boolean hasDescriptor(String eventType, DocumentReference user) throws EventStreamException { return getRecordableEventDescriptor(user).stream() .anyMatch(descriptor -> StringUtils.equals(eventType, descriptor.getEventType())); }
RecordableEventDescriptorHelper { public boolean hasDescriptor(String eventType, DocumentReference user) throws EventStreamException { return getRecordableEventDescriptor(user).stream() .anyMatch(descriptor -> StringUtils.equals(eventType, descriptor.getEventType())); } }
RecordableEventDescriptorHelper { public boolean hasDescriptor(String eventType, DocumentReference user) throws EventStreamException { return getRecordableEventDescriptor(user).stream() .anyMatch(descriptor -> StringUtils.equals(eventType, descriptor.getEventType())); }  }
RecordableEventDescriptorHelper { public boolean hasDescriptor(String eventType, DocumentReference user) throws EventStreamException { return getRecordableEventDescriptor(user).stream() .anyMatch(descriptor -> StringUtils.equals(eventType, descriptor.getEventType())); }  boolean hasDescriptor(String eventType, DocumentReference user); }
RecordableEventDescriptorHelper { public boolean hasDescriptor(String eventType, DocumentReference user) throws EventStreamException { return getRecordableEventDescriptor(user).stream() .anyMatch(descriptor -> StringUtils.equals(eventType, descriptor.getEventType())); }  boolean hasDescriptor(String eventType, DocumentReference user);  }