Skip to content
This repository has been archived by the owner on Jan 22, 2019. It is now read-only.

Commit

Permalink
Add a (failing) test for #35
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Mar 9, 2016
1 parent 70b6ee7 commit 3cdf027
Show file tree
Hide file tree
Showing 4 changed files with 733 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.fasterxml.jackson.dataformat.avro.failing;

import com.fasterxml.jackson.databind.ObjectMapper;

import com.fasterxml.jackson.dataformat.avro.AvroMapper;
import com.fasterxml.jackson.dataformat.avro.AvroSchema;
import com.fasterxml.jackson.dataformat.avro.AvroTestBase;
import com.fasterxml.jackson.dataformat.avro.gen.Event35;
import com.fasterxml.jackson.dataformat.avro.gen.Event35Id;

// Test(s) for [dataformat-avro#35]
public class SerializeGeneratedTest extends AvroTestBase
{
public void testWriteGeneratedEvent() throws Exception
{
Event35 event = new Event35();
event.setPlayerCount(100);
Event35Id id = new Event35Id();
id.setFirst(10);
ObjectMapper mapper = new AvroMapper();
byte[] bytes = mapper.writer(new AvroSchema(Event35.SCHEMA$)).writeValueAsBytes(event);
assertNotNull(bytes);
}
}
187 changes: 187 additions & 0 deletions src/test/java/com/fasterxml/jackson/dataformat/avro/gen/Event35.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
/**
* Autogenerated by Avro
*
* DO NOT EDIT DIRECTLY
*/
package com.fasterxml.jackson.dataformat.avro.gen;

@SuppressWarnings("all")
@org.apache.avro.specific.AvroGenerated
public class Event35 extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord {
public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"Event\",\"namespace\":\"com.demonstration\",\"fields\":[{\"name\":\"playerCount\",\"type\":[\"null\",\"int\"]},{\"name\":\"eventID\",\"type\":[\"null\",{\"type\":\"record\",\"name\":\"EventID\",\"fields\":[{\"name\":\"description\",\"type\":[\"null\",{\"type\":\"string\",\"avro.java.string\":\"String\"}],\"default\":null},{\"name\":\"first\",\"type\":[\"null\",\"int\"],\"default\":null},{\"name\":\"second\",\"type\":[\"null\",\"int\"],\"default\":null}]}]}]}");
public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; }
private java.lang.Integer playerCount;
private Event35Id eventID;

/**
* Default constructor.
*/
public Event35() {}

/**
* All-args constructor.
*/
public Event35(java.lang.Integer playerCount, Event35Id eventID) {
this.playerCount = playerCount;
this.eventID = eventID;
}

public org.apache.avro.Schema getSchema() { return SCHEMA$; }
// Used by DatumWriter. Applications should not call.
public java.lang.Object get(int field$) {
switch (field$) {
case 0: return playerCount;
case 1: return eventID;
default: throw new org.apache.avro.AvroRuntimeException("Bad index");
}
}
// Used by DatumReader. Applications should not call.
@SuppressWarnings(value="unchecked")
public void put(int field$, java.lang.Object value$) {
switch (field$) {
case 0: playerCount = (java.lang.Integer)value$; break;
case 1: eventID = (Event35Id)value$; break;
default: throw new org.apache.avro.AvroRuntimeException("Bad index");
}
}

/**
* Gets the value of the 'playerCount' field.
*/
public java.lang.Integer getPlayerCount() {
return playerCount;
}

/**
* Sets the value of the 'playerCount' field.
* @param value the value to set.
*/
public void setPlayerCount(java.lang.Integer value) {
this.playerCount = value;
}

/**
* Gets the value of the 'eventID' field.
*/
public Event35Id getEventID() {
return eventID;
}

/**
* Sets the value of the 'eventID' field.
* @param value the value to set.
*/
public void setEventID(Event35Id value) {
this.eventID = value;
}

/** Creates a new Event RecordBuilder */
public static Event35.Builder newBuilder() {
return new Event35.Builder();
}

/** Creates a new Event RecordBuilder by copying an existing Builder */
public static Event35.Builder newBuilder(Event35.Builder other) {
return new Event35.Builder(other);
}

/** Creates a new Event RecordBuilder by copying an existing Event instance */
public static Event35.Builder newBuilder(Event35 other) {
return new Event35.Builder(other);
}

/**
* RecordBuilder for Event instances.
*/
public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase<Event35>
implements org.apache.avro.data.RecordBuilder<Event35> {

private java.lang.Integer playerCount;
private Event35Id eventID;

/** Creates a new Builder */
private Builder() {
super(Event35.SCHEMA$);
}

/** Creates a Builder by copying an existing Builder */
private Builder(Event35.Builder other) {
super(other);
}

/** Creates a Builder by copying an existing Event instance */
private Builder(Event35 other) {
super(Event35.SCHEMA$);
if (isValidValue(fields()[0], other.playerCount)) {
this.playerCount = data().deepCopy(fields()[0].schema(), other.playerCount);
fieldSetFlags()[0] = true;
}
if (isValidValue(fields()[1], other.eventID)) {
this.eventID = data().deepCopy(fields()[1].schema(), other.eventID);
fieldSetFlags()[1] = true;
}
}

/** Gets the value of the 'playerCount' field */
public java.lang.Integer getPlayerCount() {
return playerCount;
}

/** Sets the value of the 'playerCount' field */
public Event35.Builder setPlayerCount(java.lang.Integer value) {
validate(fields()[0], value);
this.playerCount = value;
fieldSetFlags()[0] = true;
return this;
}

/** Checks whether the 'playerCount' field has been set */
public boolean hasPlayerCount() {
return fieldSetFlags()[0];
}

/** Clears the value of the 'playerCount' field */
public Event35.Builder clearPlayerCount() {
playerCount = null;
fieldSetFlags()[0] = false;
return this;
}

/** Gets the value of the 'eventID' field */
public Event35Id getEventID() {
return eventID;
}

/** Sets the value of the 'eventID' field */
public Event35.Builder setEventID(Event35Id value) {
validate(fields()[1], value);
this.eventID = value;
fieldSetFlags()[1] = true;
return this;
}

/** Checks whether the 'eventID' field has been set */
public boolean hasEventID() {
return fieldSetFlags()[1];
}

/** Clears the value of the 'eventID' field */
public Event35.Builder clearEventID() {
eventID = null;
fieldSetFlags()[1] = false;
return this;
}

@Override
public Event35 build() {
try {
Event35 record = new Event35();
record.playerCount = fieldSetFlags()[0] ? this.playerCount : (java.lang.Integer) defaultValue(fields()[0]);
record.eventID = fieldSetFlags()[1] ? this.eventID : (Event35Id) defaultValue(fields()[1]);
return record;
} catch (Exception e) {
throw new org.apache.avro.AvroRuntimeException(e);
}
}
}
}
Loading

0 comments on commit 3cdf027

Please sign in to comment.