ConnectorPluginsResource { @PUT @Path("/{connectorType}/config/validate") public ConfigInfos validateConfigs(final @PathParam("connectorType") String connType, final Map<String, String> connectorConfig) throws Throwable { return herder.validateConfigs(connType, connectorConfig); } ConnectorPluginsResource(Herder herder); @PUT @Path("/{connectorType}/config/validate") ConfigInfos validateConfigs(final @PathParam("connectorType") String connType,
                                       final Map<String, String> connectorConfig); @GET @Path("/") List<ConnectorPluginInfo> listConnectorPlugins();  }
@Test public void testValidateConfig() throws Throwable { herder.validateConfigs(EasyMock.eq(ConnectorPluginsResourceTestConnector.class.getName()), EasyMock.eq(props)); PowerMock.expectLastCall().andAnswer(new IAnswer<ConfigInfos>() { @Override public ConfigInfos answer() { ConfigDef connectorConfigDef = ConnectorConfig.configDef(); List<ConfigValue> connectorConfigValues = connectorConfigDef.validate(props); Connector connector = new ConnectorPluginsResourceTestConnector(); Config config = connector.validate(props); ConfigDef configDef = connector.config(); Map<String, ConfigDef.ConfigKey> configKeys = configDef.configKeys(); List<ConfigValue> configValues = config.configValues(); Map<String, ConfigDef.ConfigKey> resultConfigKeys = new HashMap<>(configKeys); resultConfigKeys.putAll(connectorConfigDef.configKeys()); configValues.addAll(connectorConfigValues); return AbstractHerder.generateResult(ConnectorPluginsResourceTestConnector.class.getName(), resultConfigKeys, configValues, Collections.singletonList("Test")); } }); PowerMock.replayAll(); ConfigInfos configInfos = connectorPluginsResource.validateConfigs(ConnectorPluginsResourceTestConnector.class.getName(), props); assertEquals(CONFIG_INFOS.name(), configInfos.name()); assertEquals(CONFIG_INFOS.errorCount(), configInfos.errorCount()); assertEquals(CONFIG_INFOS.groups(), configInfos.groups()); assertEquals(new HashSet<>(CONFIG_INFOS.values()), new HashSet<>(configInfos.values())); PowerMock.verifyAll(); }