LINQ Reporting Engine - build report with custom type as datasource (Java)

I’m trying to use build report based on this example from you’re github.

I created following test (with JUnit 5):

@ParameterizedTest
@ValueSource(strings = {
    "<<[test.name]>>",
    "<<[test.getName()]>>",
    "<<[name]>>",
    "<<[getName()]>>",
    "<<[test.activities.count()]>>",
    "<<[test.activities.Count()]>>",
    "<<[test.activities.first()]>>",
    "<<[test.activities.first().activities_Text]>>",
    "<<[test.getActivities().first().activities_Text]>>",
    "<<[test.addresses.first().city]>>",
    "<<[test.getAddresses().first().city]>>",
})
void shouldPassWithoutErrorForPojo(String expression) throws Exception {
    Document doc = new Document();
    DocumentBuilder builder = new DocumentBuilder(doc);
    builder.write(expression);

    var reportingEngine = new ReportingEngine();
    reportingEngine.buildReport(doc, new TestData(), "test");

}

public class TestData {

    public String name;
    public List<String> activities;
    public List<Address> addresses;

    public TestData() {
    name = "David";
    activities = List.of("Cooking", "Computer Games");
    addresses = List.of(new Address("1st street", "New Town"));
    }

    public String getName() {
    return name;
    }

    public List<String> getActivities() {
    return activities;
    }

    public List<Address> getAddresses() {
    return addresses;
    }

    public class Address {

    private String street;
    private String city;

    public Address(String street, String city) {
        this.street = street;
        this.city = city;
    }

    public String getStreet() {
        return street;
    }

    public String getCity() {
        return city;
    }
    }
}

Unfortunatelly from all of this cases I’m testing I’m getting errors with message like the following one:

java.lang.IllegalStateException: An error has been encountered at the end of expression 'test.name]>'. Can not get the value of member 'name' on type 'class pl.example.templates.ReportingEngineTest$TestData'.

In other words, I cannot access data in provided object either by field or method.
What am I doing wrong?

@pandamian It looks like the reason of the problem is reflection optimization. Please try disabling it before building the report:

ReportingEngine.setUseReflectionOptimization(false);
1 Like

It seems that it fix the problem.

1 Like

The issues you have found earlier (filed as WORDSJAVA-2710) have been fixed in this Aspose.Words for Java 22.12 update.