ModuleBuilder extends AbstractBuilder<ModuleConfig, ModuleBuilder> { public ModuleConfig build() { ModuleConfig moduleConfig = new ModuleConfig(); super.build(moduleConfig); moduleConfig.setDefault(isDefault); moduleConfig.setMonitor(monitor); moduleConfig.setName(name); moduleConfig.setOrganization(organization); moduleConfig.setOwner(owner); moduleConfig.setRegistries(registries); moduleConfig.setVersion(version); return moduleConfig; }  ModuleBuilder name(String name); ModuleBuilder version(String version); ModuleBuilder owner(String owner); ModuleBuilder organization(String organization); ModuleBuilder addRegistries(List<? extends RegistryConfig> registries); ModuleBuilder addRegistry(RegistryConfig registry); ModuleBuilder monitor(MonitorConfig monitor); ModuleBuilder isDefault(Boolean isDefault); ModuleConfig build();  }
@Test void build() { RegistryConfig registry = new RegistryConfig(); MonitorConfig monitor = new MonitorConfig(); ModuleBuilder builder = new ModuleBuilder(); builder.name("name").version("version").owner("owner").organization("organization").addRegistry(registry) .monitor(monitor).isDefault(false); ModuleConfig config = builder.build(); ModuleConfig config2 = builder.build(); Assertions.assertEquals("name", config.getName()); Assertions.assertEquals("version", config.getVersion()); Assertions.assertEquals("owner", config.getOwner()); Assertions.assertEquals("organization", config.getOrganization()); Assertions.assertTrue(builder.build().getRegistries().contains(registry)); Assertions.assertSame(monitor, builder.build().getMonitor()); Assertions.assertFalse(config.isDefault()); Assertions.assertNotSame(config, config2); }