@Test public void JsonResponseShouldContainLocation() throws IOException { Item item = new Item(1l,"Teller", "Regal A", LocalDate.now()); JsonContent<Item> write = this.json.write(item); this.json.write(item).assertThat() .extractingJsonPathStringValue("@.location") .isEqualTo("Regal A"); this.json.write(item).assertThat() .extractingJsonPathStringValue("@.description") .isEqualTo("Teller"); this.json.write(item).assertThat() .extractingJsonPathNumberValue("@.id") .isEqualTo(1); this.json.write(item).assertThat() .extractingJsonPathNumberValue("@.itemdate") .isNull(); }
@Override protected void validateJson(final JsonContent<SearchResult> jsonContent) throws IOException { jsonContent.assertThat() .hasJsonPathStringValue("$.reference", "ABC") .hasJsonPathStringValue("$.index", "wiki_eng") .hasJsonPathStringValue("$.title", "Fiji") .hasJsonPathStringValue("$.summary", "Fiji is an island country") .hasJsonPathNumberValue("$.weight", 11.7) .hasJsonPathArrayValue("$.fieldMap.CUSTOM_FIELD.names", "CUSTOM_FIELD") .hasJsonPathStringValue("$.fieldMap.CUSTOM_FIELD.type", "STRING") .hasJsonPathBooleanValue("$.fieldMap.CUSTOM_FIELD.advanced", false) .hasJsonPathArrayValue("$.fieldMap.CUSTOM_FIELD.names", "CUSTOM_VALUE") .hasJsonPathArrayValue("$.fieldMap.DATE_FIELD.names", "DATE_FIELD") .hasJsonPathStringValue("$.fieldMap.DATE_FIELD.type", "DATE") .hasJsonPathBooleanValue("$.fieldMap.DATE_FIELD.advanced", false) .hasJsonPathNumberValue("$.fieldMap.DATE_FIELD.values[0].value", 1479318360000L) .hasJsonPathNumberValue("$.date", 1479318360000L) .hasJsonPathStringValue("$.promotionCategory", "NONE") .hasJsonPathStringValue("$.domain", "PUBLIC_INDEXES"); }
@Override protected void validateJson(final JsonContent<SearchResult> jsonContent) throws IOException { jsonContent.assertThat() .hasJsonPathStringValue("$.reference", "ABC") .hasJsonPathStringValue("$.index", "wiki_eng") .hasJsonPathStringValue("$.title", "Fiji") .hasJsonPathStringValue("$.summary", "Fiji is an island country") .hasJsonPathNumberValue("$.weight", 11.7) .hasJsonPathArrayValue("$.fieldMap.CUSTOM_FIELD.names", "CUSTOM_FIELD") .hasJsonPathStringValue("$.fieldMap.CUSTOM_FIELD.type", "STRING") .hasJsonPathBooleanValue("$.fieldMap.CUSTOM_FIELD.advanced", false) .hasJsonPathArrayValue("$.fieldMap.CUSTOM_FIELD.names", "CUSTOM_VALUE") .hasJsonPathArrayValue("$.fieldMap.DATE_FIELD.names", "DATE_FIELD") .hasJsonPathStringValue("$.fieldMap.DATE_FIELD.type", "DATE") .hasJsonPathBooleanValue("$.fieldMap.DATE_FIELD.advanced", false) .hasJsonPathNumberValue("$.fieldMap.DATE_FIELD.values[0].value", 1479318360000L) .hasJsonPathNumberValue("$.date", 1479318360000L) .hasJsonPathStringValue("$.promotionCategory", "NONE") .hasJsonPathStringValue("$.qmsId", "0") .hasJsonPathStringValue("$.promotionName", "SomeName"); }
@Override protected void validateJson(final JsonContent<TrendingWidget> jsonContent) { jsonContent.assertThat() .hasJsonPathStringValue("$.name", "Test Widget") .hasJsonPathStringValue("$.type", "TrendingWidget") .hasJsonPathNumberValue("$.x", 1) .hasJsonPathNumberValue("$.y", 1) .hasJsonPathNumberValue("$.width", 1) .hasJsonPathNumberValue("$.height", 1) .hasJsonPathNumberValue("$.datasource.config.id", 123) .hasJsonPathStringValue("$.datasource.config.type", "QUERY") .hasJsonPathStringValue("$.widgetSettings.parametricField", "/DOCUMENT/CONTENT_TYPE") .hasJsonPathStringValue("$.widgetSettings.dateField", "/DOCUMENT/AUTN_DATE") .hasJsonPathNumberValue("$.widgetSettings.maxValues", 5) .hasJsonPathStringValue("$.widgetSettings.maxDate", "2010-04-05T00:00:00Z") .hasJsonPathStringValue("$.widgetSettings.minDate", "2009-04-05T00:00:00Z") .hasJsonPathNumberValue("$.widgetSettings.numberOfBuckets", 12); }
@Override protected void validateJson(final JsonContent<Database> jsonContent) throws IOException { jsonContent.assertThat() .hasJsonPathStringValue("$.name", "wiki_eng") .hasJsonPathStringValue("$.displayName", "English Wikipedia") .hasJsonPathNumberValue("$.documents", 1234567890) .hasJsonPathBooleanValue("$.public", true) .hasJsonPathStringValue("$.domain", "PUBLIC_INDEXES"); }
@Override protected void validateJson(final JsonContent<ViewConfig> jsonContent) { jsonContent.assertThat().hasJsonPathStringValue("protocol", "HTTPS"); jsonContent.assertThat().hasJsonPathStringValue("host", "localhost"); jsonContent.assertThat().hasJsonPathNumberValue("port", 9080); jsonContent.assertThat().hasJsonPathStringValue("viewingMode", "CONNECTOR"); jsonContent.assertThat().hasJsonPathBooleanValue("highlighting", false); }
@Override protected void validateJson(final JsonContent<QueryManipulation> jsonContent) { jsonContent.assertThat().hasJsonPathStringValue("@.server.host", "find-idol"); jsonContent.assertThat().hasJsonPathNumberValue("@.server.port", 16000); jsonContent.assertThat().hasJsonPathBooleanValue("@.expandQuery", true); jsonContent.assertThat().hasJsonPathStringValue("@.blacklist", "ISO_Blacklist"); jsonContent.assertThat().hasJsonPathBooleanValue("@.enabled", true); }
@Override protected void validateJson(final JsonContent<AnswerServerConfig> jsonContent) { jsonContent.assertThat().hasJsonPathStringValue("@.server.host", "localhost"); jsonContent.assertThat().hasJsonPathNumberValue("@.server.port", 7000); jsonContent.assertThat().hasJsonPathStringValue("@.systemNames[0]", "answerbank1"); jsonContent.assertThat().hasJsonPathBooleanValue("@.enabled", true); }
@Override protected void validateJson(final JsonContent<FieldsInfo> jsonContent) { jsonContent.assertThat().hasJsonPathValue("@.someNumberField"); jsonContent.assertThat().hasJsonPathArrayValue("@.anotherField.names", "ANOTHER_FIELD"); jsonContent.assertThat().hasJsonPathStringValue("@.anotherField.displayName", "Another Field"); jsonContent.assertThat().hasJsonPathBooleanValue("@.anotherField.advanced", true); }
@Override protected void validateJson(final JsonContent<FieldInfo<String>> jsonContent) throws IOException { jsonContent.assertThat().hasJsonPathStringValue("@.id", "someField"); jsonContent.assertThat().hasJsonPathStringValue("@.displayName", "Some Field"); jsonContent.assertThat().hasJsonPathStringValue("@.type", "STRING"); jsonContent.assertThat().hasJsonPathBooleanValue("@.advanced", false); jsonContent.assertThat().hasJsonPathArrayValue("@.names", "SomeName", "SomeOtherName"); jsonContent.assertThat().hasJsonPathStringValue("@.values[0].value", "Some value"); jsonContent.assertThat().hasJsonPathStringValue("@.values[0].displayValue", "Some Value"); }
@Override protected void validateJson(final JsonContent<HodConfig> jsonContent) { jsonContent.assertThat().hasJsonPathStringValue("@.activeIndexes[0].domain", ResourceName.WIKI_CHI.getDomain()); jsonContent.assertThat().hasJsonPathStringValue("@.activeIndexes[0].name", ResourceName.WIKI_CHI.getName()); jsonContent.assertThat().hasJsonPathBooleanValue("@.publicIndexesEnabled", true); // jsonContent.assertThat().hasJsonPathStringValue("@.apiKey", "api-key-abc"); TODO: see other to-do comment below jsonContent.assertThat().hasJsonPathStringValue("@.ssoPageGetUrl", "https://dev.havenapps.io/sso.html"); jsonContent.assertThat().hasJsonPathStringValue("@.ssoPagePostUrl", "https://dev.havenapps.io/sso"); jsonContent.assertThat().hasJsonPathStringValue("@.endpointUrl", "https://api.int.havenondemand.com"); }
@Override protected void validateJson(final JsonContent<TimeLastRefreshedWidget> jsonContent) { jsonContent.assertThat() .hasJsonPathStringValue("$.name", "Test Widget") .hasJsonPathStringValue("$.type", "TimeLastRefreshedWidget") .hasJsonPathNumberValue("$.x", 1) .hasJsonPathNumberValue("$.y", 1) .hasJsonPathNumberValue("$.width", 1) .hasJsonPathNumberValue("$.height", 1) .hasJsonPathStringValue("$.widgetSettings.dateFormat", "HH:mm z") .hasJsonPathStringValue("$.widgetSettings.timeZone", "Europe/London") .hasJsonPathStringValue("$.widgetSettings.testing", "testing"); }
@Override protected void validateJson(final JsonContent<StaticContentWidget> jsonContent) { jsonContent.assertThat() .hasJsonPathStringValue("$.name", "Test Widget") .hasJsonPathStringValue("$.type", "StaticContentWidget") .hasJsonPathNumberValue("$.x", 1) .hasJsonPathNumberValue("$.y", 1) .hasJsonPathNumberValue("$.width", 1) .hasJsonPathNumberValue("$.height", 1) .hasJsonPathStringValue("$.widgetSettings.html", "Hello World!") .hasJsonPathStringValue("$.widgetSettings.testing", "testing"); }
@Override protected void validateJson(final JsonContent<SunburstWidget> jsonContent) { jsonContent.assertThat() .hasJsonPathStringValue("$.name", "Test Widget") .hasJsonPathStringValue("$.type", "SunburstWidget") .hasJsonPathNumberValue("$.x", 1) .hasJsonPathNumberValue("$.y", 1) .hasJsonPathNumberValue("$.width", 1) .hasJsonPathNumberValue("$.height", 1) .hasJsonPathNumberValue("$.datasource.config.id", 123) .hasJsonPathStringValue("$.datasource.config.type", "QUERY") .hasJsonPathStringValue("$.widgetSettings.firstField", "CONTENT_TYPE") .hasJsonPathNumberValue("$.widgetSettings.maxLegendEntries", 5); }
@Override protected void validateJson(final JsonContent<CurrentTimeWidget> jsonContent) { jsonContent.assertThat() .hasJsonPathStringValue("$.name", "Test Widget") .hasJsonPathStringValue("$.type", "CurrentTimeWidget") .hasJsonPathNumberValue("$.x", 1) .hasJsonPathNumberValue("$.y", 1) .hasJsonPathNumberValue("$.width", 1) .hasJsonPathNumberValue("$.height", 1) .hasJsonPathStringValue("$.widgetSettings.dateFormat", "ll") .hasJsonPathStringValue("$.widgetSettings.timeFormat", "HH:mm z") .hasJsonPathStringValue("$.widgetSettings.timeZone", "Europe/London") .hasJsonPathStringValue("$.widgetSettings.testing", "testing"); }
@Override protected void validateJson(final JsonContent<TopicMapWidget> jsonContent) { jsonContent.assertThat() .hasJsonPathStringValue("$.name", "Test Widget") .hasJsonPathStringValue("$.type", "TopicMapWidget") .hasJsonPathNumberValue("$.x", 1) .hasJsonPathNumberValue("$.y", 1) .hasJsonPathNumberValue("$.width", 1) .hasJsonPathNumberValue("$.height", 1) .hasJsonPathNumberValue("$.datasource.config.id", 123) .hasJsonPathStringValue("$.datasource.config.type", "QUERY"); }
@Override protected void validateJson(final JsonContent<VideoWidget> jsonContent) { jsonContent.assertThat() .hasJsonPathStringValue("$.name", "Test Widget") .hasJsonPathStringValue("$.type", "VideoWidget") .hasJsonPathNumberValue("$.x", 1) .hasJsonPathNumberValue("$.y", 1) .hasJsonPathNumberValue("$.width", 1) .hasJsonPathNumberValue("$.height", 1) .hasJsonPathNumberValue("$.datasource.config.id", 123) .hasJsonPathStringValue("$.datasource.config.type", "QUERY"); }
@Override protected void validateJson(final JsonContent<StaticImageWidget> jsonContent) { jsonContent.assertThat() .hasJsonPathStringValue("$.name", "Test Widget") .hasJsonPathStringValue("$.type", "StaticContentWidget") .hasJsonPathNumberValue("$.x", 1) .hasJsonPathNumberValue("$.y", 1) .hasJsonPathNumberValue("$.width", 1) .hasJsonPathNumberValue("$.height", 1) .hasJsonPathStringValue("$.widgetSettings.url", "http://placehold.it/800x300") .hasJsonPathStringValue("$.widgetSettings.testing", "testing"); }
@Override protected void validateJson(final JsonContent<MapWidget> jsonContent) { jsonContent.assertThat() .hasJsonPathStringValue("$.name", "Test Widget") .hasJsonPathStringValue("$.type", "MapWidget") .hasJsonPathNumberValue("$.x", 1) .hasJsonPathNumberValue("$.y", 1) .hasJsonPathNumberValue("$.width", 1) .hasJsonPathNumberValue("$.height", 1) .hasJsonPathNumberValue("$.datasource.config.id", 123) .hasJsonPathStringValue("$.datasource.config.type", "QUERY"); }
@Override protected void validateJson(final JsonContent<SimpleWidget> jsonContent) { jsonContent.assertThat() .hasJsonPathStringValue("$.name", "Test Widget") .hasJsonPathStringValue("$.type", "StaticContentWidget") .hasJsonPathNumberValue("$.x", 1) .hasJsonPathNumberValue("$.y", 1) .hasJsonPathNumberValue("$.width", 1) .hasJsonPathNumberValue("$.height", 1) .hasJsonPathStringValue("$.displayWidgetName", "always") .hasJsonPathNumberValue("$.datasource.config.id", 123) .hasJsonPathStringValue("$.datasource.config.type", "QUERY") .hasJsonPathStringValue("$.widgetSettings.content", "Hello World!"); }
@Override protected void validateJson(final JsonContent<ResultsListWidget> jsonContent) { jsonContent.assertThat() .hasJsonPathStringValue("$.name", "Test Widget") .hasJsonPathStringValue("$.type", "ResultsListWidget") .hasJsonPathNumberValue("$.x", 1) .hasJsonPathNumberValue("$.y", 1) .hasJsonPathNumberValue("$.width", 1) .hasJsonPathNumberValue("$.height", 1) .hasJsonPathNumberValue("$.datasource.config.id", 123) .hasJsonPathStringValue("$.datasource.config.type", "QUERY"); }
@Override protected void validateJson(final JsonContent<Dashboard> jsonContent) { jsonContent.assertThat() .hasJsonPathStringValue("$.dashboardName", "My First Dashboard") .hasJsonPathBooleanValue("$.enabled", true) .hasJsonPathNumberValue("$.width", 5) .hasJsonPathNumberValue("$.height", 5) .doesNotHaveEmptyJsonPathValue("$.widgets"); }
@Override protected void validateJson(final JsonContent<CustomApplication> jsonContent) { jsonContent.assertThat() .hasJsonPathStringValue("$.applicationName", "Application name") .hasJsonPathStringValue("$.url", "http://example.url.com") .hasJsonPathStringValue("$.icon", "hp-monitor") .hasJsonPathBooleanValue("$.openInNewTab", true) .hasJsonPathBooleanValue("$.enabled", true); }
@Override protected void validateJson(final JsonContent<TrendingConfiguration> jsonContent) { jsonContent.assertThat() .hasJsonPathStringValue("$.dateField", ParametricValuesService.AUTN_DATE_FIELD) .hasJsonPathNumberValue("$.numberOfValues", 10) .hasJsonPathNumberValue("$.maxNumberOfBuckets", 20) .hasJsonPathNumberValue("$.minNumberOfBuckets", 10) .hasJsonPathNumberValue("$.defaultNumberOfBuckets", 15); }
@Override protected void validateJson(final JsonContent<UiCustomization> jsonContent) { jsonContent.assertThat().hasJsonPathBooleanValue("@.options.option3.user", false); jsonContent.assertThat().hasJsonPathStringValue("@.parametricOrder[0]", "FIELD_Y"); jsonContent.assertThat().hasJsonPathStringValue("@.parametricOrder[1]", "FIELD_X"); jsonContent.assertThat().hasJsonPathStringValue("@.specialUrlPrefixes.['application/vnd.visio']", "ms-visio:ofv|u|"); jsonContent.assertThat().hasJsonPathStringValue("@.errorCallSupportString", "Custom technical support message"); }
@Override protected void validateJson(final JsonContent<PowerPointConfig> jsonContent) { jsonContent.assertThat().hasJsonPathNumberValue("@.marginLeft", 0.1); jsonContent.assertThat().hasJsonPathNumberValue("@.marginRight", 0.1); jsonContent.assertThat().hasJsonPathNumberValue("@.marginTop", 0.1); jsonContent.assertThat().hasJsonPathNumberValue("@.marginBottom", 0.1); }
@Override protected void validateJson(final JsonContent<ExportConfig> jsonContent) { jsonContent.assertThat().hasJsonPathNumberValue("@.powerpoint.marginLeft", 0.1); jsonContent.assertThat().hasJsonPathNumberValue("@.powerpoint.marginRight", 0.1); jsonContent.assertThat().hasJsonPathNumberValue("@.powerpoint.marginTop", 0.1); jsonContent.assertThat().hasJsonPathNumberValue("@.powerpoint.marginBottom", 0.1); }
@Override protected void validateJson(final JsonContent<TemplatesConfig> jsonContent) { jsonContent.assertThat().hasJsonPathStringValue("@.searchResult[0].file", "some_file.tmpl"); jsonContent.assertThat().hasJsonPathStringValue("@.searchResult[0].triggers[0].field", "some_idol_field"); jsonContent.assertThat().hasJsonPathStringValue("@.searchResult[0].triggers[0].values[0]", "some_value"); jsonContent.assertThat().hasJsonPathStringValue("@.searchResult[0].triggers[1].field", "some_other_idol_field"); jsonContent.assertThat().hasJsonPathStringValue("@.searchResult[0].triggers[1].values[0]", "some_value"); jsonContent.assertThat().hasJsonPathStringValue("@.searchResult[0].triggers[1].values[1]", "some_other_value");jsonContent.assertThat().hasJsonPathStringValue("@.searchResult[0].file", "some_file.tmpl"); jsonContent.assertThat().hasJsonPathStringValue("@.previewPanel[0].triggers[0].field", "some_idol_field"); jsonContent.assertThat().hasJsonPathStringValue("@.previewPanel[0].triggers[0].values[0]", "some_value"); jsonContent.assertThat().hasJsonPathStringValue("@.previewPanel[0].triggers[1].field", "some_other_idol_field"); jsonContent.assertThat().hasJsonPathStringValue("@.previewPanel[0].triggers[1].values[0]", "some_value"); jsonContent.assertThat().hasJsonPathStringValue("@.previewPanel[0].triggers[1].values[1]", "some_other_value"); }
@Test public void jsonSymmetry() throws IOException { final String sampleJson = sampleJson(); final C component = json.parse(sampleJson).getObject(); final JsonContent<C> jsonContent = json.write(component); assertThat(jsonContent).isEqualToJson(sampleJson); }
@Override protected void validateJson(final JsonContent<TestConfig> json) { json.assertThat().extractingJsonPathStringValue("@.authentication.name").isEqualTo("SingleUserAuthentication"); json.assertThat().extractingJsonPathStringValue("@.authentication.method").isEqualTo(LoginTypes.SINGLE_USER); json.assertThat().extractingJsonPathStringValue("@.authentication.singleUser.username").isEqualTo("admin"); json.assertThat().extractingJsonPathStringValue("@.authentication.singleUser.hashedPassword").isEqualTo("$2a$12$uGikZXio88E.bl0A3oEe6eR.bAZxfzyifvQ4pAf6uLflCxUA55ONe"); json.assertThat().extractingJsonPathStringValue("@.authentication.defaultLogin.username").isEqualTo("admin"); json.assertThat().extractingJsonPathStringValue("@.authentication.defaultLogin.password").isNotNull(); }
@Override protected void validateJson(final JsonContent<TestConfig> json) { json.assertThat().extractingJsonPathStringValue("@.authentication.name").isEqualTo("CasAuthentication"); json.assertThat().extractingJsonPathStringValue("@.authentication.method").isEqualTo(LoginTypes.CAS); json.assertThat().extractingJsonPathStringValue("@.authentication.cas.casServerLoginUrl").isEqualTo("/login/authenticatedLogin"); json.assertThat().extractingJsonPathStringValue("@.authentication.cas.casServerUrlPrefix").isEqualTo("prefix"); json.assertThat().extractingJsonPathStringValue("@.authentication.cas.serverName").isEqualTo("test-server"); json.assertThat().extractingJsonPathStringValue("@.authentication.defaultLogin.username").isEqualTo("admin"); json.assertThat().extractingJsonPathStringValue("@.authentication.defaultLogin.password").isNotNull(); }
@Override protected void validateJson(final JsonContent<UsernameAndPassword> json) { json.assertThat().extractingJsonPathStringValue("@.username") .isEqualTo("Getafix"); json.assertThat().extractingJsonPathStringValue("@.password") .isEqualTo("Abracadabra"); }
@Override protected void validateJson(final JsonContent<CasConfig> json) { json.assertThat().extractingJsonPathStringValue("@.casServerLoginUrl") .isEqualTo("/login"); json.assertThat().extractingJsonPathStringValue("@.casServerUrlPrefix") .isEqualTo("prefix"); json.assertThat().extractingJsonPathStringValue("@.serverName") .isEqualTo("MASTER"); }
@Override protected void validateJson(final JsonContent<BCryptUsernameAndPassword> json) { json.assertThat().extractingJsonPathStringValue("@.username") .isEqualTo("Sinbad the Sailor"); json.assertThat().extractingJsonPathStringValue("@.hashedPassword") .isEqualTo("XYZ"); json.assertThat().extractingJsonPathBooleanValue("@.passwordRedacted") .isEqualTo(false); }
@Override protected void validateJson(final JsonContent<HostAndPort> json) { json.assertThat().extractingJsonPathStringValue("@.host") .isEqualTo("example.com"); json.assertThat().extractingJsonPathNumberValue("@.port") .isEqualTo(8080); }
@Override protected void validateJson(final JsonContent<QueryManipulationConfig> jsonContent) { jsonContent.assertThat().hasJsonPathStringValue("@.index", "SomeIndex"); jsonContent.assertThat().hasJsonPathStringValue("@.profile", "SomeProfile"); }
@Test public void toJson() throws IOException { final JsonContent<O> jsonContent = json.write(object); validateJson(jsonContent); }
@Override protected void validateJson(final JsonContent<TagName> jsonContent) throws IOException { jsonContent.assertThat() .hasJsonPathStringValue("$.id", "/DOCUMENT/FOO_BAR") .hasJsonPathStringValue("$.displayName", "Foo Bar"); }
@Override protected void validateJson(final JsonContent<HsodConfig> jsonContent) { jsonContent.assertThat().hasJsonPathStringValue("@.landingPageUrl", LANDING_PAGE_URL); }
@Override protected void validateJson(final JsonContent<UiCustomizationOptions> jsonContent) { jsonContent.assertThat().hasJsonPathBooleanValue("@.option2.user", false); jsonContent.assertThat().hasJsonPathBooleanValue("@.option3.user", true); jsonContent.assertThat().hasJsonPathBooleanValue("@.option3.bi", false); }