@Test public void shouldTalkToPluginToCheckIfSCMConfigurationIsValid() throws Exception { when(jsonMessageHandler.requestMessageForIsSCMConfigurationValid(scmPropertyConfiguration)).thenReturn(requestBody); ValidationResult deserializedResponse = new ValidationResult(); when(jsonMessageHandler.responseMessageForIsSCMConfigurationValid(responseBody)).thenReturn(deserializedResponse); ValidationResult response = scmExtension.isSCMConfigurationValid(PLUGIN_ID, scmPropertyConfiguration); assertRequest(requestArgumentCaptor.getValue(), SCM_EXTENSION, "1.0", SCMExtension.REQUEST_VALIDATE_SCM_CONFIGURATION, requestBody); verify(jsonMessageHandler).requestMessageForIsSCMConfigurationValid(scmPropertyConfiguration); verify(jsonMessageHandler).responseMessageForIsSCMConfigurationValid(responseBody); assertSame(response, deserializedResponse); }
@Test public void shouldTalkToPluginToGetPluginSettingsView() throws Exception { String deserializedResponse = ""; when(pluginSettingsJSONMessageHandler.responseMessageForPluginSettingsView(responseBody)).thenReturn(deserializedResponse); String response = scmExtension.getPluginSettingsView(PLUGIN_ID); assertRequest(requestArgumentCaptor.getValue(), SCM_EXTENSION, "1.0", PluginSettingsConstants.REQUEST_PLUGIN_SETTINGS_VIEW, null); verify(pluginSettingsJSONMessageHandler).responseMessageForPluginSettingsView(responseBody); assertSame(response, deserializedResponse); }
@Test public void shouldTalkToPluginToGetLatestModification() throws Exception { String flyweight = "flyweight"; when(jsonMessageHandler.requestMessageForLatestRevision(scmPropertyConfiguration, materialData, flyweight)).thenReturn(requestBody); MaterialPollResult deserializedResponse = new MaterialPollResult(); when(jsonMessageHandler.responseMessageForLatestRevision(responseBody)).thenReturn(deserializedResponse); MaterialPollResult response = scmExtension.getLatestRevision(PLUGIN_ID, scmPropertyConfiguration, materialData, flyweight); assertRequest(requestArgumentCaptor.getValue(), SCM_EXTENSION, "1.0", SCMExtension.REQUEST_LATEST_REVISION, requestBody); verify(jsonMessageHandler).requestMessageForLatestRevision(scmPropertyConfiguration, materialData, flyweight); verify(jsonMessageHandler).responseMessageForLatestRevision(responseBody); assertSame(response, deserializedResponse); }
@Test public void shouldTalkToPluginToGetValidatePluginSettings() throws Exception { when(pluginSettingsJSONMessageHandler.requestMessageForPluginSettingsValidation(pluginSettingsConfiguration)).thenReturn(requestBody); ValidationResult deserializedResponse = new ValidationResult(); when(pluginSettingsJSONMessageHandler.responseMessageForPluginSettingsValidation(responseBody)).thenReturn(deserializedResponse); ValidationResult response = scmExtension.validatePluginSettings(PLUGIN_ID, pluginSettingsConfiguration); assertRequest(requestArgumentCaptor.getValue(), SCM_EXTENSION, "1.0", PluginSettingsConstants.REQUEST_VALIDATE_PLUGIN_SETTINGS, requestBody); verify(pluginSettingsJSONMessageHandler).responseMessageForPluginSettingsValidation(responseBody); assertSame(response, deserializedResponse); }
@Test public void shouldTalkToPluginToCheckSCMConnectionSuccessful() throws Exception { when(jsonMessageHandler.requestMessageForCheckConnectionToSCM(scmPropertyConfiguration)).thenReturn(requestBody); Result deserializedResponse = new Result(); when(jsonMessageHandler.responseMessageForCheckConnectionToSCM(responseBody)).thenReturn(deserializedResponse); Result response = scmExtension.checkConnectionToSCM(PLUGIN_ID, scmPropertyConfiguration); assertRequest(requestArgumentCaptor.getValue(), SCM_EXTENSION, "1.0", SCMExtension.REQUEST_CHECK_SCM_CONNECTION, requestBody); verify(jsonMessageHandler).requestMessageForCheckConnectionToSCM(scmPropertyConfiguration); verify(jsonMessageHandler).responseMessageForCheckConnectionToSCM(responseBody); assertSame(response, deserializedResponse); }
@Test public void shouldTalkToPluginToGetPluginSettingsConfiguration() throws Exception { PluginSettingsConfiguration deserializedResponse = new PluginSettingsConfiguration(); when(pluginSettingsJSONMessageHandler.responseMessageForPluginSettingsConfiguration(responseBody)).thenReturn(deserializedResponse); PluginSettingsConfiguration response = scmExtension.getPluginSettingsConfiguration(PLUGIN_ID); assertRequest(requestArgumentCaptor.getValue(), SCM_EXTENSION, "1.0", PluginSettingsConstants.REQUEST_PLUGIN_SETTINGS_CONFIGURATION, null); verify(pluginSettingsJSONMessageHandler).responseMessageForPluginSettingsConfiguration(responseBody); assertSame(response, deserializedResponse); }
@Test public void shouldTalkToPluginToGetSCMConfiguration() throws Exception { SCMPropertyConfiguration deserializedResponse = new SCMPropertyConfiguration(); when(jsonMessageHandler.responseMessageForSCMConfiguration(responseBody)).thenReturn(deserializedResponse); SCMPropertyConfiguration response = scmExtension.getSCMConfiguration(PLUGIN_ID); assertRequest(requestArgumentCaptor.getValue(), SCM_EXTENSION, "1.0", SCMExtension.REQUEST_SCM_CONFIGURATION, null); verify(jsonMessageHandler).responseMessageForSCMConfiguration(responseBody); assertSame(response, deserializedResponse); }
@Test public void shouldTalkToPluginToCheckout() throws Exception { String destination = "destination"; SCMRevision revision = new SCMRevision(); when(jsonMessageHandler.requestMessageForCheckout(scmPropertyConfiguration, destination, revision)).thenReturn(requestBody); Result deserializedResponse = new Result(); when(jsonMessageHandler.responseMessageForCheckout(responseBody)).thenReturn(deserializedResponse); Result response = scmExtension.checkout(PLUGIN_ID, scmPropertyConfiguration, destination, revision); assertRequest(requestArgumentCaptor.getValue(), SCM_EXTENSION, "1.0", SCMExtension.REQUEST_CHECKOUT, requestBody); verify(jsonMessageHandler).requestMessageForCheckout(scmPropertyConfiguration, destination, revision); verify(jsonMessageHandler).responseMessageForCheckout(responseBody); assertSame(response, deserializedResponse); }
@Test public void shouldTalkToPluginToGetLatestModificationSinceLastRevision() throws Exception { String flyweight = "flyweight"; SCMRevision previouslyKnownRevision = new SCMRevision(); when(jsonMessageHandler.requestMessageForLatestRevisionsSince(scmPropertyConfiguration, materialData, flyweight, previouslyKnownRevision)).thenReturn(requestBody); MaterialPollResult deserializedResponse = new MaterialPollResult(); when(jsonMessageHandler.responseMessageForLatestRevisionsSince(responseBody)).thenReturn(deserializedResponse); MaterialPollResult response = scmExtension.latestModificationSince(PLUGIN_ID, scmPropertyConfiguration, materialData, flyweight, previouslyKnownRevision); assertRequest(requestArgumentCaptor.getValue(), SCM_EXTENSION, "1.0", SCMExtension.REQUEST_LATEST_REVISIONS_SINCE, requestBody); verify(jsonMessageHandler).requestMessageForLatestRevisionsSince(scmPropertyConfiguration, materialData, flyweight, previouslyKnownRevision); verify(jsonMessageHandler).responseMessageForLatestRevisionsSince(responseBody); assertSame(response, deserializedResponse); }
@Test public void shouldTalkToPluginToGetSCMView() throws Exception { SCMView deserializedResponse = new SCMView() { @Override public String displayValue() { return null; } @Override public String template() { return null; } }; when(jsonMessageHandler.responseMessageForSCMView(responseBody)).thenReturn(deserializedResponse); SCMView response = scmExtension.getSCMView(PLUGIN_ID); assertRequest(requestArgumentCaptor.getValue(), SCM_EXTENSION, "1.0", SCMExtension.REQUEST_SCM_VIEW, null); verify(jsonMessageHandler).responseMessageForSCMView(responseBody); assertSame(response, deserializedResponse); }