Revision 50985
Added by Claudio Atzori about 6 years ago
modules/dnet-mapreduce-jobs/trunk/src/test/java/eu/dnetlib/data/mapreduce/hbase/broker/EventFactoryTest.java | ||
---|---|---|
2 | 2 |
|
3 | 3 |
import java.util.UUID; |
4 | 4 |
|
5 |
import eu.dnetlib.data.mapreduce.hbase.broker.model.EventWrapper; |
|
5 | 6 |
import org.apache.commons.lang.math.RandomUtils; |
6 | 7 |
import org.apache.commons.logging.Log; |
7 | 8 |
import org.apache.commons.logging.LogFactory; |
... | ... | |
73 | 74 |
|
74 | 75 |
event.setPayload(payload.toJSON()); |
75 | 76 |
|
76 |
log.info("event: " + event.toString()); |
|
77 |
log.info("event message: " + event.toString());
|
|
77 | 78 |
|
79 |
final EventWrapper wrapper = new EventWrapper(event, "test"); |
|
80 |
|
|
81 |
log.info("broker event: " + wrapper.asBrokerEvent().toJson()); |
|
82 |
|
|
78 | 83 |
} |
79 | 84 |
|
80 | 85 |
private Qualifier.Builder q(final String classid, final String scheme) { |
modules/dnet-mapreduce-jobs/trunk/src/main/java/eu/dnetlib/data/mapreduce/hbase/broker/model/Event.java | ||
---|---|---|
4 | 4 |
import java.util.Map; |
5 | 5 |
|
6 | 6 |
import com.google.gson.Gson; |
7 |
import com.google.gson.GsonBuilder; |
|
7 | 8 |
|
8 | 9 |
public class Event { |
9 | 10 |
|
11 |
public static final String DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"; |
|
12 |
|
|
10 | 13 |
private String eventId; |
11 | 14 |
|
12 | 15 |
private String producerId; |
... | ... | |
103 | 106 |
} |
104 | 107 |
|
105 | 108 |
public String toJson() { |
106 |
return new Gson().toJson(this); |
|
109 |
|
|
110 |
final Gson gson = new GsonBuilder() |
|
111 |
.setDateFormat(DATE_FORMAT).create(); |
|
112 |
|
|
113 |
return gson.toJson(this); |
|
107 | 114 |
} |
108 | 115 |
} |
Also available in: Unified diff
force gson to serialise dates in a format that can be undrestood by ElasticSearch