/*
 * 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.registry.config.listener;

import io.shardingsphere.orchestration.internal.registry.config.service.ConfigurationService;
import io.shardingsphere.orchestration.reg.api.RegistryCenter;
import io.shardingsphere.orchestration.reg.listener.DataChangedEvent;
import io.shardingsphere.orchestration.util.FieldUtil;
import lombok.SneakyThrows;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;

import java.util.HashMap;
import java.util.Map;

import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

@RunWith(MockitoJUnitRunner.class)
public final class ConfigMapChangedListenerTest {
    
    private ConfigMapChangedListener configMapChangedListener;
    
    @Mock
    private RegistryCenter regCenter;
    
    @Mock
    private ConfigurationService configService;
    
    @Before
    @SneakyThrows
    public void setUp() {
        configMapChangedListener = new ConfigMapChangedListener("test", regCenter);
        FieldUtil.setField(configMapChangedListener, "configService", configService);
    }
    
    @Test
    public void assertCreateShardingOrchestrationEvent() {
        Map<String, Object> expected = new HashMap<>(1, 1);
        expected.put("key_0", "value_0");
        when(configService.loadConfigMap()).thenReturn(expected);
        assertThat(configMapChangedListener.createShardingOrchestrationEvent(mock(DataChangedEvent.class)).getConfigMap(), is(expected));
    }
}

@@ -693,102 +693,8 @@
 r;%0A%0A
-import io.shardingsphere.orchestration.internal.registry.config.service.ConfigurationService;%0A
 impo
@@ -865,22 +865,49 @@
 ion.
-util.FieldUtil
+reg.listener.DataChangedEvent.ChangedType
 ;%0Aim
@@ -1088,57 +1088,8 @@
 r;%0A%0A
-import java.util.HashMap;%0Aimport java.util.Map;%0A%0A
 impo
@@ -1174,88 +1174,8 @@
 hat;
-%0Aimport static org.mockito.Mockito.mock;%0Aimport static org.mockito.Mockito.when;
 %0A%0A@R
@@ -1258,24 +1258,113 @@
 Test %7B%0A    %0A
+    private static final String CONFIG_MAP_YAML = %22sharding-key1: sharding-value1%22;%0A    %0A
     private 
@@ -1476,71 +1476,8 @@
    %0A
-    @Mock%0A    private ConfigurationService configService;%0A    %0A
     
@@ -1620,335 +1620,193 @@
     
-    FieldUtil.setField(configMapChangedListener, %22configService%22, configService);%0A    %7D%0A    %0A    @Test%0A    public void assertCreateShardingOrchestrationEvent() %7B%0A        Map%3CString, Object%3E expected = new HashMap%3C%3E(1, 1);%0A        expected.put(%22key_0%22, %22value_0%22);%0A        when(configService.loadConfigMap()).thenReturn(expected
+%7D%0A    %0A    @Test%0A    public void assertCreateShardingOrchestrationEvent() %7B%0A        DataChangedEvent dataChangedEvent = new DataChangedEvent(%22test%22, CONFIG_MAP_YAML, ChangedType.UPDATED
 );%0A 
@@ -1885,14 +1885,9 @@
 ent(
-mock(D
+d
 ataC
@@ -1897,23 +1897,16 @@
 gedEvent
-.class)
 ).getCon
@@ -1917,21 +1917,21 @@
 ap()
-, is(expected
+.size(), is(1
 ));%0A

modify assertCreateShardingOrchestrationEvent()