/*
 * Copyright 2016-2018 shardingsphere.io.
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * </p>
 */

package io.shardingsphere.orchestration.internal.state.service;

import io.shardingsphere.orchestration.reg.api.RegistryCenter;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;

import static org.mockito.Mockito.verify;
@RunWith(MockitoJUnitRunner.class)
public class DataSourceServiceTest {
    
    @Mock
    private RegistryCenter regCenter;
    
    private DataSourceService dataSourceService;
    
    @Before
    public void setUp() {
        dataSourceService = new DataSourceService("test", regCenter);
    }
    
    @Test
    public void assertPersistDataSourcesNode() {
        dataSourceService.persistDataSourcesNode();
        verify(regCenter).persist("/test/datasources", "");
    }
    
    @Test
    public void testGetAvailableDataSourceConfigurations() {
    }
    
    @Test
    public void testGetAvailableShardingRuleConfiguration() {
    }
    
    @Test
    public void testGetAvailableMasterSlaveRuleConfiguration() {
    }
    
    @Test
    public void testGetDisabledSlaveDataSourceNames() {
    }
}
    
@@ -935,16 +935,57 @@
 verify;%0A
+import static org.mockito.Mockito.when;%0A%0A
 @RunWith
@@ -1049,24 +1049,801 @@
 Test %7B%0A    %0A
+    private static final String DATA_SOURCE_YAML =%0A            %22ds_0: !!io.shardingsphere.core.config.DataSourceConfiguration%5Cn%22%0A                    + %22  dataSourceClassName: org.apache.commons.dbcp2.BasicDataSource%5Cn%22 + %22  properties:%5Cn%22%0A                    + %22    driverClassName: com.mysql.jdbc.Driver%5Cn%22 + %22    url: jdbc:mysql://localhost:3306/ds_0%5Cn%22 + %22    username: root%5Cn%22 + %22    password: root%5Cn%22%0A                    + %22ds_1: !!io.shardingsphere.core.config.DataSourceConfiguration%5Cn%22%0A                    + %22  dataSourceClassName: org.apache.commons.dbcp2.BasicDataSource%5Cn%22 + %22  properties:%5Cn%22%0A                    + %22    driverClassName: com.mysql.jdbc.Driver%5Cn%22 + %22    url: jdbc:mysql://localhost:3306/ds_1%5Cn%22 + %22    username: root%5Cn%22 + %22    password: root%5Cn%22;%0A    %0A
     @Mock%0A  
@@ -2240,32 +2240,32 @@
 %0A    %0A    @Test%0A
-
     public void 
@@ -2305,24 +2305,136 @@
 rations() %7B%0A
+        when(regCenter.getDirectly(%22/test/config/schema/sharding_db/datasource%22)).thenReturn(DATA_SOURCE_YAML);%0A
     %7D%0A    %0A 

ADD DATA_SOURCE_YAML