ActivityBeansCache { @PostConstruct void init() { registerGwtEditorProvider(); final Collection<SyncBeanDef<Activity>> availableActivities = getAvailableActivities(); for (final SyncBeanDef<Activity> activityBean : availableActivities) { final String id = activityBean.getName(); validateUniqueness(id); activitiesById.put(id, activityBean); if (isSplashScreen(activityBean.getQualifiers())) { splashActivities.add((SplashScreenActivity) activityBean.getInstance()); } else { if (isClientEditor(activityBean.getQualifiers())) { registerGwtClientBean(id, activityBean); } final Pair<Integer, List<String>> metaInfo = generateActivityMetaInfo(activityBean); if (metaInfo != null) { addResourceActivity(activityBean, metaInfo); } } } this.resourceTypeManagerCache.sortResourceActivitiesByPriority(); } ActivityBeansCache(); @Inject  ActivityBeansCache(SyncBeanManager iocManager,
                              Event<NewPerspectiveEvent> newPerspectiveEventEvent,
                              Event<NewWorkbenchScreenEvent> newWorkbenchScreenEventEvent,
                              ResourceTypeManagerCache resourceTypeManagerCache,
                              ExperimentalActivitiesAuthorizationManager experimentalActivitiesAuthorizationManager,
                              GWTEditorNativeRegister gwtEditorNativeRegister); void removeActivity(String id); void addNewScreenActivity(final SyncBeanDef<Activity> activityBean); void addNewPerspectiveActivity(final SyncBeanDef<Activity> activityBean); void addNewEditorActivity(final SyncBeanDef<Activity> activityBean,
                                     String priority,
                                     String resourceTypeName); void addNewEditorActivity(final SyncBeanDef<Activity> syncBeanDef,
                                     final int priority,
                                     final List<String> resourceTypes); void addNewSplashScreenActivity(final SyncBeanDef<Activity> activityBean); boolean hasActivity(String id); List<SplashScreenActivity> getSplashScreens(); SyncBeanDef<Activity> getActivity(final String id); SyncBeanDef<Activity> getActivity(final Path path); List<SyncBeanDef<Activity>> getPerspectiveActivities(); List<String> getActivitiesById(); void noOp();  }
@Test(expected = RuntimeException.class) public void initShouldNotAllowTwoIdenticalsActivities() throws Exception { ActivityBeansCacheUnitTestWrapper cache = new ActivityBeansCacheUnitTestWrapper(); cache.mockSplashScreenBehaviour(); cache.duplicateActivity(); cache.init(); }
@Test public void initShouldCacheOtherActivities() throws Exception { ActivityBeansCacheUnitTestWrapper cache = new ActivityBeansCacheUnitTestWrapper(); cache.mockActivityBehaviour(); cache.init(); assertFalse(cache.getResourceTypeManagerCache().getResourceActivities().isEmpty()); }