@Override public SocialActivitiesEvent toSocial(Object object) { SampleSocialUserEvent event = (SampleSocialUserEvent) object; return new SocialActivitiesEvent(); }
public static SocialActivitiesEvent getDummyLastWrittenMarker() { if (dummyLastWrittenMarker == null) { dummyLastWrittenMarker = new SocialActivitiesEvent(new SocialUser("DUMMY"), DefaultTypes.DUMMY_EVENT, new Date()); } return dummyLastWrittenMarker; }
@Before public void setUp() throws Exception { socialTimelineCachePersistence = createFakeSocialTimelineCachePersistence(); this.socialSecurityConstraintsManager = mock(SocialSecurityConstraintsManager.class); socialTimelineCachePersistence.socialSecurityConstraintsManager = socialSecurityConstraintsManager; oneEventList.add(new SocialActivitiesEvent()); }
private List<SocialActivitiesEvent> createTimeline(String name, int numEvents) { List<SocialActivitiesEvent> events = new ArrayList<SocialActivitiesEvent>(); for (int i = 0; i < numEvents; i++) { events.add(new SocialActivitiesEvent(new SocialUser(name), DefaultTypes.DUMMY_EVENT, new Date()).withAdicionalInfo(i + "")); } return events; }
private List<SocialActivitiesEvent> createTimeline(String name, int numEvents) { List<SocialActivitiesEvent> events = new ArrayList<SocialActivitiesEvent>(); for (int i = 0; i < numEvents; i++) { events.add(new SocialActivitiesEvent(new SocialUser(name), DefaultTypes.DUMMY_EVENT, new Date()).withAdicionalInfo(i + "")); } return events; }
@Override public SocialActivitiesEvent toSocial(Object object) { RepositoryChangeEvent event = (RepositoryChangeEvent) object; return new SocialActivitiesEvent( socialUserRepository.systemUser(), AssetManagementEventTypes.REPOSITORY_CHANGE.name(), new Date(event.getTimestamp()) ) .withLink(event.getRepositoryAlias() != null ? event.getRepositoryAlias() : "<unknown>", event.getRootURI() != null ? event.getRootURI() : "<unknown>") .withAdicionalInfo(""); }
@Override public SocialActivitiesEvent toSocial(Object object) { RepositoryChangeEvent event = (RepositoryChangeEvent) object; return new SocialActivitiesEvent( socialUserRepository.systemUser(), AssetManagementEventTypes.REPOSITORY_CHANGE.name(), new Date(event.getTimestamp()) ) .withLink(event.getRepositoryAlias() != null ? event.getRepositoryAlias() : "<unknown>", event.getRootURI() != null ? event.getRootURI() : "<unknown>") .withAdicionalInfo(""); }
@Test public void hasRestrictionsThrowsAnExceptionTest() throws Exception { final SocialActivitiesEvent vfsEvent = spy(new SocialActivitiesEvent(socialUser, "type", new Date())); when(vfsEvent.isVFSLink()).thenThrow(RuntimeException.class); socialEventModuleConstraint.init(); assertTrue(socialEventModuleConstraint.hasRestrictions(vfsEvent)); }
@Override public SocialActivitiesEvent toSocial( Object object ) { NewRepositoryEvent event = (NewRepositoryEvent) object; SocialUser socialUser = null; try { socialUser = socialUserRepositoryAPI.findSocialUser( loggedUser.getIdentifier() ); } catch(ContextNotActiveException e) { //clean repository socialUser = new SocialUser( "system" ); } String additionalInfo = "Created"; return new SocialActivitiesEvent( socialUser, ExtendedTypes.NEW_REPOSITORY_EVENT, new Date() ).withAdicionalInfo( additionalInfo ).withLink( event.getNewRepository().getAlias(), event.getNewRepository().getUri() ).withDescription( "" ); }
@Override public SocialActivitiesEvent toSocial(Object object) { CommentAddedEvent event = (CommentAddedEvent) object; SocialUser socialUser = socialUserRepositoryAPI.findSocialUser(event.getUserName()); String additionalInfo = "commented"; return new SocialActivitiesEvent( socialUser, DiscussionEventTypes.COMMENT_ADDED.name(), new Date(event.getTimestamp()) ).withLink( event.getPath().getFileName(), event.getPath().toURI() ) .withAdicionalInfo(additionalInfo); }
@Test public void hasNoRestrictionsForOtherSocialEventsTest() throws Exception { final WorkspaceProject project = mock(WorkspaceProject.class); eventProject = project; final SocialActivitiesEvent customEventOtherType = new SocialActivitiesEvent(socialUser, "type", new Date()).withLink("link", "link", SocialActivitiesEvent.LINK_TYPE.CUSTOM); assertFalse(socialEventModuleConstraint.hasRestrictions(customEventOtherType)); }
private void createFreshCacheEventsEvents(int numberOfEvents) { for (int i = 0; i < numberOfEvents; i++) { socialTimelinePersistenceFake.persist(socialUser, new SocialActivitiesEvent(new SocialUser("fresh"), DefaultTypes.DUMMY_EVENT, new Date()).withAdicionalInfo(i + "")); } } }
private void createFreshCacheEventsEvents(int numberOfEvents) { for (int i = 0; i < numberOfEvents; i++) { socialTimelinePersistenceFake.persist(new SocialActivitiesEvent(new SocialUser("fresh"), DefaultTypes.DUMMY_EVENT, new Date()).withAdicionalInfo(i + "")); } } }
@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"); socialEventModuleConstraint.init(); assertFalse(socialEventModuleConstraint.hasRestrictions(restrictedEvent)); }
@Test public void hasRestrictionsBecauseThrowsAnExceptionTest() throws Exception { returnRepo = repository; SocialEventRepositoryConstraint socialEventRepositoryConstraintSpy = spy(this.socialEventRepositoryConstraint); final SocialActivitiesEvent vfsEvent = new SocialActivitiesEvent(socialUser, "type", new Date()); socialEventRepositoryConstraintSpy.init(); assertFalse(socialEventRepositoryConstraintSpy.hasRestrictions(vfsEvent)); when(socialEventRepositoryConstraintSpy.getEventRepository(vfsEvent)).thenThrow(RuntimeException.class); assertTrue(socialEventRepositoryConstraintSpy.hasRestrictions(vfsEvent)); }
@Test public void isAllowedShouldReturnFalseWhenASecurityConstraintThrowsException(){ socialSecurityConstraintsManager = new SocialSecurityConstraintsManager(){ @Override Instance<SocialSecurityConstraint> getSocialSecurityConstraints() { throw new RuntimeException(); } }; assertFalse(socialSecurityConstraintsManager.isAllowed(new SocialActivitiesEvent())); }
@Test public void isAllowedShouldReturnFalseWhenASecurityConstraintThrowsException(){ socialSecurityConstraintsManager = new SocialSecurityConstraintsManager(){ @Override Instance<SocialSecurityConstraint> getSocialSecurityConstraints() { throw new RuntimeException(); } }; assertFalse(socialSecurityConstraintsManager.isAllowed(new SocialActivitiesEvent())); }
@Override public SocialActivitiesEvent toSocial( Object object ) { ResourceAddedEvent event = (ResourceAddedEvent) object; SocialUser socialUser = socialUserRepositoryAPI.findSocialUser( event.getSessionInfo().getIdentity().getIdentifier() ); String additionalInfo = "Added"; String description = getCommitDescription( event ); return new SocialActivitiesEvent( socialUser, HomePageTypes.RESOURCE_ADDED_EVENT.name(), new Date() ).withLink( event.getPath().getFileName(), event.getPath().toURI() ).withAdicionalInfo( additionalInfo ).withDescription( description ); }
@Override public SocialActivitiesEvent toSocial( Object object ) { ResourceUpdatedEvent event = (ResourceUpdatedEvent) object; SocialUser socialUser = socialUserRepositoryAPI.findSocialUser( event.getSessionInfo().getIdentity().getIdentifier() ); String additionalInfo = "Edited"; String description = getCommitDescription( event ); return new SocialActivitiesEvent( socialUser, HomePageTypes.RESOURCE_UPDATE_EVENT.name(), new Date() ).withLink( event.getPath().getFileName(), event.getPath().toURI() ).withAdicionalInfo( additionalInfo ).withDescription( description ); }
@Override public SocialActivitiesEvent toSocial(final Object object) { return new SocialActivitiesEvent(new SocialUser("user"), socialEventType().name(), new Date() ).withDescription("test adaptor").withAdicionalInfo("info"); }