ActivityBeansCache { public void addNewEditorActivity(final SyncBeanDef<Activity> activityBean, String priority, String resourceTypeName) { final String id = activityBean.getName(); validateUniqueness(id); activitiesById.put(id, activityBean); this.resourceTypeManagerCache.addResourceActivity(new ActivityAndMetaInfo(iocManager, activityBean, Integer.valueOf(priority), Arrays.asList(resourceTypeName))); 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 public void addEditorActivityShouldSortResourcesByPriority() { String higherPriority = "20000"; String lowerPriority = "1"; Collection<SyncBeanDef> resourceTypeBeans = createResourceType("MODEL"); when(iocManager.lookupBeans(eq("resource"))).thenReturn(resourceTypeBeans); Collection<SyncBeanDef> resourceTypeBeans1 = createResourceType("MODEL"); when(iocManager.lookupBeans(eq("resource1"))).thenReturn(resourceTypeBeans1); Collection<SyncBeanDef> resourceTypeBeans2 = createResourceType("MODEL"); when(iocManager.lookupBeans(eq("resource2"))).thenReturn(resourceTypeBeans2); SyncBeanDef mock = mock(SyncBeanDef.class); when(mock.getName()).thenReturn("resource1"); cache.addNewEditorActivity(mock, lowerPriority, "resource"); SyncBeanDef mock1 = mock(SyncBeanDef.class); when(mock1.getName()).thenReturn("resource2"); cache.addNewEditorActivity(mock1, higherPriority, "resource1"); List<ActivityAndMetaInfo> resourceActivities = this.resourceTypeManagerCache.getResourceActivities(); assertEquals(resourceActivities.get(0).getPriority(), Integer.valueOf(higherPriority).intValue()); }