0

I need to assign values to SelectResults and use this for JUnit purposes.

I could assign StructImpl values but could not do it for SelectResults.

String[] FieldNames;
Object[] FieldValues;
StructImpl s1;
List<StructImpl> structImplList = new ArrayList<StructImpl>();

FieldNames = new String[] {"cpcaAttributeId", "cpcaAttributeName", "cpcmCatalogId", "cpcmCatalogDesc" };

FieldValues = new Object[] {"ATTRIBUTE_02", "LONGDESCRIPTION", "COMACTIVITY", "Company activities" };
s1 = new StructImpl(new StructTypeImpl(FieldNames),new Object[] {"ATTRIBUTE_02","LO","NGDESCRIPTION","COMACTIVITY", "Company activities"});
structImplList.add(s1);
John Blum
  • 7,381
  • 1
  • 20
  • 30
user1479469
  • 45
  • 3
  • 9

1 Answers1

0

What are you trying to test?

The GemFire/Geode SelectResults type is an interface, and therefore, is ideal for mocking using a framework like Mockito.

You can see such an example of this in the SDG test suite itself, here.

If you are using the GemFire/Geode API directly to construct and execute a query (i.e. you are not using SDG's GemfireTemplate or the SD[G] Repository abstraction), then you mostly want to mock the interface of the Query objects and not the behavior.

In general, when Unit Testing with Mocks, your application should assume that GemFire/Geode does the right thing, as stated in it's contract (Javadoc). With Integration Tests, it is fair game to test with live objects and actual behavior. This is important when asserting that your OQL queries are well-formed and such, or that a framework like SDG is properly converting objects to the expected type, which is especially true when using the SD[G] Repository abstraction.

Anyway, most of the time you would be mocking the SelectResults.<T>asList() method returning the applications objects as expected by your application.

Regardless, I am not quite certain what your ask is. So, if you could share a repository/example with your tests, perhaps that would shed some light on the subject.

If not, hope this gives you some ideas.

Thanks!

John Blum
  • 7,381
  • 1
  • 20
  • 30