### Question:
DefaultComponentDescriptorFactory implements ComponentDescriptorFactory { @Override public <T> ComponentDescriptor<T> make(final String componentName, final Class<T> componentType, final Supplier<T> componentSupplier, final boolean isSingleton) { final var classLoader = componentType.getClassLoader(); final var version = getVersionFor(componentType, classLoader); final ComponentMetadata metadata = loadAnnotationComponentMetadata(componentType); var builder = new ComponentDescriptorBuilder<T>() .type(componentType) .supplier(componentSupplier) .metadata(metadata) .isSingleton(isSingleton) .order(extractComponentOrderFromMetadata(metadata)) .configuration(extractComponentConfFromMetadata(metadata)); if (version != null) builder.version(version); if (componentName != null) builder.name(componentName); else builder.name(componentNameGenerator.generate(builder)); return builder.build(); } DefaultComponentDescriptorFactory(); void setComponentNameGenerator(final ComponentNameGenerator componentNameGenerator); @Override ComponentDescriptor<T> make(final String componentName,
                                           final Class<T> componentType,
                                           final Supplier<T> componentSupplier,
                                           final boolean isSingleton);  }### Answer:
@Test public void shouldCreateDescriptorAndLoadOrderFromAnnotationMetadata() { ComponentDescriptor<TestClassWithAnnotations> descriptor = factory.make( null, TestClassWithAnnotations.class, TestClassWithAnnotations::new, true); assertNotNull(descriptor); assertTrue(descriptor.metadata().contains("order", "value", 42)); assertEquals(42, descriptor.order()); }
@Test public void shouldCreateDescriptorGivenVersionedClass() { ComponentDescriptor<TestVersionedClass> descriptor = factory.make( null, TestVersionedClass.class, TestVersionedClass::new, true); assertNotNull(descriptor); assertTrue(descriptor.isVersioned()); assertTrue(Version.isEqual(descriptor.version(), "1.0")); }
@Test public void shouldCreateDescriptorGivenSimpleClass() { ComponentDescriptor<TestClass> descriptor = factory.make( null, TestClass.class, TestClass::new, true); assertNotNull(descriptor); assertFalse(descriptor.isVersioned()); }
@Test public void shouldCreateDescriptorAndLoadConfigFromAnnotationMetadata() { ComponentDescriptor<TestClassWithAnnotations> descriptor = factory.make( null, TestClassWithAnnotations.class, TestClassWithAnnotations::new, true); assertNotNull(descriptor); assertTrue(descriptor.metadata().contains("confvalue", "value", "value1")); assertTrue(descriptor.metadata().contains("confvalue", "value", "value2")); Conf configuration = descriptor.configuration(); assertNotNull(configuration); assertTrue(configuration.hasPath("key-1")); assertTrue(configuration.hasPath("key-2")); }