testRecord.put("map2", map); String testString = testRecord.toString(); assertFalse("Record with duplicated values results in wrong 'toString()'", testString.contains("CIRCULAR REFERENCE"));
assertNotNull(parent.toString()); // This should not fail with an infinite recursion (StackOverflowError) } catch (StackOverflowError e) { fail("StackOverflowError occurred");
private void writeIncludingSchema(final GenericData.Record value, final JsonGenerator gen) throws IOException { // Start new object. gen.writeStartObject(); // Write value gen.writeFieldName("value"); gen.writeRawValue(value.toString()); // Write schema gen.writeFieldName("schema"); gen.writeRawValue(value.getSchema().toString()); // End object gen.writeEndObject(); }
if (value != 1) throw new IOException("Cannot handle non-binary feature value (all feature values have to be 1; or just do not specify the value): " + feature.toString());
Assert.assertEquals(actualRecord.toString(), key.get(0), (actualRecord .get("username").hashCode() & Integer.MAX_VALUE) % 2); if (key.getLength() > 1) {
private void writeValueOnly(final GenericData.Record value, final JsonGenerator gen) throws IOException { gen.writeRawValue(value.toString()); } }
@Test public void shouldCreateStructWithNestedObject() { for (Entry<String, BsonValue> entry : val.entrySet()) { converter.addFieldSchema(entry, builder); } Schema finalSchema = builder.build(); Struct struct = new Struct(finalSchema); for (Entry<String, BsonValue> entry : val.entrySet()) { converter.convertRecord(entry, finalSchema, struct); } final GenericData.Record avro = (GenericData.Record)avroData.fromConnectData(finalSchema, struct); assertThat(avro.toString()).isEqualTo( "{\"_id\": 1, " + "\"s1\": {\"s1f1\": \"field1s1\", \"s1f2\": \"field2s1\"}, " + "\"s2\": {\"s2f1\": \"field1s2\", \"s2f2\": {\"in1\": 1}}}"); }