@Override public int hashCode() { return Objects.hashCode(getEvent_initiator(), getEvent_name(), getIp(), getSession_id(), getTimestamp(), getUser_id()); }
public ReflectStandardEvent(StandardEvent event) { setEvent_initiator(event.getEventInitiator()); setEvent_name(event.getEventName()); setIp(event.getIp()); setSession_id(event.getSessionId()); setTimestamp(event.getTimestamp()); setUser_id(event.getUserId()); }
@Test public void testReflectProjectionLoad() throws IOException { Dataset<ReflectStandardEvent> original = repo.create( "ns", "reflectProjection", new DatasetDescriptor.Builder() .schema(ReflectStandardEvent.class) .build(), ReflectStandardEvent.class); DatasetWriter<ReflectStandardEvent> writer = null; try { writer = original.newWriter(); writer.write(new ReflectStandardEvent(sepEvent)); writer.write(new ReflectStandardEvent(octEvent)); writer.write(new ReflectStandardEvent(novEvent)); } finally { Closeables.close(writer, false); } View<ReflectSmallEvent> dataset = repo.load("ns", original.getName(), ReflectSmallEvent.class); Set<ReflectSmallEvent> expected = Sets.newHashSet( new ReflectSmallEvent(sepEvent), new ReflectSmallEvent(octEvent), new ReflectSmallEvent(novEvent)); assertContentEquals(expected, dataset); }
@Test public void testReflectProjectionAsType() throws IOException { Dataset<StandardEvent> original = repo.create( "ns", "reflectProjection", new DatasetDescriptor.Builder() .schema(StandardEvent.class) .build(), StandardEvent.class); DatasetWriter<ReflectStandardEvent> writer = null; try { writer = original.asType(ReflectStandardEvent.class).newWriter(); writer.write(new ReflectStandardEvent(sepEvent)); writer.write(new ReflectStandardEvent(octEvent)); writer.write(new ReflectStandardEvent(novEvent)); } finally { Closeables.close(writer, false); } final View<ReflectSmallEvent> smallEvents = original.asType(ReflectSmallEvent.class); Set<ReflectSmallEvent> expected = Sets.newHashSet( new ReflectSmallEvent(sepEvent), new ReflectSmallEvent(octEvent), new ReflectSmallEvent(novEvent)); assertContentEquals(expected, smallEvents); TestHelpers.assertThrows("Should not be able to write small events", IncompatibleSchemaException.class, new Runnable() { @Override public void run() { smallEvents.newWriter(); } }); }
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null || !Objects.equal(getClass(), obj.getClass())) { return false; } final ReflectStandardEvent other = (ReflectStandardEvent) obj; return Objects.equal(this.getEvent_initiator(), other.getEvent_initiator()) && Objects.equal(this.getEvent_name(), other.getEvent_name()) && Objects.equal(this.getIp(), other.getIp()) && Objects.equal(this.getSession_id(), other.getSession_id()) && Objects.equal(this.getTimestamp(), other.getTimestamp()) && Objects.equal(this.getUser_id(), other.getUser_id()); }