@Test public void shouldReturnUniqueTemplates() throws Exception { List<SynthTemplate> templates = templateSelector.chooseRandomList(3); assertThat(templates).hasSize(3); for(int i=0; i<templates.size(); i++){ int matches = 0; for(int j=0; j<templates.size(); j++){ if(templates.get(i).getId().equals(templates.get(j))){ matches++; } } if(matches>1){ assertThat(true).isFalse(); } } }
@Override public List<SynthTemplate> chooseRandomList(int size) throws Exception { List<SynthTemplate> selections = new ArrayList<>(); for (int i = 0; i < size; i++) { selections.add(chooseUniqueRandom(selections.stream().map(synthTemplate -> synthTemplate.getId()).collect(Collectors.toList()))); } return selections; }
TemplateSelector implements ITemplateSelector { @Override public List<SynthTemplate> chooseRandomList(int size) throws Exception { List<SynthTemplate> selections = new ArrayList<>(); for (int i = 0; i < size; i++) { selections.add(chooseUniqueRandom(selections.stream().map(synthTemplate -> synthTemplate.getId()).collect(Collectors.toList()))); } return selections; } }
TemplateSelector implements ITemplateSelector { @Override public List<SynthTemplate> chooseRandomList(int size) throws Exception { List<SynthTemplate> selections = new ArrayList<>(); for (int i = 0; i < size; i++) { selections.add(chooseUniqueRandom(selections.stream().map(synthTemplate -> synthTemplate.getId()).collect(Collectors.toList()))); } return selections; }  }
TemplateSelector implements ITemplateSelector { @Override public List<SynthTemplate> chooseRandomList(int size) throws Exception { List<SynthTemplate> selections = new ArrayList<>(); for (int i = 0; i < size; i++) { selections.add(chooseUniqueRandom(selections.stream().map(synthTemplate -> synthTemplate.getId()).collect(Collectors.toList()))); } return selections; }  @Override SynthTemplate chooseRandom(); @Override SynthTemplate chooseUniqueRandom(List<Integer> ids); @Override List<SynthTemplate> chooseRandomList(int size); @Override SynthTemplate chooseSpecific(Integer templateId); }
TemplateSelector implements ITemplateSelector { @Override public List<SynthTemplate> chooseRandomList(int size) throws Exception { List<SynthTemplate> selections = new ArrayList<>(); for (int i = 0; i < size; i++) { selections.add(chooseUniqueRandom(selections.stream().map(synthTemplate -> synthTemplate.getId()).collect(Collectors.toList()))); } return selections; }  @Override SynthTemplate chooseRandom(); @Override SynthTemplate chooseUniqueRandom(List<Integer> ids); @Override List<SynthTemplate> chooseRandomList(int size); @Override SynthTemplate chooseSpecific(Integer templateId);  }