@Test public void testOperateGroupOperation() { GroupModel group = newGroup(); OperationContext operationContext = newOperationContext(); businessDao.operationGroupOperation(operationContext, group, false); GroupModel newGroup = query(group, 1); List<GroupOperationModel> operationModels = groupOperationDao.query("group_id=?", Lists.newArrayList(Long.toString(newGroup.getId()))); Assert.assertEquals(1, operationModels.size()); Assert.assertEquals(operationContext.getOperation(), operationModels.get(0).getOperation()); List<GroupOperationLog> logs = groupOperationLogDao .select(new GroupOperationLogModel(newGroup.getId(), operationContext.getOperation(), operationContext.getOperatorId()), false); Assert.assertEquals(1, logs.size()); Assert.assertEquals(operationContext.getOperation(), logs.get(0).getOperation()); Assert.assertEquals(operationContext.getToken(), logs.get(0).getToken()); businessDao.operationGroupOperation(operationContext, group, true); operationModels = groupOperationDao.query("group_id=?", Lists.newArrayList(Long.toString(newGroup.getId()))); Assert.assertEquals(0, operationModels.size()); logs = groupOperationLogDao.select(new GroupOperationLogModel(newGroup.getId(), operationContext.getOperation(), operationContext.getOperatorId()), true); Assert.assertEquals(1, logs.size()); Assert.assertEquals(operationContext.getOperation(), logs.get(0).getOperation()); Assert.assertEquals(operationContext.getToken(), logs.get(0).getToken()); }
@Transactional public void operationGroupOperation(OperationContext operationContext, GroupModel group, boolean isOperationComplete) { checkOperationContextArgument(operationContext); List<GroupOperationModel> groupOperation = Lists .newArrayList(new GroupOperationModel(groupDao.generateGroup(group).getId(), operationContext.getOperation())); if (isOperationComplete) { deleteGroupOperation(operationContext, groupOperation); } else { insertOrUpdateGroupOperation(operationContext, groupOperation); } }
BusinessDao { @Transactional public void operationGroupOperation(OperationContext operationContext, GroupModel group, boolean isOperationComplete) { checkOperationContextArgument(operationContext); List<GroupOperationModel> groupOperation = Lists .newArrayList(new GroupOperationModel(groupDao.generateGroup(group).getId(), operationContext.getOperation())); if (isOperationComplete) { deleteGroupOperation(operationContext, groupOperation); } else { insertOrUpdateGroupOperation(operationContext, groupOperation); } } }
BusinessDao { @Transactional public void operationGroupOperation(OperationContext operationContext, GroupModel group, boolean isOperationComplete) { checkOperationContextArgument(operationContext); List<GroupOperationModel> groupOperation = Lists .newArrayList(new GroupOperationModel(groupDao.generateGroup(group).getId(), operationContext.getOperation())); if (isOperationComplete) { deleteGroupOperation(operationContext, groupOperation); } else { insertOrUpdateGroupOperation(operationContext, groupOperation); } }  }
BusinessDao { @Transactional public void operationGroupOperation(OperationContext operationContext, GroupModel group, boolean isOperationComplete) { checkOperationContextArgument(operationContext); List<GroupOperationModel> groupOperation = Lists .newArrayList(new GroupOperationModel(groupDao.generateGroup(group).getId(), operationContext.getOperation())); if (isOperationComplete) { deleteGroupOperation(operationContext, groupOperation); } else { insertOrUpdateGroupOperation(operationContext, groupOperation); } }  @Transactional void createServiceRouteRules(OperationContext operationContext, final String serviceId, List<RouteRuleInfo> routeRuleInfos); @Transactional void activateServiceRouteRules(OperationContext operationContext, final String serviceId, List<RouteRuleInfo> routeRuleInfos); @Transactional void operationGroupOperation(OperationContext operationContext, GroupModel group, boolean isOperationComplete); RouteRuleModel generateRouteRule(RouteRuleModel routeRuleModel); GroupModel generateGroup(GroupModel groupModel); @Transactional void updateGroupInstance(OperationContext operationContext, Long groupId, Set<String> instanceIds); void deleteGroupOperation(OperationContext operationContext, List<GroupOperationModel> groupOperations); void insertOrUpdateGroupOperation(OperationContext operationContext, List<GroupOperationModel> groupOperations); void deleteGroups(OperationContext operationContext, List<Long> groupIds); void insertOrUpdateGroups(OperationContext operationContext, List<GroupModel> groups); void insertGroups(OperationContext operationContext, List<GroupModel> groups); void deleteRouteRules(OperationContext operationContext, List<Long> routeRuleIds); void insertOrUpdateRouteRules(OperationContext operationContext, List<RouteRuleModel> routeRules); void insertRouteRules(OperationContext operationContext, List<RouteRuleModel> routeRules); void deleteRouteRuleGroups(OperationContext operationContext, List<Long> ids); void insertOrUpdateRouteRuleGroups(OperationContext operationContext, List<RouteRuleGroupModel> routeRuleGroups); void releaseRouteRuleGroups(OperationContext operationContext, List<RouteRuleGroupModel> routeRuleGroups); void publishRouteRuleGroups(OperationContext operationContext, List<RouteRuleGroupModel> routeRuleGroups); void deleteGroupInstances(OperationContext operationContext, List<Long> groupInstanceIds); void deleteGroupInstancesByFilter(OperationContext operationContext, List<GroupInstanceModel> groupInstances); void insertGroupInstances(OperationContext operationContext, List<GroupInstanceModel> groupInstanceModels); void deleteServiceInstances(OperationContext operationContext, List<Long> serviceInstanceIds); void deleteServiceInstancesByFilter(OperationContext operationContext, List<ServiceInstanceModel> serviceInstances); void insertServiceInstances(OperationContext operationContext, List<ServiceInstanceModel> serviceInstanceModels); }
BusinessDao { @Transactional public void operationGroupOperation(OperationContext operationContext, GroupModel group, boolean isOperationComplete) { checkOperationContextArgument(operationContext); List<GroupOperationModel> groupOperation = Lists .newArrayList(new GroupOperationModel(groupDao.generateGroup(group).getId(), operationContext.getOperation())); if (isOperationComplete) { deleteGroupOperation(operationContext, groupOperation); } else { insertOrUpdateGroupOperation(operationContext, groupOperation); } }  @Transactional void createServiceRouteRules(OperationContext operationContext, final String serviceId, List<RouteRuleInfo> routeRuleInfos); @Transactional void activateServiceRouteRules(OperationContext operationContext, final String serviceId, List<RouteRuleInfo> routeRuleInfos); @Transactional void operationGroupOperation(OperationContext operationContext, GroupModel group, boolean isOperationComplete); RouteRuleModel generateRouteRule(RouteRuleModel routeRuleModel); GroupModel generateGroup(GroupModel groupModel); @Transactional void updateGroupInstance(OperationContext operationContext, Long groupId, Set<String> instanceIds); void deleteGroupOperation(OperationContext operationContext, List<GroupOperationModel> groupOperations); void insertOrUpdateGroupOperation(OperationContext operationContext, List<GroupOperationModel> groupOperations); void deleteGroups(OperationContext operationContext, List<Long> groupIds); void insertOrUpdateGroups(OperationContext operationContext, List<GroupModel> groups); void insertGroups(OperationContext operationContext, List<GroupModel> groups); void deleteRouteRules(OperationContext operationContext, List<Long> routeRuleIds); void insertOrUpdateRouteRules(OperationContext operationContext, List<RouteRuleModel> routeRules); void insertRouteRules(OperationContext operationContext, List<RouteRuleModel> routeRules); void deleteRouteRuleGroups(OperationContext operationContext, List<Long> ids); void insertOrUpdateRouteRuleGroups(OperationContext operationContext, List<RouteRuleGroupModel> routeRuleGroups); void releaseRouteRuleGroups(OperationContext operationContext, List<RouteRuleGroupModel> routeRuleGroups); void publishRouteRuleGroups(OperationContext operationContext, List<RouteRuleGroupModel> routeRuleGroups); void deleteGroupInstances(OperationContext operationContext, List<Long> groupInstanceIds); void deleteGroupInstancesByFilter(OperationContext operationContext, List<GroupInstanceModel> groupInstances); void insertGroupInstances(OperationContext operationContext, List<GroupInstanceModel> groupInstanceModels); void deleteServiceInstances(OperationContext operationContext, List<Long> serviceInstanceIds); void deleteServiceInstancesByFilter(OperationContext operationContext, List<ServiceInstanceModel> serviceInstances); void insertServiceInstances(OperationContext operationContext, List<ServiceInstanceModel> serviceInstanceModels); static final BusinessDao INSTANCE; }