@Test public void shouldTalkToPluginToValidatePluginSettings() throws Exception { extension.registerHandler("1.0", pluginSettingsJSONMessageHandler); extension.messageHandlerMap.put("1.0", jsonMessageHandler); String requestBody = "expected-request"; when(pluginSettingsJSONMessageHandler.requestMessageForPluginSettingsValidation(pluginSettingsConfiguration)).thenReturn(requestBody); String responseBody = "expected-response"; ValidationResult deserializedResponse = new ValidationResult(); when(pluginSettingsJSONMessageHandler.responseMessageForPluginSettingsValidation(responseBody)).thenReturn(deserializedResponse); when(pluginManager.isPluginOfType(PACKAGE_MATERIAL_EXTENSION, PLUGIN_ID)).thenReturn(true); when(pluginManager.submitTo(eq(PLUGIN_ID), eq(PACKAGE_MATERIAL_EXTENSION), requestArgumentCaptor.capture())).thenReturn(DefaultGoPluginApiResponse.success(responseBody)); ValidationResult response = extension.validatePluginSettings(PLUGIN_ID, pluginSettingsConfiguration); assertRequest(requestArgumentCaptor.getValue(), PACKAGE_MATERIAL_EXTENSION, "1.0", PluginSettingsConstants.REQUEST_VALIDATE_PLUGIN_SETTINGS, requestBody); verify(pluginSettingsJSONMessageHandler).responseMessageForPluginSettingsValidation(responseBody); assertSame(response, deserializedResponse); } @Test