While testing the pipeline I got this error even the error log shows that the objects are equal:
public void testGenerateUserPageViews() throws Exception{
final PCollection<SessionModel> input = p.apply(Create.of(SESSION_MODEL));
final PCollection<UserPageViews> output = input.apply(ParDo.of(new GenerateUserPageViews()));
PAssert.that(output).containsInAnyOrder(USER_PAGEVIEWS);
p.run().waitUntilFinish();
}
java.lang.AssertionError: ParDo(GenerateUserPageViews)/ParMultiDo(GenerateUserPageViews).output:
Expected: iterable over [<com.userprofile.models.UserPageViews@e1688b19>] in any order
but: Not matched: <com.userprofile.models.UserPageViews@e1688b19>
at org.apache.beam.sdk.testing.PAssert$PAssertionSite.capture(PAssert.java:174)
at org.apache.beam.sdk.testing.PAssert.that(PAssert.java:416)
at org.apache.beam.sdk.testing.PAssert.that(PAssert.java:408)
at
CodePudding user response:
I would guess that com.userprofile.models.UserPageViews
does not have a fully implemented equals
or hashCode
method.
CodePudding user response:
The solution is that I replace String variable with "" value in place of null. But I still don't understand why the object reference are the same in both cases.