@Test public void shouldCreateMultipleInstancesOfObjectWhenUsingInstanceDescriptors() { Annotation annotation = annotation().withInstanceDescriptor("TEST_CODE1", new String[]{}) .withInstanceDescriptor("TEST_CODE2", new String[]{"PROPERTY_VALUE"}).build(); Map<RepositoryObjectKey, ClassWithStringConstructor> objects = annotatedObjectFactory.createObjects(ClassWithStringConstructor.class, annotation); assertThatItemMap(objects).containsObjectsThatAreNotSame("TEST_CODE1", "TEST_CODE2").hasSize(2); assertThat(objects.get(RepositoryObjectKey.withKey("TEST_CODE2")).property).isSameAs("PROPERTY_VALUE"); }
public <T> Map<RepositoryObjectKey, T> createObjects(Class<T> objectClass, Annotation annotation) { Map<String, T> rawObjectInstances; ObjectInstance[] instanceDescriptors = extractInstanceDescriptors(annotation); if (instanceDescriptors.length > 0) { rawObjectInstances = createObjectsFromInstanceDescriptors(objectClass, instanceDescriptors); } else { rawObjectInstances = createObject(objectClass, annotation); } int objectOrder = extractOrder(annotation); Map<RepositoryObjectKey, T> createdObjects = new HashMap<RepositoryObjectKey, T>(); for (Entry<String, T> objectEntry : rawObjectInstances.entrySet()) { createdObjects.put(new RepositoryObjectKey(objectEntry.getKey(), objectOrder), objectEntry.getValue()); } return createdObjects; }
AnnotatedObjectFactory { public <T> Map<RepositoryObjectKey, T> createObjects(Class<T> objectClass, Annotation annotation) { Map<String, T> rawObjectInstances; ObjectInstance[] instanceDescriptors = extractInstanceDescriptors(annotation); if (instanceDescriptors.length > 0) { rawObjectInstances = createObjectsFromInstanceDescriptors(objectClass, instanceDescriptors); } else { rawObjectInstances = createObject(objectClass, annotation); } int objectOrder = extractOrder(annotation); Map<RepositoryObjectKey, T> createdObjects = new HashMap<RepositoryObjectKey, T>(); for (Entry<String, T> objectEntry : rawObjectInstances.entrySet()) { createdObjects.put(new RepositoryObjectKey(objectEntry.getKey(), objectOrder), objectEntry.getValue()); } return createdObjects; } }
AnnotatedObjectFactory { public <T> Map<RepositoryObjectKey, T> createObjects(Class<T> objectClass, Annotation annotation) { Map<String, T> rawObjectInstances; ObjectInstance[] instanceDescriptors = extractInstanceDescriptors(annotation); if (instanceDescriptors.length > 0) { rawObjectInstances = createObjectsFromInstanceDescriptors(objectClass, instanceDescriptors); } else { rawObjectInstances = createObject(objectClass, annotation); } int objectOrder = extractOrder(annotation); Map<RepositoryObjectKey, T> createdObjects = new HashMap<RepositoryObjectKey, T>(); for (Entry<String, T> objectEntry : rawObjectInstances.entrySet()) { createdObjects.put(new RepositoryObjectKey(objectEntry.getKey(), objectOrder), objectEntry.getValue()); } return createdObjects; }  }
AnnotatedObjectFactory { public <T> Map<RepositoryObjectKey, T> createObjects(Class<T> objectClass, Annotation annotation) { Map<String, T> rawObjectInstances; ObjectInstance[] instanceDescriptors = extractInstanceDescriptors(annotation); if (instanceDescriptors.length > 0) { rawObjectInstances = createObjectsFromInstanceDescriptors(objectClass, instanceDescriptors); } else { rawObjectInstances = createObject(objectClass, annotation); } int objectOrder = extractOrder(annotation); Map<RepositoryObjectKey, T> createdObjects = new HashMap<RepositoryObjectKey, T>(); for (Entry<String, T> objectEntry : rawObjectInstances.entrySet()) { createdObjects.put(new RepositoryObjectKey(objectEntry.getKey(), objectOrder), objectEntry.getValue()); } return createdObjects; }  Map<RepositoryObjectKey, T> createObjects(Class<T> objectClass, Annotation annotation); }
AnnotatedObjectFactory { public <T> Map<RepositoryObjectKey, T> createObjects(Class<T> objectClass, Annotation annotation) { Map<String, T> rawObjectInstances; ObjectInstance[] instanceDescriptors = extractInstanceDescriptors(annotation); if (instanceDescriptors.length > 0) { rawObjectInstances = createObjectsFromInstanceDescriptors(objectClass, instanceDescriptors); } else { rawObjectInstances = createObject(objectClass, annotation); } int objectOrder = extractOrder(annotation); Map<RepositoryObjectKey, T> createdObjects = new HashMap<RepositoryObjectKey, T>(); for (Entry<String, T> objectEntry : rawObjectInstances.entrySet()) { createdObjects.put(new RepositoryObjectKey(objectEntry.getKey(), objectOrder), objectEntry.getValue()); } return createdObjects; }  Map<RepositoryObjectKey, T> createObjects(Class<T> objectClass, Annotation annotation); static final int DEFAULT_ORDER_VALUE; }