EmitAPIImpl implements EmitAPI, Runnable { @Override public Emit create(EmitSpec spec) throws InvalidAdviceException { EmitImpl impl; if (spec.hasTupleSpec()) { impl = new EmitTuples(spec, spec.getTupleSpec()); } else if (spec.hasGroupBySpec()) { impl = new EmitGrouped(spec, spec.getGroupBySpec()); } else { throw new InvalidAdviceException(spec, "EmitSpec lacks tuple or groupby spec"); } emits.add(impl); return impl; } EmitAPIImpl(long reportInterval, String reportsTopic, boolean emitIfNoResults); @Override Emit create(EmitSpec spec); @Override void destroy(Emit emit); @Override void run(); final long reportInterval; final String reportsTopic; final boolean emitIfNoResults; }
@Test public void testInvalidEmit() { ByteString out1 = ByteString.copyFromUtf8("output query 1"); EmitSpec emitspec1 = EmitSpec.newBuilder().setOutputId(out1).build(); EmitAPIImpl impl = new EmitAPIImpl(1000, "topic", true); try { Emit created = impl.create(emitspec1); fail(); } catch (InvalidAdviceException e) { } }