com.regnosys.rosetta.generators.test.TestUtil.xtend Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of test-helper Show documentation
Show all versions of test-helper Show documentation
Test infrastructure for Rosetta code generators
package com.regnosys.rosetta.generators.test
import java.util.List
import java.io.File
import java.nio.file.Files
import com.google.inject.Inject
import com.google.inject.Provider
import org.eclipse.xtext.resource.XtextResourceSet
import com.regnosys.rosetta.tests.util.ModelHelper
class TestUtil {
@Inject
Provider resourceSetProvider
@Inject
extension ModelHelper
def getRosettaFileContents(List srcPaths) {
return srcPaths
.map[new File(it)]
.flatMap[listFiles[it.name.endsWith('.rosetta')].toList]
.map[Files.readAllBytes(toPath)]
.map[new String(it)]
.toList
}
def parseAllRosettaFiles(List srcPaths) {
srcPaths.rosettaFileContents.parseRosetta
return resourceSetProvider.get
}
}