Java Code Examples for io.dropwizard.jersey.validation.Validators#newValidator()
The following examples show how to use
io.dropwizard.jersey.validation.Validators#newValidator() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ComplianceToolModeTest.java From verify-service-provider with MIT License | 5 votes |
@Test public void testThatConfigurationArgumentCanBeParsed() throws ArgumentParserException, JsonProcessingException { ComplianceToolMode complianceToolMode = new ComplianceToolMode(objectMapper, Validators.newValidator(), mock(VerifyServiceProviderApplication.class)); final Subparser subparser = createParser(); complianceToolMode.configure(subparser); String suppliedHost = "127.0.0.1"; String suppliedCallbackUrl = HTTP_LOCALHOST_8080; int suppliedTimeout = 6; MatchingDataset suppliedMatchingDataset = new MatchingDatasetBuilder().build(); int suppliedPort = 0; Namespace namespace = subparser.parseArgs( createArguments( "--url", suppliedCallbackUrl, "-d", objectMapper.writeValueAsString(suppliedMatchingDataset), "--host", suppliedHost, "-p", String.valueOf(suppliedPort), "-t", String.valueOf(suppliedTimeout) ) ); MatchingDataset actual = namespace.get(ComplianceToolMode.IDENTITY_DATASET); assertThat(actual).isEqualToComparingFieldByFieldRecursively(suppliedMatchingDataset); String url = namespace.get(ComplianceToolMode.ASSERTION_CONSUMER_URL); assertThat(url).isEqualTo(suppliedCallbackUrl); Integer timeout = namespace.get(ComplianceToolMode.TIMEOUT); assertThat(timeout).isEqualTo(suppliedTimeout); Integer port = namespace.get(ComplianceToolMode.PORT); assertThat(port).isEqualTo(suppliedPort); String host = namespace.get(ComplianceToolMode.BIND_HOST); assertThat(host).isEqualTo(suppliedHost); }
Example 2
Source File: ComplianceToolModeTest.java From verify-service-provider with MIT License | 5 votes |
@Test public void testThatThereAreDefaults() throws Exception { ComplianceToolMode complianceToolMode = new ComplianceToolMode(objectMapper, Validators.newValidator(), mock(VerifyServiceProviderApplication.class)); final Subparser subparser = createParser(); complianceToolMode.configure(subparser); Namespace namespace = subparser.parseArgs(noArguments()); MatchingDataset actual = namespace.get(ComplianceToolMode.IDENTITY_DATASET); String expectedMatchingDataset = FixtureHelpers.fixture("default-test-identity-dataset.json"); String receivedMatchingDataset = objectMapper.writeValueAsString(actual); assertThat(new JSONObject(receivedMatchingDataset)) .isEqualToComparingFieldByFieldRecursively(new JSONObject(expectedMatchingDataset)); String url = namespace.get(ComplianceToolMode.ASSERTION_CONSUMER_URL); assertThat(url).isEqualTo(ComplianceToolMode.DEFAULT_CONSUMER_URL); Integer timeout = namespace.get(ComplianceToolMode.TIMEOUT); assertThat(timeout).isEqualTo(ComplianceToolMode.DEFAULT_TIMEOUT); Integer port = namespace.get(ComplianceToolMode.PORT); assertThat(port).isEqualTo(ComplianceToolMode.DEFAULT_PORT); String host = namespace.get(ComplianceToolMode.BIND_HOST); assertThat(host).isEqualTo(ComplianceToolMode.DEFAULT_HOST); }
Example 3
Source File: ComplianceToolModeTest.java From verify-service-provider with MIT License | 5 votes |
@Test public void itWillErrorIfTheMatchingDatasetIsNotValid() throws ArgumentParserException { ComplianceToolMode complianceToolMode = new ComplianceToolMode(objectMapper, Validators.newValidator(), mock(VerifyServiceProviderApplication.class)); final Subparser subparser = createParser(); complianceToolMode.configure(subparser); assertThatThrownBy(()-> subparser.parseArgs(createArguments("-d", "{}"))) .isInstanceOf(ArgumentParserException.class) .hasMessageStartingWith("Matching Dataset argument was not valid:"); }
Example 4
Source File: UpgradeCommand.java From irontest with Apache License 2.0 | 5 votes |
private IronTestConfiguration getIronTestConfiguration(String ironTestHome) throws IOException, ConfigurationException { Path configYmlFilePath = Paths.get(ironTestHome, "config.yml"); ObjectMapper objectMapper = Jackson.newObjectMapper(); Validator validator = Validators.newValidator(); YamlConfigurationFactory<IronTestConfiguration> factory = new YamlConfigurationFactory<>(IronTestConfiguration.class, validator, objectMapper, "dw"); IronTestConfiguration configuration = factory.build(configYmlFilePath.toFile()); return configuration; }