I'm not sure if this is a known issue but i'm getting a weird behavior.
Here's the snippet of code i'm using to mock things out.
Mock Data:
private MockResult[] getPartnerDataFeedData() {
MockResult[] mock = new MockResult[1];
PartnerDataFeedRecord record =
getDSLContext().newRecord(INTEGRATION.PARTNER_DATA_FEED);
record.setPartnerDataFeedId(1234L);
record.setIntegrationDataTypeName("EVENT_LEVEL_IMPRESSIONS");
record.setPartnerDataFeedName("Event Leve Impressions");
record.setPartnerId(4321L);
record.setProviderId(4L);
record.setSiteActivityFeedId(56L);
record.setTpasnsId(27L);
record.setLastModifiedById(6244L);
record.setLastModificationDate(new Timestamp(System.currentTimeMillis()));
record.setType("PARTNER");
Result<PartnerDataFeedRecord> result =
getDSLContext().newResult(INTEGRATION.PARTNER_DATA_FEED);
result.add(record);
mock[0] = new MockResult(result.size(), result);
return mock;
}
Impl:
public PartnerDataFeed getDataFeedById(final long dataFeedId) {
PartnerDataFeedRecord o =
dslContext.select(INTEGRATION.PARTNER_DATA_FEED.PARTNER_DATA_FEED_ID,
INTEGRATION.PARTNER_DATA_FEED.INTEGRATION_DATA_TYPE_NAME,
INTEGRATION.PARTNER_DATA_FEED.PARTNER_DATA_FEED_NAME,
INTEGRATION.PARTNER_DATA_FEED.PARTNER_ID,
INTEGRATION.PARTNER_DATA_FEED.PROVIDER_ID,
INTEGRATION.PARTNER_DATA_FEED.SITE_ACTIVITY_FEED_ID,
INTEGRATION.PARTNER_DATA_FEED.TPASNS_ID,
INTEGRATION.PARTNER_DATA_FEED.LAST_MODIFIED_BY_ID,
INTEGRATION.PARTNER_DATA_FEED.LAST_MODIFICATION_DATE,
INTEGRATION.PARTNER_DATA_FEED.TYPE)
.from(INTEGRATION.PARTNER_DATA_FEED)
.where(INTEGRATION.PARTNER_DATA_FEED.PARTNER_DATA_FEED_ID.eq(dataFeedId))
.fetchOneInto(PartnerDataFeedRecord.class);
return o.into(PartnerDataFeed.class);
}
I'm inspecting both the Record and Pojo and both have really peculiar
behavior.
Here's the result i'm getting:
[image: Screen Shot 2019-01-30 at 5.12.27 PM.png]
The values are all kinds of jumbled up. "4321" was the partnerId, now it's
assigned to the IntegrationDataTypeName. The TpasNsId is supposed to be
27, instead it's assigned to FeedName, the type is supposed to be PARTNER
instead it's a timestamp.
Here's my driving logic...
@Override
public MockResult[] execute(MockExecuteContext ctx) {
// You might need a DSLContext to create org.jooq.Result and
org.jooq.Record objects
DSLContext create = DSL.using(SQLDialect.POSTGRES);
MockResult[] mock = new MockResult[1];
// The execute context contains SQL string(s), bind values, and
other meta-data
String sql = ctx.sql().toUpperCase();
for(MockTestData entry : patternMatchList) {
Pattern identityPattern = entry.getIdentityPattern();
Pattern validation = entry.getValidationPattern();
String errorMessage = entry.getErrorMessage();
//identify query
if(identityPattern.matcher(sql).matches()) {
//validate
assertTrue(validation.matcher(sql).matches(), errorMessage);
mock = entry.getMockResults();
}
}
return mock;
}
This returns the Mock data that was created in the first code snippet.
Any ideas?
I'm using Jooq 3.10.6 with Postgres Syntax (Though it's mocked so in theory
should not matter too much).
Any thoughts?
--
Thank you
Samir Faci
https://keybase.io/csgeek
--
You received this message because you are subscribed to the Google Groups "jOOQ
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.