Skip to content

Commit

Permalink
createOrchestrationEvent => createShardingOrchestrationEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
terrymanu committed Dec 3, 2018
1 parent 728b328 commit 0304460
Show file tree
Hide file tree
Showing 16 changed files with 28 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public AuthenticationChangedListener(final String name, final RegistryCenter reg
}

@Override
protected AuthenticationChangedEvent createOrchestrationEvent(final DataChangedEvent event) {
protected AuthenticationChangedEvent createShardingOrchestrationEvent(final DataChangedEvent event) {
return new AuthenticationChangedEvent(configService.loadAuthentication());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public ConfigMapChangedListener(final String name, final RegistryCenter regCente
}

@Override
protected ConfigMapChangedEvent createOrchestrationEvent(final DataChangedEvent event) {
protected ConfigMapChangedEvent createShardingOrchestrationEvent(final DataChangedEvent event) {
return new ConfigMapChangedEvent(configService.loadConfigMap());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public DataSourceChangedListener(final String name, final RegistryCenter regCent
}

@Override
protected DataSourceChangedEvent createOrchestrationEvent(final DataChangedEvent event) {
protected DataSourceChangedEvent createShardingOrchestrationEvent(final DataChangedEvent event) {
return new DataSourceChangedEvent(shardingSchemaName, dataSourceService.getAvailableDataSourceConfigurations(shardingSchemaName));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public PropertiesChangedListener(final String name, final RegistryCenter regCent
}

@Override
protected PropertiesChangedEvent createOrchestrationEvent(final DataChangedEvent event) {
protected PropertiesChangedEvent createShardingOrchestrationEvent(final DataChangedEvent event) {
return new PropertiesChangedEvent(configService.loadProperties());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public RuleChangedListener(final String name, final RegistryCenter regCenter, fi
}

@Override
protected ShardingOrchestrationEvent createOrchestrationEvent(final DataChangedEvent event) {
protected ShardingOrchestrationEvent createShardingOrchestrationEvent(final DataChangedEvent event) {
return configService.isShardingRule(shardingSchemaName) ? getShardingConfigurationChangedEvent() : getMasterSlaveConfigurationChangedEvent();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ public final void watch(final ChangedType... watchedChangedTypes) {
@Override
public void onChange(final DataChangedEvent dataChangedEvent) {
if (watchedChangedTypeList.contains(dataChangedEvent.getChangedType())) {
eventBus.post(createOrchestrationEvent(dataChangedEvent));
eventBus.post(createShardingOrchestrationEvent(dataChangedEvent));
}
}
});
}

protected abstract ShardingOrchestrationEvent createOrchestrationEvent(DataChangedEvent event);
protected abstract ShardingOrchestrationEvent createShardingOrchestrationEvent(DataChangedEvent event);
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public DataSourceStateChangedListener(final String name, final RegistryCenter re
}

@Override
protected DisabledStateChangedEvent createOrchestrationEvent(final DataChangedEvent event) {
protected DisabledStateChangedEvent createShardingOrchestrationEvent(final DataChangedEvent event) {
return new DisabledStateChangedEvent(dataSourceService.getDisabledSlaveSchemaGroup());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public InstanceStateChangedListener(final String name, final RegistryCenter regC
}

@Override
protected CircuitStateChangedEvent createOrchestrationEvent(final DataChangedEvent event) {
protected CircuitStateChangedEvent createShardingOrchestrationEvent(final DataChangedEvent event) {
return new CircuitStateChangedEvent(StateNodeStatus.DISABLED.toString().equalsIgnoreCase(regCenter.get(event.getKey())));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ public void setUp() {
}

@Test
public void assertCreateOrchestrationEvent() {
public void assertCreateShardingOrchestrationEvent() {
Authentication expected = new Authentication();
when(configService.loadAuthentication()).thenReturn(expected);
assertThat(authenticationChangedListener.createOrchestrationEvent(mock(DataChangedEvent.class)).getAuthentication(), is(expected));
assertThat(authenticationChangedListener.createShardingOrchestrationEvent(mock(DataChangedEvent.class)).getAuthentication(), is(expected));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ public void setUp() {
}

@Test
public void assertCreateOrchestrationEvent() {
public void assertCreateShardingOrchestrationEvent() {
Map<String, Object> expected = new HashMap<>(1, 1);
expected.put("key_0", "value_0");
when(configService.loadConfigMap()).thenReturn(expected);
assertThat(configMapChangedListener.createOrchestrationEvent(mock(DataChangedEvent.class)).getConfigMap(), is(expected));
assertThat(configMapChangedListener.createShardingOrchestrationEvent(mock(DataChangedEvent.class)).getConfigMap(), is(expected));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ public void setUp() {
}

@Test
public void assertCreateOrchestrationEvent() {
public void assertCreateShardingOrchestrationEvent() {
Map<String, DataSourceConfiguration> expected = new HashMap<>(1, 1);
expected.put("sharding_db", mock(DataSourceConfiguration.class));
when(dataSourceService.getAvailableDataSourceConfigurations("sharding_db")).thenReturn(expected);
DataSourceChangedEvent actual = dataSourceChangedListener.createOrchestrationEvent(mock(DataChangedEvent.class));
DataSourceChangedEvent actual = dataSourceChangedListener.createShardingOrchestrationEvent(mock(DataChangedEvent.class));
assertThat(actual.getShardingSchemaName(), is("sharding_db"));
assertThat(actual.getDataSourceConfigurations(), is(expected));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ public void setUp() {
}

@Test
public void assertCreateOrchestrationEvent() {
public void assertCreateShardingOrchestrationEvent() {
Properties expected = new Properties();
expected.setProperty(ShardingPropertiesConstant.SQL_SHOW.getKey(), Boolean.TRUE.toString());
when(configService.loadProperties()).thenReturn(expected);
assertThat(propertiesChangedListener.createOrchestrationEvent(mock(DataChangedEvent.class)).getProps(), is(expected));
assertThat(propertiesChangedListener.createShardingOrchestrationEvent(mock(DataChangedEvent.class)).getProps(), is(expected));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,20 +61,20 @@ public void setUp() {
}

@Test
public void assertCreateOrchestrationEventForSharding() {
public void assertCreateShardingOrchestrationEventForSharding() {
when(configService.isShardingRule("sharding_db")).thenReturn(true);
ShardingRuleConfiguration expected = mock(ShardingRuleConfiguration.class);
when(dataSourceService.getAvailableShardingRuleConfiguration("sharding_db")).thenReturn(expected);
ShardingRuleChangedEvent actual = (ShardingRuleChangedEvent) ruleChangedListener.createOrchestrationEvent(mock(DataChangedEvent.class));
ShardingRuleChangedEvent actual = (ShardingRuleChangedEvent) ruleChangedListener.createShardingOrchestrationEvent(mock(DataChangedEvent.class));
assertThat(actual.getShardingSchemaName(), is("sharding_db"));
assertThat(actual.getShardingRuleConfiguration(), is(expected));
}

@Test
public void assertCreateOrchestrationEventForMasterSlave() {
public void assertCreateShardingOrchestrationEventForMasterSlave() {
MasterSlaveRuleConfiguration expected = mock(MasterSlaveRuleConfiguration.class);
when(dataSourceService.getAvailableMasterSlaveRuleConfiguration("sharding_db")).thenReturn(expected);
MasterSlaveRuleChangedEvent actual = (MasterSlaveRuleChangedEvent) ruleChangedListener.createOrchestrationEvent(mock(DataChangedEvent.class));
MasterSlaveRuleChangedEvent actual = (MasterSlaveRuleChangedEvent) ruleChangedListener.createShardingOrchestrationEvent(mock(DataChangedEvent.class));
assertThat(actual.getShardingSchemaName(), is("sharding_db"));
assertThat(actual.getMasterSlaveRuleConfiguration(), is(expected));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void assertWatch() {
PostShardingOrchestrationEventListener postShardingOrchestrationEventListener = new PostShardingOrchestrationEventListener(regCenter, "test") {

@Override
protected ShardingOrchestrationEvent createOrchestrationEvent(final DataChangedEvent event) {
protected ShardingOrchestrationEvent createShardingOrchestrationEvent(final DataChangedEvent event) {
return mock(ShardingOrchestrationEvent.class);
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ public void setUp() {
}

@Test
public void assertCreateOrchestrationEvent() {
public void assertCreateShardingOrchestrationEvent() {
OrchestrationShardingSchemaGroup expected = mock(OrchestrationShardingSchemaGroup.class);
when(dataSourceService.getDisabledSlaveSchemaGroup()).thenReturn(expected);
assertThat(dataSourceStateChangedListener.createOrchestrationEvent(mock(DataChangedEvent.class)).getDisabledGroup(), is(expected));
assertThat(dataSourceStateChangedListener.createShardingOrchestrationEvent(mock(DataChangedEvent.class)).getDisabledGroup(), is(expected));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,16 @@ public void setUp() {
}

@Test
public void assertCreateOrchestrationEventWhenEnabled() {
public void assertCreateShardingOrchestrationEventWhenEnabled() {
DataChangedEvent dataChangedEvent = new DataChangedEvent("test/test_ds", "", ChangedType.UPDATED);
when(regCenter.get("test/test_ds")).thenReturn("");
assertFalse(instanceStateChangedListener.createOrchestrationEvent(dataChangedEvent).isCircuitBreak());
assertFalse(instanceStateChangedListener.createShardingOrchestrationEvent(dataChangedEvent).isCircuitBreak());
}

@Test
public void assertCreateOrchestrationEventWhenDisabled() {
public void assertCreateShardingOrchestrationEventWhenDisabled() {
DataChangedEvent dataChangedEvent = new DataChangedEvent("test/test_ds", StateNodeStatus.DISABLED.name(), ChangedType.UPDATED);
when(regCenter.get("test/test_ds")).thenReturn(StateNodeStatus.DISABLED.name());
assertTrue(instanceStateChangedListener.createOrchestrationEvent(dataChangedEvent).isCircuitBreak());
assertTrue(instanceStateChangedListener.createShardingOrchestrationEvent(dataChangedEvent).isCircuitBreak());
}
}

0 comments on commit 0304460

Please sign in to comment.