protected void expectNullGenerations(ComponentBuilderGenerator<String> gen, int n) {
   ProductWrapper<String> wrapper = new ProductWrapper<String>();
   for (int i = 0; i < n; i++) {
     wrapper = gen.generate(wrapper);
     assertNotNull(wrapper);
     assertNull(wrapper.unwrap());
   }
 }
 @SuppressWarnings("synthetic-access")
 public ProductWrapper<E> generate(ProductWrapper<E> wrapper) {
   Entity entity = createEntity("Test");
   context.setCurrentProduct(new ProductWrapper<Entity>(entity));
   if (!builder.execute((BeneratorContext) context)) return null;
   return wrapper.wrap((E) entity.get(componentName));
 }
예제 #3
0
 @Override
 public synchronized ProductWrapper<E> generate(ProductWrapper<E> wrapper) {
   if (cursor < 0) return null;
   E result = values.get(cursor);
   if (cursor < values.size() - 1) cursor++;
   else cursor = -1;
   if (logger.isDebugEnabled()) logger.debug("created: " + result);
   return wrapper.wrap(result);
 }
 @SuppressWarnings({"unchecked", "rawtypes"})
 @Override
 public void startConsuming(ProductWrapper<?> wrapper) {
   Object object = wrapper.unwrap();
   if (!(object instanceof Entity)) throw new IllegalArgumentException("Expected Entity");
   Entity entity = (Entity) object;
   Entity output = mapper.convert(entity);
   stack.push(output);
   target.startConsuming(((ProductWrapper) wrapper).wrap(output));
 }
 public ProductWrapper<Entity> generate(ProductWrapper<Entity> wrapper) {
   return wrapper.wrap(new Entity("MyEntity", descriptorProvider, "locale", locale));
 }
 public ProductWrapper<E> generate(ProductWrapper<E> wrapper) {
   this.lastMethodCall = "generate";
   return wrapper.wrap(value);
 }
 @Override
 public void finishConsuming(ProductWrapper<?> wrapper) {
   logger.info(wrapper.toString());
   target.finishConsuming(wrapper);
 }