congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
JsonMessageHandler1_0Test
Code IndexAdd Tabnine to your IDE (free)

How to use
JsonMessageHandler1_0Test
in
com.thoughtworks.go.plugin.access.packagematerial

Best Java code snippets using com.thoughtworks.go.plugin.access.packagematerial.JsonMessageHandler1_0Test (Showing top 16 results out of 315)

origin: gocd/gocd

@Test
public void shouldHandleNullMessagesForCheckRepositoryConnectionResponse() throws Exception {
  assertSuccessResult(messageHandler.responseMessageForCheckConnectionToRepository("{\"status\":\"success\"}"), new ArrayList<>());
  assertFailureResult(messageHandler.responseMessageForCheckConnectionToRepository("{\"status\":\"failure\"}"), new ArrayList<>());
}
origin: gocd/gocd

@Test
public void shouldValidateIncorrectJsonResponseForPackageConfiguration() {
  assertThat(errorMessageForPackageConfiguration(""), is("Unable to de-serialize json response. Empty response body"));
  assertThat(errorMessageForPackageConfiguration(null), is("Unable to de-serialize json response. Empty response body"));
  assertThat(errorMessageForPackageConfiguration("[{\"key-one\":\"value\"},{\"key-two\":\"value\"}]"), is("Unable to de-serialize json response. Package configuration should be returned as a map"));
  assertThat(errorMessageForPackageConfiguration("{\"\":{}}"), is("Unable to de-serialize json response. Package configuration key cannot be empty"));
  assertThat(errorMessageForPackageConfiguration("{\"key\":[{}]}"), is("Unable to de-serialize json response. Package configuration properties for key 'key' should be represented as a Map"));
  assertThat(errorMessageForRepositoryConfiguration("{\"key\":{\"part-of-identity\":\"true\"}}"), is("Unable to de-serialize json response. 'part-of-identity' property for key 'key' should be of type boolean"));
  assertThat(errorMessageForRepositoryConfiguration("{\"key\":{\"part-of-identity\":100}}"), is("Unable to de-serialize json response. 'part-of-identity' property for key 'key' should be of type boolean"));
  assertThat(errorMessageForRepositoryConfiguration("{\"key\":{\"part-of-identity\":\"\"}}"), is("Unable to de-serialize json response. 'part-of-identity' property for key 'key' should be of type boolean"));
  assertThat(errorMessageForRepositoryConfiguration("{\"key\":{\"secure\":\"true\"}}"), is("Unable to de-serialize json response. 'secure' property for key 'key' should be of type boolean"));
  assertThat(errorMessageForRepositoryConfiguration("{\"key\":{\"secure\":100}}"), is("Unable to de-serialize json response. 'secure' property for key 'key' should be of type boolean"));
  assertThat(errorMessageForRepositoryConfiguration("{\"key\":{\"secure\":\"\"}}"), is("Unable to de-serialize json response. 'secure' property for key 'key' should be of type boolean"));
  assertThat(errorMessageForRepositoryConfiguration("{\"key\":{\"required\":\"true\"}}"), is("Unable to de-serialize json response. 'required' property for key 'key' should be of type boolean"));
  assertThat(errorMessageForRepositoryConfiguration("{\"key\":{\"required\":100}}"), is("Unable to de-serialize json response. 'required' property for key 'key' should be of type boolean"));
  assertThat(errorMessageForRepositoryConfiguration("{\"key\":{\"required\":\"\"}}"), is("Unable to de-serialize json response. 'required' property for key 'key' should be of type boolean"));
  assertThat(errorMessageForRepositoryConfiguration("{\"key\":{\"display-name\":true}}"), is("Unable to de-serialize json response. 'display-name' property for key 'key' should be of type string"));
  assertThat(errorMessageForRepositoryConfiguration("{\"key\":{\"display-name\":100}}"), is("Unable to de-serialize json response. 'display-name' property for key 'key' should be of type string"));
  assertThat(errorMessageForRepositoryConfiguration("{\"key\":{\"display-order\":true}}"), is("Unable to de-serialize json response. 'display-order' property for key 'key' should be of type integer"));
  assertThat(errorMessageForRepositoryConfiguration("{\"key\":{\"display-order\":10.0}}"), is("Unable to de-serialize json response. 'display-order' property for key 'key' should be of type integer"));
  assertThat(errorMessageForRepositoryConfiguration("{\"key\":{\"display-order\":\"\"}}"), is("Unable to de-serialize json response. 'display-order' property for key 'key' should be of type integer"));
}
origin: gocd/gocd

@Test
public void shouldValidateIncorrectJsonForPackageRevision() {
  assertThat(errorMessageForPackageRevision("[{\"revision\":\"abc.rpm\"}]"), is("Unable to de-serialize json response. Package revision should be returned as a map"));
  assertThat(errorMessageForPackageRevision("{\"revision\":{}}"), is("Unable to de-serialize json response. Package revision should be of type string"));
  assertThat(errorMessageForPackageRevision("{\"revisionComment\":{}}"), is("Unable to de-serialize json response. Package revision comment should be of type string"));
  assertThat(errorMessageForPackageRevision("{\"user\":{}}"), is("Unable to de-serialize json response. Package revision user should be of type string"));
  assertThat(errorMessageForPackageRevision("{\"timestamp\":{}}"), is("Unable to de-serialize json response. Package revision timestamp should be of type string with format yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"));
  assertThat(errorMessageForPackageRevision("{\"timestamp\":\"12-01-2014\"}"), is("Unable to de-serialize json response. Package revision timestamp should be of type string with format yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"));
}
origin: gocd/gocd

@Test
public void shouldBuildSuccessResultFromCheckRepositoryConnectionResponse() throws Exception {
  String responseBody = "{\"status\":\"success\",messages=[\"message-one\",\"message-two\"]}";
  Result result = messageHandler.responseMessageForCheckConnectionToRepository(responseBody);
  assertSuccessResult(result, Arrays.asList("message-one", "message-two"));
}
origin: gocd/gocd

@Test
public void shouldBuildPackageRevisionFromLatestRevisionSinceResponse() throws Exception {
  String responseBody = "{\"revision\":\"abc.rpm\",\"timestamp\":\"2011-07-14T19:43:37.100Z\",\"user\":\"some-user\",\"revisionComment\":\"comment\"," +
      "\"trackbackUrl\":\"http:\\\\localhost:9999\",\"data\":{\"dataKeyOne\":\"data-value-one\",\"dataKeyTwo\":\"data-value-two\"}}";
  PackageRevision packageRevision = messageHandler.responseMessageForLatestRevisionSince(responseBody);
  assertPackageRevision(packageRevision, "abc.rpm", "some-user", "2011-07-14T19:43:37.100Z", "comment", "http:\\localhost:9999");
}
origin: gocd/gocd

@Test
public void shouldBuildFailureResultFromCheckPackageConnectionResponse() throws Exception {
  String responseBody = "{\"status\":\"failure\",messages=[\"message-one\",\"message-two\"]}";
  Result result = messageHandler.responseMessageForCheckConnectionToPackage(responseBody);
  assertFailureResult(result, Arrays.asList("message-one", "message-two"));
}
origin: gocd/gocd

@Test
public void shouldBuildRepositoryConfigurationFromResponseBody() throws Exception {
  String responseBody = "{" +
      "\"key-one\":{}," +
      "\"key-two\":{\"default-value\":\"two\",\"part-of-identity\":true,\"secure\":true,\"required\":true,\"display-name\":\"display-two\",\"display-order\":\"1\"}," +
      "\"key-three\":{\"default-value\":\"three\",\"part-of-identity\":false,\"secure\":false,\"required\":false,\"display-name\":\"display-three\",\"display-order\":\"2\"}" +
      "}";
  RepositoryConfiguration repositoryConfiguration = messageHandler.responseMessageForRepositoryConfiguration(responseBody);
  assertPropertyConfiguration((PackageMaterialProperty) repositoryConfiguration.get("key-one"), "key-one", null, true, true, false, "", 0);
  assertPropertyConfiguration((PackageMaterialProperty) repositoryConfiguration.get("key-two"), "key-two", "two", true, true, true, "display-two", 1);
  assertPropertyConfiguration((PackageMaterialProperty) repositoryConfiguration.get("key-three"), "key-three", "three", false, false, false, "display-three", 2);
}
origin: gocd/gocd

@Test
public void shouldBuildValidationResultFromCheckRepositoryConfigurationValidResponse() throws Exception {
  String responseBody = "[{\"key\":\"key-one\",\"message\":\"incorrect value\"},{\"message\":\"general error\"}]";
  ValidationResult validationResult = messageHandler.responseMessageForIsRepositoryConfigurationValid(responseBody);
  assertValidationError(validationResult.getErrors().get(0), "key-one", "incorrect value");
  assertValidationError(validationResult.getErrors().get(1), "", "general error");
}
origin: gocd/gocd

@Test
public void shouldThrowExceptionWhenAttemptingToGetLatestRevisionFromEmptyResponse(){
  assertThat(getErrorMessageFromLatestRevision(""), is("Empty response body"));
  assertThat(getErrorMessageFromLatestRevision("{}"), is("Empty response body"));
  assertThat(getErrorMessageFromLatestRevision(null), is("Empty response body"));
}
origin: gocd/gocd

@Test
public void shouldValidateIncorrectJsonResponseForRepositoryConfiguration() {
  assertThat(errorMessageForRepositoryConfiguration(""), is("Unable to de-serialize json response. Empty response body"));
  assertThat(errorMessageForRepositoryConfiguration(null), is("Unable to de-serialize json response. Empty response body"));
  assertThat(errorMessageForRepositoryConfiguration("[{\"key-one\":\"value\"},{\"key-two\":\"value\"}]"), is("Unable to de-serialize json response. Repository configuration should be returned as a map"));
  assertThat(errorMessageForRepositoryConfiguration("{\"\":{}}"), is("Unable to de-serialize json response. Repository configuration key cannot be empty"));
  assertThat(errorMessageForRepositoryConfiguration("{\"key\":[{}]}"), is("Unable to de-serialize json response. Repository configuration properties for key 'key' should be represented as a Map"));
  assertThat(errorMessageForRepositoryConfiguration("{\"key\":{\"part-of-identity\":\"true\"}}"), is("Unable to de-serialize json response. 'part-of-identity' property for key 'key' should be of type boolean"));
  assertThat(errorMessageForRepositoryConfiguration("{\"key\":{\"part-of-identity\":100}}"), is("Unable to de-serialize json response. 'part-of-identity' property for key 'key' should be of type boolean"));
  assertThat(errorMessageForRepositoryConfiguration("{\"key\":{\"part-of-identity\":\"\"}}"), is("Unable to de-serialize json response. 'part-of-identity' property for key 'key' should be of type boolean"));
  assertThat(errorMessageForRepositoryConfiguration("{\"key\":{\"secure\":\"true\"}}"), is("Unable to de-serialize json response. 'secure' property for key 'key' should be of type boolean"));
  assertThat(errorMessageForRepositoryConfiguration("{\"key\":{\"secure\":100}}"), is("Unable to de-serialize json response. 'secure' property for key 'key' should be of type boolean"));
  assertThat(errorMessageForRepositoryConfiguration("{\"key\":{\"secure\":\"\"}}"), is("Unable to de-serialize json response. 'secure' property for key 'key' should be of type boolean"));
  assertThat(errorMessageForRepositoryConfiguration("{\"key\":{\"required\":\"true\"}}"), is("Unable to de-serialize json response. 'required' property for key 'key' should be of type boolean"));
  assertThat(errorMessageForRepositoryConfiguration("{\"key\":{\"required\":100}}"), is("Unable to de-serialize json response. 'required' property for key 'key' should be of type boolean"));
  assertThat(errorMessageForRepositoryConfiguration("{\"key\":{\"required\":\"\"}}"), is("Unable to de-serialize json response. 'required' property for key 'key' should be of type boolean"));
  assertThat(errorMessageForRepositoryConfiguration("{\"key\":{\"display-name\":true}}"), is("Unable to de-serialize json response. 'display-name' property for key 'key' should be of type string"));
  assertThat(errorMessageForRepositoryConfiguration("{\"key\":{\"display-name\":100}}"), is("Unable to de-serialize json response. 'display-name' property for key 'key' should be of type string"));
  assertThat(errorMessageForRepositoryConfiguration("{\"key\":{\"display-order\":true}}"), is("Unable to de-serialize json response. 'display-order' property for key 'key' should be of type integer"));
  assertThat(errorMessageForRepositoryConfiguration("{\"key\":{\"display-order\":10.0}}"), is("Unable to de-serialize json response. 'display-order' property for key 'key' should be of type integer"));
  assertThat(errorMessageForRepositoryConfiguration("{\"key\":{\"display-order\":\"\"}}"), is("Unable to de-serialize json response. 'display-order' property for key 'key' should be of type integer"));
}
origin: gocd/gocd

@Test
public void shouldBuildSuccessResultFromCheckPackageConnectionResponse() throws Exception {
  String responseBody = "{\"status\":\"success\",messages=[\"message-one\",\"message-two\"]}";
  Result result = messageHandler.responseMessageForCheckConnectionToPackage(responseBody);
  assertSuccessResult(result, Arrays.asList("message-one", "message-two"));
}
origin: gocd/gocd

@Test
public void shouldBuildPackageRevisionFromLatestRevisionResponse() throws Exception {
  String responseBody = "{\"revision\":\"abc.rpm\",\"timestamp\":\"2011-07-14T19:43:37.100Z\",\"user\":\"some-user\",\"revisionComment\":\"comment\"," +
      "\"trackbackUrl\":\"http:\\\\localhost:9999\",\"data\":{\"dataKeyOne\":\"data-value-one\",\"dataKeyTwo\":\"data-value-two\"}}";
  PackageRevision packageRevision = messageHandler.responseMessageForLatestRevision(responseBody);
  assertPackageRevision(packageRevision, "abc.rpm", "some-user", "2011-07-14T19:43:37.100Z", "comment", "http:\\localhost:9999");
}
origin: gocd/gocd

@Test
public void shouldBuildFailureResultFromCheckRepositoryConnectionResponse() throws Exception {
  String responseBody = "{\"status\":\"failure\",messages=[\"message-one\",\"message-two\"]}";
  Result result = messageHandler.responseMessageForCheckConnectionToRepository(responseBody);
  assertFailureResult(result, Arrays.asList("message-one", "message-two"));
}
origin: gocd/gocd

@Test
public void shouldBuildPackageConfigurationFromResponseBody() throws Exception {
  String responseBody = "{" +
      "\"key-one\":{}," +
      "\"key-two\":{\"default-value\":\"two\",\"part-of-identity\":true,\"secure\":true,\"required\":true,\"display-name\":\"display-two\",\"display-order\":\"1\"}," +
      "\"key-three\":{\"default-value\":\"three\",\"part-of-identity\":false,\"secure\":false,\"required\":false,\"display-name\":\"display-three\",\"display-order\":\"2\"}" +
      "}";
  com.thoughtworks.go.plugin.api.material.packagerepository.PackageConfiguration packageConfiguration = messageHandler.responseMessageForPackageConfiguration(responseBody);
  assertPropertyConfiguration((PackageMaterialProperty) packageConfiguration.get("key-one"), "key-one", null, true, true, false, "", 0);
  assertPropertyConfiguration((PackageMaterialProperty) packageConfiguration.get("key-two"), "key-two", "two", true, true, true, "display-two", 1);
  assertPropertyConfiguration((PackageMaterialProperty) packageConfiguration.get("key-three"), "key-three", "three", false, false, false, "display-three", 2);
}
origin: gocd/gocd

@Test
public void shouldBuildValidationResultForCheckRepositoryConfigurationValidResponse() throws Exception {
  String responseBody = "[{\"key\":\"key-one\",\"message\":\"incorrect value\"},{\"message\":\"general error\"}]";
  ValidationResult validationResult = messageHandler.responseMessageForIsPackageConfigurationValid(responseBody);
  assertValidationError(validationResult.getErrors().get(0), "key-one", "incorrect value");
  assertValidationError(validationResult.getErrors().get(1), "", "general error");
}
origin: gocd/gocd

@Test
public void shouldHandleNullMessagesForCheckPackageConnectionResponse() throws Exception {
  assertSuccessResult(messageHandler.responseMessageForCheckConnectionToPackage("{\"status\":\"success\"}"), new ArrayList<>());
  assertFailureResult(messageHandler.responseMessageForCheckConnectionToPackage("{\"status\":\"failure\"}"), new ArrayList<>());
}
com.thoughtworks.go.plugin.access.packagematerialJsonMessageHandler1_0Test

Most used methods

  • assertFailureResult
  • assertPackageRevision
  • assertPropertyConfiguration
  • assertSuccessResult
  • assertValidationError
  • errorMessageForPackageConfiguration
  • errorMessageForPackageRevision
  • errorMessageForRepositoryConfiguration
  • getErrorMessageFromLatestRevision

Popular in Java

  • Creating JSON documents from java classes using gson
  • startActivity (Activity)
  • setRequestProperty (URLConnection)
  • getSharedPreferences (Context)
  • BufferedImage (java.awt.image)
    The BufferedImage subclass describes an java.awt.Image with an accessible buffer of image data. All
  • Date (java.util)
    A specific moment in time, with millisecond precision. Values typically come from System#currentTime
  • Random (java.util)
    This class provides methods that return pseudo-random values.It is dangerous to seed Random with the
  • JButton (javax.swing)
  • JOptionPane (javax.swing)
  • SAXParseException (org.xml.sax)
    Encapsulate an XML parse error or warning.> This module, both source code and documentation, is in t
  • Top Vim plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now