BaggageAPIImpl implements BaggageAPI { @Override public Pack create(PackSpec spec) throws InvalidAdviceException { if (spec.hasFilterSpec()) { return new BagFiltered(spec.getBagId(), spec.getFilterSpec(), ACTIVE, ARCHIVE); } else if (spec.hasGroupBySpec()) { return new BagGrouped(spec.getBagId(), spec.getGroupBySpec(), ACTIVE, ARCHIVE); } else if (spec.hasTupleSpec()) { return new BagTuples(spec.getBagId(), spec.getTupleSpec(), ACTIVE, ARCHIVE); } else { throw new InvalidAdviceException(spec, "Bag type not specified"); } } BaggageAPIImpl(Namespace<ByteString, ByteString> active, Namespace<ByteString, ByteString> archive);  BaggageAPIImpl(); static long random(); @Override Pack create(PackSpec spec); @Override Unpack create(UnpackSpec spec); static final Random r; static final ByteString PT_ACTIVE_NAMESPACE; static final ByteString PT_ARCHIVE_NAMESPACE; final Namespace<ByteString, ByteString> ACTIVE; }
@Test public void testInvalidAdvice() { BaggageAPIImplForTest baggage = new BaggageAPIImplForTest(); try { Pack pack = baggage.create(PackSpec.newBuilder().setBagId(ByteString.copyFromUtf8("test")).build()); fail(); } catch (InvalidAdviceException e) { } try { Unpack unpack = baggage.create(UnpackSpec.newBuilder().setBagId(ByteString.copyFromUtf8("test")).build()); fail(); } catch (InvalidAdviceException e) { } }