@Test public void testLoadModelFromJson() throws IOException { Resource expectedResource = loadResource("Test1.ecore"); Optional<Resource> result = resourceManager.loadResource(toFullPath("Test1.json"), resourceSet); assertTrue(result.isPresent()); assertTrue(EcoreUtil.equals(expectedResource.getContents(), result.get().getContents())); }
@SuppressWarnings("checkstyle:IllegalCatch") public Optional<Resource> loadResource(final URI resourceURI, final ResourceSet rs) { try { Resource resource = rs.getResource(resourceURI, true); resource.load(Collections.EMPTY_MAP); return Optional.of(resource); } catch (final Throwable e) { LOG.error("Could not load resource with URI: " + resourceURI); return Optional.empty(); } }
ResourceManager { @SuppressWarnings("checkstyle:IllegalCatch") public Optional<Resource> loadResource(final URI resourceURI, final ResourceSet rs) { try { Resource resource = rs.getResource(resourceURI, true); resource.load(Collections.EMPTY_MAP); return Optional.of(resource); } catch (final Throwable e) { LOG.error("Could not load resource with URI: " + resourceURI); return Optional.empty(); } } }
ResourceManager { @SuppressWarnings("checkstyle:IllegalCatch") public Optional<Resource> loadResource(final URI resourceURI, final ResourceSet rs) { try { Resource resource = rs.getResource(resourceURI, true); resource.load(Collections.EMPTY_MAP); return Optional.of(resource); } catch (final Throwable e) { LOG.error("Could not load resource with URI: " + resourceURI); return Optional.empty(); } } @Inject  ResourceManager(final Set<EPackageConfiguration> configurations); }
ResourceManager { @SuppressWarnings("checkstyle:IllegalCatch") public Optional<Resource> loadResource(final URI resourceURI, final ResourceSet rs) { try { Resource resource = rs.getResource(resourceURI, true); resource.load(Collections.EMPTY_MAP); return Optional.of(resource); } catch (final Throwable e) { LOG.error("Could not load resource with URI: " + resourceURI); return Optional.empty(); } } @Inject  ResourceManager(final Set<EPackageConfiguration> configurations); void initialize(); @SuppressWarnings("checkstyle:IllegalCatch") Optional<Resource> loadResource(final URI resourceURI, final ResourceSet rs); Optional<Resource> loadResource(final String resourceURI, final ResourceSet rs); Optional<T> loadModel(final URI resourceURI, final ResourceSet rs, final Class<T> clazz); Optional<T> loadModel(final String resourceURI, final ResourceSet rs,
      final Class<T> clazz); boolean save(final ResourceSet rs); }
ResourceManager { @SuppressWarnings("checkstyle:IllegalCatch") public Optional<Resource> loadResource(final URI resourceURI, final ResourceSet rs) { try { Resource resource = rs.getResource(resourceURI, true); resource.load(Collections.EMPTY_MAP); return Optional.of(resource); } catch (final Throwable e) { LOG.error("Could not load resource with URI: " + resourceURI); return Optional.empty(); } } @Inject  ResourceManager(final Set<EPackageConfiguration> configurations); void initialize(); @SuppressWarnings("checkstyle:IllegalCatch") Optional<Resource> loadResource(final URI resourceURI, final ResourceSet rs); Optional<Resource> loadResource(final String resourceURI, final ResourceSet rs); Optional<T> loadModel(final URI resourceURI, final ResourceSet rs, final Class<T> clazz); Optional<T> loadModel(final String resourceURI, final ResourceSet rs,
      final Class<T> clazz); boolean save(final ResourceSet rs);  }