@Test public void list_returned_from_multiple_request_is_copied_to_array() { Integer[] array = new Integer[]{1, 2, 3}; List<Integer> list = Arrays.asList(1, 2, 3); when(mockSpecimenContext.resolve(any(MultipleRequest.class))).thenReturn(list); Integer[] result = (Integer[])this.arrayRelay.create(SpecimenType.of(Integer[].class), mockSpecimenContext); assertArrayEquals(array, result); }
@Override public Object create(Object request, SpecimenContext context) { if (!(request instanceof SpecimenType)) { return new NoSpecimen(); } SpecimenType specimenType = (SpecimenType)request; if(!specimenType.getRawType().isArray()) { return new NoSpecimen(); } Class clazz = specimenType.getRawType(); return buildArray(clazz, context); }
ArrayRelay implements SpecimenBuilder { @Override public Object create(Object request, SpecimenContext context) { if (!(request instanceof SpecimenType)) { return new NoSpecimen(); } SpecimenType specimenType = (SpecimenType)request; if(!specimenType.getRawType().isArray()) { return new NoSpecimen(); } Class clazz = specimenType.getRawType(); return buildArray(clazz, context); } }
ArrayRelay implements SpecimenBuilder { @Override public Object create(Object request, SpecimenContext context) { if (!(request instanceof SpecimenType)) { return new NoSpecimen(); } SpecimenType specimenType = (SpecimenType)request; if(!specimenType.getRawType().isArray()) { return new NoSpecimen(); } Class clazz = specimenType.getRawType(); return buildArray(clazz, context); }  }
ArrayRelay implements SpecimenBuilder { @Override public Object create(Object request, SpecimenContext context) { if (!(request instanceof SpecimenType)) { return new NoSpecimen(); } SpecimenType specimenType = (SpecimenType)request; if(!specimenType.getRawType().isArray()) { return new NoSpecimen(); } Class clazz = specimenType.getRawType(); return buildArray(clazz, context); }  @Override Object create(Object request, SpecimenContext context); }
ArrayRelay implements SpecimenBuilder { @Override public Object create(Object request, SpecimenContext context) { if (!(request instanceof SpecimenType)) { return new NoSpecimen(); } SpecimenType specimenType = (SpecimenType)request; if(!specimenType.getRawType().isArray()) { return new NoSpecimen(); } Class clazz = specimenType.getRawType(); return buildArray(clazz, context); }  @Override Object create(Object request, SpecimenContext context);  }