@Test public void testAsyncAttributeNotOverwritten() throws Exception { final JobContext ctx = this.mockery.mock(JobContext.class); this.mockery.checking(new Expectations() {{ allowing(ctx).getAttribute(AsyncContext.ASYNC); will(returnValue("X")); }}); final JobContextDecoratorImpl decorator = new JobContextDecoratorImpl(ctx, Collections.singletonMap(AsyncContext.ASYNC, AsyncContext.ASYNC)); assertEquals("X", decorator.getAttribute(AsyncContext.ASYNC)); }
@Override public <T> T getAttribute(final String name) { if (this.additionalAttributes.containsKey(name)) { return (T) this.additionalAttributes.get(name); } return (T) wrapped.getAttribute(name); }
JobContextDecoratorImpl implements JobContext { @Override public <T> T getAttribute(final String name) { if (this.additionalAttributes.containsKey(name)) { return (T) this.additionalAttributes.get(name); } return (T) wrapped.getAttribute(name); } }
JobContextDecoratorImpl implements JobContext { @Override public <T> T getAttribute(final String name) { if (this.additionalAttributes.containsKey(name)) { return (T) this.additionalAttributes.get(name); } return (T) wrapped.getAttribute(name); } JobContextDecoratorImpl(final JobContext wrapped, final Map<String, Object> additionalAttributes); }
JobContextDecoratorImpl implements JobContext { @Override public <T> T getAttribute(final String name) { if (this.additionalAttributes.containsKey(name)) { return (T) this.additionalAttributes.get(name); } return (T) wrapped.getAttribute(name); } JobContextDecoratorImpl(final JobContext wrapped, final Map<String, Object> additionalAttributes); @Override JobStatusListener getListener(); @Override boolean isAsync(); @Override T getAttribute(final String name); @Override Map<String, Object> getAttributes(); }
JobContextDecoratorImpl implements JobContext { @Override public <T> T getAttribute(final String name) { if (this.additionalAttributes.containsKey(name)) { return (T) this.additionalAttributes.get(name); } return (T) wrapped.getAttribute(name); } JobContextDecoratorImpl(final JobContext wrapped, final Map<String, Object> additionalAttributes); @Override JobStatusListener getListener(); @Override boolean isAsync(); @Override T getAttribute(final String name); @Override Map<String, Object> getAttributes();  }