@Test public void testLiveActivityEdit() { String liveActivityId = "liveActivity"; LiveActivity liveActivity = Mockito.mock(LiveActivity.class); Mockito.when(activityRepository.getLiveActivityByTypedId(liveActivityId)).thenReturn(liveActivity); String activityId = "activity"; Activity activity = Mockito.mock(Activity.class); Mockito.when(activityRepository.getActivityById(activityId)).thenReturn(activity); String spaceControllerId = "spaceController"; SpaceController spaceController = Mockito.mock(SpaceController.class); Mockito.when(spaceControllerRepository.getSpaceControllerById(spaceControllerId)).thenReturn(spaceController); Map<String, Object> args = new HashMap<>(); args.put(MasterApiMessages.MASTER_API_PARAMETER_NAME_ENTITY_ID, liveActivityId); String name = "name"; args.put(MasterApiMessages.MASTER_API_PARAMETER_NAME_ENTITY_NAME, name); String description = "description"; args.put(MasterApiMessages.MASTER_API_PARAMETER_NAME_ENTITY_DESCRIPTION, description); args.put(MasterApiMessages.MASTER_API_PARAMETER_NAME_ACTIVITY_ID, activityId); args.put(MasterApiMessages.MASTER_API_PARAMETER_NAME_SPACE_CONTROLLER_ID, spaceControllerId); masterApiActivityManager.editLiveActivity(args); Mockito.verify(liveActivity).setName(name); Mockito.verify(liveActivity).setDescription(description); Mockito.verify(liveActivity).setActivity(activity); Mockito.verify(liveActivity).setController(spaceController); Mockito.verify(activityRepository).saveLiveActivity(liveActivity); }
@Override public Map<String, Object> editLiveActivity(Map<String, Object> args) { String liveActivityId = (String) args.get(MasterApiMessages.MASTER_API_PARAMETER_NAME_ENTITY_ID); LiveActivity liveActivity = activityRepository.getLiveActivityByTypedId(liveActivityId); if (liveActivity == null) { return getNoSuchLiveActivityResponse(liveActivityId); } boolean edited = false; String name = (String) args.get(MasterApiMessages.MASTER_API_PARAMETER_NAME_ENTITY_NAME); if (name != null) { liveActivity.setName(name); edited |= true; } String description = (String) args.get(MasterApiMessages.MASTER_API_PARAMETER_NAME_ENTITY_DESCRIPTION); if (description != null) { liveActivity.setDescription(description); edited |= true; } String activityId = (String) args.get(MasterApiMessages.MASTER_API_PARAMETER_NAME_ACTIVITY_ID); if (activityId != null) { Activity newActivity = activityRepository.getActivityById(activityId); if (newActivity == null) { return getNoSuchActivityResponse(activityId); } liveActivity.setActivity(newActivity); edited |= true; } String spaceControllerId = (String) args.get(MasterApiMessages.MASTER_API_PARAMETER_NAME_SPACE_CONTROLLER_ID); if (spaceControllerId != null) { SpaceController spaceController = spaceControllerRepository.getSpaceControllerById(spaceControllerId); if (spaceController == null) { return getNoSuchSpaceControllerResponse(spaceControllerId); } liveActivity.setController(spaceController); edited |= true; } if (edited) { activityRepository.saveLiveActivity(liveActivity); } return MasterApiMessageSupport.getSimpleSuccessResponse(); }
StandardMasterApiActivityManager extends BaseMasterApiManager implements InternalMasterApiActivityManager { @Override public Map<String, Object> editLiveActivity(Map<String, Object> args) { String liveActivityId = (String) args.get(MasterApiMessages.MASTER_API_PARAMETER_NAME_ENTITY_ID); LiveActivity liveActivity = activityRepository.getLiveActivityByTypedId(liveActivityId); if (liveActivity == null) { return getNoSuchLiveActivityResponse(liveActivityId); } boolean edited = false; String name = (String) args.get(MasterApiMessages.MASTER_API_PARAMETER_NAME_ENTITY_NAME); if (name != null) { liveActivity.setName(name); edited |= true; } String description = (String) args.get(MasterApiMessages.MASTER_API_PARAMETER_NAME_ENTITY_DESCRIPTION); if (description != null) { liveActivity.setDescription(description); edited |= true; } String activityId = (String) args.get(MasterApiMessages.MASTER_API_PARAMETER_NAME_ACTIVITY_ID); if (activityId != null) { Activity newActivity = activityRepository.getActivityById(activityId); if (newActivity == null) { return getNoSuchActivityResponse(activityId); } liveActivity.setActivity(newActivity); edited |= true; } String spaceControllerId = (String) args.get(MasterApiMessages.MASTER_API_PARAMETER_NAME_SPACE_CONTROLLER_ID); if (spaceControllerId != null) { SpaceController spaceController = spaceControllerRepository.getSpaceControllerById(spaceControllerId); if (spaceController == null) { return getNoSuchSpaceControllerResponse(spaceControllerId); } liveActivity.setController(spaceController); edited |= true; } if (edited) { activityRepository.saveLiveActivity(liveActivity); } return MasterApiMessageSupport.getSimpleSuccessResponse(); } }
StandardMasterApiActivityManager extends BaseMasterApiManager implements InternalMasterApiActivityManager { @Override public Map<String, Object> editLiveActivity(Map<String, Object> args) { String liveActivityId = (String) args.get(MasterApiMessages.MASTER_API_PARAMETER_NAME_ENTITY_ID); LiveActivity liveActivity = activityRepository.getLiveActivityByTypedId(liveActivityId); if (liveActivity == null) { return getNoSuchLiveActivityResponse(liveActivityId); } boolean edited = false; String name = (String) args.get(MasterApiMessages.MASTER_API_PARAMETER_NAME_ENTITY_NAME); if (name != null) { liveActivity.setName(name); edited |= true; } String description = (String) args.get(MasterApiMessages.MASTER_API_PARAMETER_NAME_ENTITY_DESCRIPTION); if (description != null) { liveActivity.setDescription(description); edited |= true; } String activityId = (String) args.get(MasterApiMessages.MASTER_API_PARAMETER_NAME_ACTIVITY_ID); if (activityId != null) { Activity newActivity = activityRepository.getActivityById(activityId); if (newActivity == null) { return getNoSuchActivityResponse(activityId); } liveActivity.setActivity(newActivity); edited |= true; } String spaceControllerId = (String) args.get(MasterApiMessages.MASTER_API_PARAMETER_NAME_SPACE_CONTROLLER_ID); if (spaceControllerId != null) { SpaceController spaceController = spaceControllerRepository.getSpaceControllerById(spaceControllerId); if (spaceController == null) { return getNoSuchSpaceControllerResponse(spaceControllerId); } liveActivity.setController(spaceController); edited |= true; } if (edited) { activityRepository.saveLiveActivity(liveActivity); } return MasterApiMessageSupport.getSimpleSuccessResponse(); }  }
StandardMasterApiActivityManager extends BaseMasterApiManager implements InternalMasterApiActivityManager { @Override public Map<String, Object> editLiveActivity(Map<String, Object> args) { String liveActivityId = (String) args.get(MasterApiMessages.MASTER_API_PARAMETER_NAME_ENTITY_ID); LiveActivity liveActivity = activityRepository.getLiveActivityByTypedId(liveActivityId); if (liveActivity == null) { return getNoSuchLiveActivityResponse(liveActivityId); } boolean edited = false; String name = (String) args.get(MasterApiMessages.MASTER_API_PARAMETER_NAME_ENTITY_NAME); if (name != null) { liveActivity.setName(name); edited |= true; } String description = (String) args.get(MasterApiMessages.MASTER_API_PARAMETER_NAME_ENTITY_DESCRIPTION); if (description != null) { liveActivity.setDescription(description); edited |= true; } String activityId = (String) args.get(MasterApiMessages.MASTER_API_PARAMETER_NAME_ACTIVITY_ID); if (activityId != null) { Activity newActivity = activityRepository.getActivityById(activityId); if (newActivity == null) { return getNoSuchActivityResponse(activityId); } liveActivity.setActivity(newActivity); edited |= true; } String spaceControllerId = (String) args.get(MasterApiMessages.MASTER_API_PARAMETER_NAME_SPACE_CONTROLLER_ID); if (spaceControllerId != null) { SpaceController spaceController = spaceControllerRepository.getSpaceControllerById(spaceControllerId); if (spaceController == null) { return getNoSuchSpaceControllerResponse(spaceControllerId); } liveActivity.setController(spaceController); edited |= true; } if (edited) { activityRepository.saveLiveActivity(liveActivity); } return MasterApiMessageSupport.getSimpleSuccessResponse(); }  @Override void startup(); @Override void shutdown(); @Override Map<String, Object> saveActivity(SimpleActivity activityData, InputStream activityContentStream); @Override Map<String, Object> getActivitiesByFilter(String filter); @Override Map<String, Object> getActivityView(String id); @Override Map<String, Object> getActivityFullView(String id); @Override Map<String, Object> deleteActivity(String id); @Override Map<String, Object> updateActivityMetadata(String id, Object metadataCommandObj); @Override Map<String, Object> getLiveActivitiesByFilter(String filter); @Override Map<String, Object> getLiveActivityView(String id); @Override Map<String, Object> getLiveActivityFullView(String id); @Override boolean canCreateLiveActivities(); @Override Map<String, Object> deleteLiveActivity(String id); @Override Map<String, Object> createLiveActivity(Map<String, Object> args); @Override Map<String, Object> getLiveActivityConfiguration(String id); @Override Map<String, Object> configureLiveActivity(String id, Map<String, String> map); @Override Map<String, Object> editLiveActivity(Map<String, Object> args); @Override Map<String, Object> updateLiveActivityMetadata(String id, Object metadataCommandObj); @Override Map<String, Object> deleteLiveActivityGroup(String id); @Override Map<String, Object> getBasicSpaceControllerApiData(SpaceController controller); @Override Map<String, Object> getSpaceControllerConfiguration(String id); @Override Map<String, Object> configureSpaceController(String id, Map<String, String> map); @Override void getLiveActivityStatusApiData(LiveActivity liveActivity, Map<String, Object> data); @Override Map<String, Object> getLiveActivityGroupView(String id); @Override Map<String, Object> getLiveActivityGroupFullView(String id); @Override Map<String, Object> getLiveActivityGroupsByFilter(String filter); @Override List<Map<String, Object>> getAllUiLiveActivitiesByController(SpaceController controller); @Override Map<String, Object> getSpacesByFilter(String filter); @Override Map<String, Object> deleteSpace(String id); @Override Map<String, Object> updateSpaceMetadata(String id, Object metadataCommandObj); @Override Map<String, Object> getSpaceView(String id); @Override Map<String, Object> getSpaceFullView(String id); @Override Map<String, Object> getSpaceLiveActivityGroupView(String id); @Override Map<String, Object> updateLiveActivityGroupMetadata(String id, Object metadataCommandObj); void setMasterEventManager(MasterEventManager masterEventManager); void setActivityRepository(ActivityRepository activityRepository); void setSpaceControllerRepository(SpaceControllerRepository spaceControllerRepository); void setActivityRepositoryManager(ActivityRepositoryManager activityRepositoryManager); void setActiveSpaceControllerManager(ActiveSpaceControllerManager activeSpaceControllerManager); }
StandardMasterApiActivityManager extends BaseMasterApiManager implements InternalMasterApiActivityManager { @Override public Map<String, Object> editLiveActivity(Map<String, Object> args) { String liveActivityId = (String) args.get(MasterApiMessages.MASTER_API_PARAMETER_NAME_ENTITY_ID); LiveActivity liveActivity = activityRepository.getLiveActivityByTypedId(liveActivityId); if (liveActivity == null) { return getNoSuchLiveActivityResponse(liveActivityId); } boolean edited = false; String name = (String) args.get(MasterApiMessages.MASTER_API_PARAMETER_NAME_ENTITY_NAME); if (name != null) { liveActivity.setName(name); edited |= true; } String description = (String) args.get(MasterApiMessages.MASTER_API_PARAMETER_NAME_ENTITY_DESCRIPTION); if (description != null) { liveActivity.setDescription(description); edited |= true; } String activityId = (String) args.get(MasterApiMessages.MASTER_API_PARAMETER_NAME_ACTIVITY_ID); if (activityId != null) { Activity newActivity = activityRepository.getActivityById(activityId); if (newActivity == null) { return getNoSuchActivityResponse(activityId); } liveActivity.setActivity(newActivity); edited |= true; } String spaceControllerId = (String) args.get(MasterApiMessages.MASTER_API_PARAMETER_NAME_SPACE_CONTROLLER_ID); if (spaceControllerId != null) { SpaceController spaceController = spaceControllerRepository.getSpaceControllerById(spaceControllerId); if (spaceController == null) { return getNoSuchSpaceControllerResponse(spaceControllerId); } liveActivity.setController(spaceController); edited |= true; } if (edited) { activityRepository.saveLiveActivity(liveActivity); } return MasterApiMessageSupport.getSimpleSuccessResponse(); }  @Override void startup(); @Override void shutdown(); @Override Map<String, Object> saveActivity(SimpleActivity activityData, InputStream activityContentStream); @Override Map<String, Object> getActivitiesByFilter(String filter); @Override Map<String, Object> getActivityView(String id); @Override Map<String, Object> getActivityFullView(String id); @Override Map<String, Object> deleteActivity(String id); @Override Map<String, Object> updateActivityMetadata(String id, Object metadataCommandObj); @Override Map<String, Object> getLiveActivitiesByFilter(String filter); @Override Map<String, Object> getLiveActivityView(String id); @Override Map<String, Object> getLiveActivityFullView(String id); @Override boolean canCreateLiveActivities(); @Override Map<String, Object> deleteLiveActivity(String id); @Override Map<String, Object> createLiveActivity(Map<String, Object> args); @Override Map<String, Object> getLiveActivityConfiguration(String id); @Override Map<String, Object> configureLiveActivity(String id, Map<String, String> map); @Override Map<String, Object> editLiveActivity(Map<String, Object> args); @Override Map<String, Object> updateLiveActivityMetadata(String id, Object metadataCommandObj); @Override Map<String, Object> deleteLiveActivityGroup(String id); @Override Map<String, Object> getBasicSpaceControllerApiData(SpaceController controller); @Override Map<String, Object> getSpaceControllerConfiguration(String id); @Override Map<String, Object> configureSpaceController(String id, Map<String, String> map); @Override void getLiveActivityStatusApiData(LiveActivity liveActivity, Map<String, Object> data); @Override Map<String, Object> getLiveActivityGroupView(String id); @Override Map<String, Object> getLiveActivityGroupFullView(String id); @Override Map<String, Object> getLiveActivityGroupsByFilter(String filter); @Override List<Map<String, Object>> getAllUiLiveActivitiesByController(SpaceController controller); @Override Map<String, Object> getSpacesByFilter(String filter); @Override Map<String, Object> deleteSpace(String id); @Override Map<String, Object> updateSpaceMetadata(String id, Object metadataCommandObj); @Override Map<String, Object> getSpaceView(String id); @Override Map<String, Object> getSpaceFullView(String id); @Override Map<String, Object> getSpaceLiveActivityGroupView(String id); @Override Map<String, Object> updateLiveActivityGroupMetadata(String id, Object metadataCommandObj); void setMasterEventManager(MasterEventManager masterEventManager); void setActivityRepository(ActivityRepository activityRepository); void setSpaceControllerRepository(SpaceControllerRepository spaceControllerRepository); void setActivityRepositoryManager(ActivityRepositoryManager activityRepositoryManager); void setActiveSpaceControllerManager(ActiveSpaceControllerManager activeSpaceControllerManager);  }