Search in sources :

Example 16 with SocialActivitiesEvent

use of org.ext.uberfire.social.activities.model.SocialActivitiesEvent in project kie-wb-common by kiegroup.

the class SocialEventModuleConstraintTest method nullModulehasNoRestrictionsTest.

@Test
public void nullModulehasNoRestrictionsTest() throws Exception {
    eventProject = null;
    final SocialActivitiesEvent vfsEvent = new SocialActivitiesEvent(socialUser, "type", new Date());
    final SocialActivitiesEvent moduleEvent = new SocialActivitiesEvent(socialUser, OrganizationalUnitEventType.NEW_ORGANIZATIONAL_UNIT, new Date()).withLink("otherName", "otherName", SocialActivitiesEvent.LINK_TYPE.CUSTOM);
    socialEventModuleConstraint.init();
    assertFalse(socialEventModuleConstraint.hasRestrictions(vfsEvent));
    assertFalse(socialEventModuleConstraint.hasRestrictions(moduleEvent));
    verify(authorizationManager, never()).authorize((Resource) null, user);
    verify(authorizationManager, never()).authorize((Permission) null, user);
}
Also used : SocialActivitiesEvent(org.ext.uberfire.social.activities.model.SocialActivitiesEvent) Date(java.util.Date) Test(org.junit.Test)

Example 17 with SocialActivitiesEvent

use of org.ext.uberfire.social.activities.model.SocialActivitiesEvent in project kie-wb-common by kiegroup.

the class SocialEventOUConstraintTest method hasRestrictionsBecauseThrowsAnExceptionTest.

@Test
public void hasRestrictionsBecauseThrowsAnExceptionTest() throws Exception {
    final SocialActivitiesEvent event = new SocialActivitiesEvent(socialUser, OrganizationalUnitEventType.NEW_ORGANIZATIONAL_UNIT, new Date()).withLink("name", "ouname", SocialActivitiesEvent.LINK_TYPE.CUSTOM);
    SocialEventOUConstraint spy = spy(socialEventOUConstraint);
    when(spy.isOUSocialEvent(event)).thenThrow(RuntimeException.class);
    spy.init();
    assertTrue(spy.hasRestrictions(event));
}
Also used : SocialActivitiesEvent(org.ext.uberfire.social.activities.model.SocialActivitiesEvent) Date(java.util.Date) Test(org.junit.Test)

Example 18 with SocialActivitiesEvent

use of org.ext.uberfire.social.activities.model.SocialActivitiesEvent in project kie-wb-common by kiegroup.

the class SocialEventOUConstraintTest method hasRestrictionsTest.

@Test
public void hasRestrictionsTest() throws Exception {
    final SocialActivitiesEvent event = new SocialActivitiesEvent(socialUser, OrganizationalUnitEventType.NEW_ORGANIZATIONAL_UNIT, new Date()).withLink("otherName", "otherName", SocialActivitiesEvent.LINK_TYPE.CUSTOM);
    socialEventOUConstraint.init();
    assertTrue(socialEventOUConstraint.hasRestrictions(event));
}
Also used : SocialActivitiesEvent(org.ext.uberfire.social.activities.model.SocialActivitiesEvent) Date(java.util.Date) Test(org.junit.Test)

Example 19 with SocialActivitiesEvent

use of org.ext.uberfire.social.activities.model.SocialActivitiesEvent in project kie-wb-common by kiegroup.

the class SocialEventRepositoryConstraintTest method hasNoRestrictionsForOtherSocialEventsTest.

@Test
public void hasNoRestrictionsForOtherSocialEventsTest() throws Exception {
    final SocialActivitiesEvent customEventOtherType = new SocialActivitiesEvent(socialUser, "type", new Date()).withLink("link", "link", SocialActivitiesEvent.LINK_TYPE.CUSTOM);
    assertFalse(socialEventRepositoryConstraint.hasRestrictions(customEventOtherType));
}
Also used : SocialActivitiesEvent(org.ext.uberfire.social.activities.model.SocialActivitiesEvent) Date(java.util.Date) Test(org.junit.Test)

Example 20 with SocialActivitiesEvent

use of org.ext.uberfire.social.activities.model.SocialActivitiesEvent in project kie-wb-common by kiegroup.

the class SocialEventRepositoryConstraintTest method ifThereIsNoLoggedUserInScopeShouldNotHaveRestrictions.

@Test
public void ifThereIsNoLoggedUserInScopeShouldNotHaveRestrictions() throws Exception {
    when(userCDIContextHelper.thereIsALoggedUserInScope()).thenReturn(false);
    final SocialActivitiesEvent restrictedEvent = new SocialActivitiesEvent(socialUser, OrganizationalUnitEventType.NEW_ORGANIZATIONAL_UNIT, new Date()).withLink("otherName", "otherName", SocialActivitiesEvent.LINK_TYPE.VFS);
    socialEventRepositoryConstraint.init();
    assertFalse(socialEventRepositoryConstraint.hasRestrictions(restrictedEvent));
}
Also used : SocialActivitiesEvent(org.ext.uberfire.social.activities.model.SocialActivitiesEvent) Date(java.util.Date) Test(org.junit.Test)

Aggregations

SocialActivitiesEvent (org.ext.uberfire.social.activities.model.SocialActivitiesEvent)24 Date (java.util.Date)20 Test (org.junit.Test)16 ArrayList (java.util.ArrayList)4 SocialUser (org.ext.uberfire.social.activities.model.SocialUser)4 WorkspaceProject (org.guvnor.common.services.project.model.WorkspaceProject)3 HashMap (java.util.HashMap)2 Repository (org.guvnor.structure.repositories.Repository)2 GitRepository (org.guvnor.structure.repositories.impl.git.GitRepository)2 KieServices (org.kie.api.KieServices)2 KieContainer (org.kie.api.runtime.KieContainer)2 KieSession (org.kie.api.runtime.KieSession)2 ContextNotActiveException (javax.enterprise.context.ContextNotActiveException)1 PagedSocialQuery (org.ext.uberfire.social.activities.model.PagedSocialQuery)1 SocialPaged (org.ext.uberfire.social.activities.model.SocialPaged)1 SocialAdapter (org.ext.uberfire.social.activities.service.SocialAdapter)1 NewRepositoryEvent (org.guvnor.structure.repositories.NewRepositoryEvent)1 AgendaFilter (org.kie.api.runtime.rule.AgendaFilter)1 Match (org.kie.api.runtime.rule.Match)1 CommentAddedEvent (org.kie.workbench.common.services.shared.discussion.CommentAddedEvent)1