DevfileParser { public DevfileImpl parseJson(String devfileContent) throws DevfileFormatException { try { return parse(devfileContent, jsonMapper, emptyMap()); } catch (OverrideParameterException e) { throw new RuntimeException(e.getMessage()); } } @Inject  DevfileParser(
      DevfileSchemaValidator schemaValidator, DevfileIntegrityValidator integrityValidator); @VisibleForTesting  DevfileParser(
      DevfileSchemaValidator schemaValidator,
      DevfileIntegrityValidator integrityValidator,
      ObjectMapper yamlMapper,
      ObjectMapper jsonMapper); DevfileImpl parseYaml(String devfileContent); DevfileImpl parseYaml(String devfileContent, Map<String, String> overrideProperties); DevfileImpl parseJson(String devfileContent); DevfileImpl parseJson(String devfileContent, Map<String, String> overrideProperties); void resolveReference(DevfileImpl devfile, FileContentProvider fileContentProvider);  }
@Test( expectedExceptions = DevfileException.class, expectedExceptionsMessageRegExp = "Unable to parse Devfile - provided source is empty") public void shouldThrowDevfileExceptionWhenEmptyObjectProvided() throws Exception { devfileParser.parseJson("{}"); }
@Test( expectedExceptions = DevfileException.class, expectedExceptionsMessageRegExp = "Unable to parse Devfile - provided source is empty") public void shouldThrowDevfileExceptionWhenEmptySourceProvided() throws Exception { devfileParser.parseJson(""); }
@Test( expectedExceptions = DevfileFormatException.class, expectedExceptionsMessageRegExp = "non valid") public void shouldThrowExceptionWhenErrorOccurredDuringDevfileParsing() throws Exception { JsonProcessingException jsonException = mock(JsonProcessingException.class); when(jsonException.getMessage()).thenReturn("non valid"); when(jsonMapper.readTree(anyString())).thenReturn(devfileJsonNode); doThrow(jsonException).when(jsonMapper).treeToValue(any(), any()); devfileParser.parseJson(DEVFILE_YAML_CONTENT); }