JsonSchemaLoader { public Schema loadSchema(final String actionName) { final String schemaFile = format(SCHEMA_LOCATION_PATTERN, actionName); return load(schemaFile); }  Schema loadSchema(final String actionName);  }
@Test public void shouldReturnSchemaFromClasspath() { final Schema expectedSchema = mock(Schema.class); when(schemaCatalogResolver.loadSchema(any(JSONObject.class))).thenReturn(expectedSchema); final Schema actualSchema = loader.loadSchema("test-schema"); assertThat(actualSchema, is(expectedSchema)); }
@Test public void shouldLogSchemaName() throws Exception { loader.loadSchema("test-schema"); verify(logger).trace("Loading schema {}", "/json/schema/test-schema.json"); }
@Test public void shouldThrowExceptionIfSchemaNotFound() { expectedException.expect(SchemaLoadingException.class); expectedException.expectMessage("Unable to load JSON schema /json/schema/non-existent.json from classpath"); loader.loadSchema("non-existent"); }
@Test public void shouldThrowExceptionIfSchemaMalformed() { expectedException.expect(SchemaLoadingException.class); expectedException.expectMessage("Unable to load JSON schema /json/schema/malformed-schema.json from classpath"); loader.loadSchema("malformed-schema"); }