IdGenerator { public String generate(Class<?> role, String id) { String cloudId = workerMetadata.getId(); String idRole = role.getCanonicalName(); String seed = String.format("%s-%s-%s", cloudId, idRole, id); return getOrGenerate(seed); } @Autowired  IdGenerator(WorkerMetadata workerMetadata, Config config); String generate(Class<?> role, String id); String getProjectId(Cloud cloud, String trait); String getProjectId(Cloud cloud); String getInstanceId(Cloud cloud, String realId); String getImageId(Cloud cloud, String realId);  }
@Test public void testGenerate() { String attempt1 = idGenerator.generate(getClass(), ID); String attempt2 = idGenerator.generate(getClass(), ID); assertThat(attempt1, equalTo("54a31dbb-57f2-3ec5-9366-e53e59c3999f")); assertThat(attempt1, equalTo(attempt2)); }