@Test public void shouldAddOccurrenceNumberToAutoGeneratedNameWhenMultipleRepositoriesWithSameClassProvided() { ParamRepository repository = mock(ParamRepository.class); String repositoryClassName = repository.getClass().getSimpleName(); NamedParamRepositoryFactory factory = new NamedParamRepositoryFactory(); factory.create(repository); NamedParamRepository namedRepository1 = factory.create(repository); NamedParamRepository namedRepository2 = factory.create(repository); assertThat(namedRepository1).hasName(repositoryClassName + "1"); assertThat(namedRepository2).hasName(repositoryClassName + "2"); }
public NamedParamRepository create(RepositoryName repositoryName, ParamRepository repository) { return new NamedParamRepository(repositoryName, repository); }
NamedParamRepositoryFactory { public NamedParamRepository create(RepositoryName repositoryName, ParamRepository repository) { return new NamedParamRepository(repositoryName, repository); } }
NamedParamRepositoryFactory { public NamedParamRepository create(RepositoryName repositoryName, ParamRepository repository) { return new NamedParamRepository(repositoryName, repository); } NamedParamRepositoryFactory(); }
NamedParamRepositoryFactory { public NamedParamRepository create(RepositoryName repositoryName, ParamRepository repository) { return new NamedParamRepository(repositoryName, repository); } NamedParamRepositoryFactory(); NamedParamRepository create(RepositoryName repositoryName, ParamRepository repository); NamedParamRepository create(String repositoryName, ParamRepository repository); NamedParamRepository create(ParamRepository repository); }
NamedParamRepositoryFactory { public NamedParamRepository create(RepositoryName repositoryName, ParamRepository repository) { return new NamedParamRepository(repositoryName, repository); } NamedParamRepositoryFactory(); NamedParamRepository create(RepositoryName repositoryName, ParamRepository repository); NamedParamRepository create(String repositoryName, ParamRepository repository); NamedParamRepository create(ParamRepository repository);  }