private void loadFromTextResource(final Field field, final CoreTestRule rule,
final CreationContext context, final String resourcePath)
{
final String packageName = rule.getClass().getPackage().getName().replaceAll("\\.", "/");
final String completeName = String.format("%s/%s", packageName, resourcePath);
final ClassResource resource = new ClassResource(completeName);
FileSuffix.suffixFor(completeName).ifPresent(suffix ->
{
if (suffix == FileSuffix.GZIP)
{
resource.setDecompressor(Decompressor.GZIP);
}
});
try
{
field.set(rule, new TextAtlasBuilder().read(resource));
}
catch (IllegalArgumentException | IllegalAccessException e)
{
throw new CoreException("Error loading from text resource {}", resourcePath, e);
}
}