All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.regnosys.rosetta.generators.test.TestUtil Maven / Gradle / Ivy

There is a newer version: 11.22.0
Show newest version
package com.regnosys.rosetta.generators.test;

import com.google.inject.Inject;
import com.google.inject.Provider;
import com.regnosys.rosetta.tests.util.ModelHelper;
import java.io.File;
import java.io.FileFilter;
import java.nio.file.Files;
import java.util.List;
import org.eclipse.xtext.resource.XtextResourceSet;
import org.eclipse.xtext.xbase.lib.Conversions;
import org.eclipse.xtext.xbase.lib.Exceptions;
import org.eclipse.xtext.xbase.lib.Extension;
import org.eclipse.xtext.xbase.lib.Functions.Function1;
import org.eclipse.xtext.xbase.lib.IterableExtensions;
import org.eclipse.xtext.xbase.lib.ListExtensions;

@SuppressWarnings("all")
public class TestUtil {
  @Inject
  private Provider resourceSetProvider;

  @Inject
  @Extension
  private ModelHelper _modelHelper;

  public List getRosettaFileContents(final List srcPaths) {
    final Function1 _function = (String it) -> {
      return new File(it);
    };
    final Function1> _function_1 = (File it) -> {
      final FileFilter _function_2 = (File it_1) -> {
        return it_1.getName().endsWith(".rosetta");
      };
      return IterableExtensions.toList(((Iterable)Conversions.doWrapArray(it.listFiles(_function_2))));
    };
    final Function1 _function_2 = (File it) -> {
      try {
        return Files.readAllBytes(it.toPath());
      } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
      }
    };
    final Function1 _function_3 = (byte[] it) -> {
      return new String(it);
    };
    return IterableExtensions.toList(IterableExtensions.map(IterableExtensions.map(IterableExtensions.flatMap(ListExtensions.map(srcPaths, _function), _function_1), _function_2), _function_3));
  }

  public XtextResourceSet parseAllRosettaFiles(final List srcPaths) {
    this._modelHelper.parseRosetta(((CharSequence[])Conversions.unwrapArray(this.getRosettaFileContents(srcPaths), CharSequence.class)));
    return this.resourceSetProvider.get();
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy