DcClusterServiceImpl extends AbstractConsoleService<DcClusterTblDao> implements DcClusterService { @Override public DcClusterTbl addDcCluster(String dcName, String clusterName) { DcTbl dcInfo = dcService.find(dcName); ClusterTbl clusterInfo = clusterService.find(clusterName); if(null == dcInfo || null == clusterInfo) throw new BadRequestException("Cannot add dc-cluster to an unknown dc or cluster"); DcClusterTbl proto = new DcClusterTbl(); proto.setDcId(dcInfo.getId()); proto.setClusterId(clusterInfo.getId()); proto.setDcClusterPhase(1); try { dao.insert(proto); } catch (DalException e) { throw new ServerException("Cannot create dc-cluster."); } return find(dcName, clusterName); }  @Override DcClusterTbl find(final long dcId, final long clusterId); @Override DcClusterTbl find(final String dcName, final String clusterName); @Override DcClusterTbl addDcCluster(String dcName, String clusterName); @Override List<DcClusterTbl> findAllDcClusters(); @Override List<DcClusterTbl> findByClusterIds(final List<Long> clusterIds); @Override List<DcClusterTbl> findAllByDcId(final long dcId); @Override List<DcClusterTbl> findClusterRelated(long clusterId);  }
@Test public void testAddDcCluster() { dcClusterService.addDcCluster("fra", "cluster101"); DcClusterTbl dcClusterTbl = dcClusterService.find("fra", "cluster101"); Assert.assertNotNull(dcClusterTbl); Assert.assertEquals(101L, dcClusterTbl.getClusterId()); }