@Test public void testDefaultMapping() { generator.setFillRate(1.0) .setMaxCollectionItems(16); OptionalFields expected = generator.generate(OptionalFields.kDescriptor) .mutate() .setId(1234) .setTimestampS((int) clock.instant().getEpochSecond()) .setTimestampMs(clock.instant().getEpochSecond() * 1000) .build(); OptionalFields empty = OptionalFields.builder() .setId(2345) .build(); try (Handle handle = db.getDBI().open()) { INSERTER.execute(handle, expected, empty); OptionalFields val = handle.createQuery("SELECT * FROM mappings.default_mappings WHERE id = :id") .bind("id", expected.getId()) .map(ProvidenceJdbi.toMessage(OptionalFields.kDescriptor, ProvidenceJdbi.columnsFromAllFields(), ProvidenceJdbi.withColumn("compact", MESSAGE), ProvidenceJdbi.withColumn("other_message", CLOB_MESSAGE))) .first(); OptionalFields val2 = handle.createQuery("SELECT * FROM mappings.default_mappings WHERE id = :id") .bind("id", empty.getId()) .map(ProvidenceJdbi.toMessage(OptionalFields.kDescriptor, ProvidenceJdbi.columnsFromAllFields(), ProvidenceJdbi.withColumn("compact", MESSAGE), ProvidenceJdbi.withColumn("other_message", CLOB_MESSAGE))) .first(); assertThat(val, is(equalToMessage(expected))); assertThat(val2, is(equalToMessage(empty))); } }
@SafeVarargs public final int execute(Handle handle, M... items) { return execute(handle, ImmutableList.copyOf(items)); }
MessageInserter { @SafeVarargs public final int execute(Handle handle, M... items) { return execute(handle, ImmutableList.copyOf(items)); } }
MessageInserter { @SafeVarargs public final int execute(Handle handle, M... items) { return execute(handle, ImmutableList.copyOf(items)); } private  MessageInserter(String queryPrefix,
                            String querySuffix,
                            List<String> columnOrder,
                            Map<String, F> columnToFieldMap,
                            Map<String, Integer> columnTypeMap); }
MessageInserter { @SafeVarargs public final int execute(Handle handle, M... items) { return execute(handle, ImmutableList.copyOf(items)); } private  MessageInserter(String queryPrefix,
                            String querySuffix,
                            List<String> columnOrder,
                            Map<String, F> columnToFieldMap,
                            Map<String, Integer> columnTypeMap); @SafeVarargs final int execute(Handle handle, M... items); int execute(Handle handle, Collection<M> items); }
MessageInserter { @SafeVarargs public final int execute(Handle handle, M... items) { return execute(handle, ImmutableList.copyOf(items)); } private  MessageInserter(String queryPrefix,
                            String querySuffix,
                            List<String> columnOrder,
                            Map<String, F> columnToFieldMap,
                            Map<String, Integer> columnTypeMap); @SafeVarargs final int execute(Handle handle, M... items); int execute(Handle handle, Collection<M> items);  }