@SuppressWarnings("unchecked") @Test void populateNoChanges() throws Exception { String scriptRunner0Name = "scriptRunner0"; ScriptRunner scriptRunner0 = when(mock(ScriptRunner.class).getName()).thenReturn(scriptRunner0Name).getMock(); String scriptRunner1Name = "scriptRunner1"; ScriptRunner scriptRunner1 = when(mock(ScriptRunner.class).getName()).thenReturn(scriptRunner1Name).getMock(); when(scriptRunnerFactory.getScriptRunners()) .thenReturn(newArrayList(scriptRunner0, scriptRunner1)); ScriptType scriptType0 = mock(ScriptType.class); when(dataService.findOneById(SCRIPT_TYPE, scriptRunner0Name, ScriptType.class)) .thenReturn(scriptType0); ScriptType scriptType1 = mock(ScriptType.class); when(dataService.findOneById(SCRIPT_TYPE, scriptRunner1Name, ScriptType.class)) .thenReturn(scriptType1); scriptTypePopulator.populate(); verify(dataService, times(0)).add(eq(SCRIPT_TYPE), any(Stream.class)); }
public void populate() { Collection<ScriptRunner> scriptRunners = scriptRunnerFactory.getScriptRunners(); List<ScriptType> newScriptTypes = scriptRunners.stream() .filter(this::notExists) .map(this::createScriptType) .collect(toList()); if (!newScriptTypes.isEmpty()) { persist(newScriptTypes); } }
ScriptTypePopulator { public void populate() { Collection<ScriptRunner> scriptRunners = scriptRunnerFactory.getScriptRunners(); List<ScriptType> newScriptTypes = scriptRunners.stream() .filter(this::notExists) .map(this::createScriptType) .collect(toList()); if (!newScriptTypes.isEmpty()) { persist(newScriptTypes); } } }
ScriptTypePopulator { public void populate() { Collection<ScriptRunner> scriptRunners = scriptRunnerFactory.getScriptRunners(); List<ScriptType> newScriptTypes = scriptRunners.stream() .filter(this::notExists) .map(this::createScriptType) .collect(toList()); if (!newScriptTypes.isEmpty()) { persist(newScriptTypes); } } ScriptTypePopulator(
      ScriptRunnerFactory scriptRunnerFactory,
      DataService dataService,
      ScriptTypeFactory scriptTypeFactory); }
ScriptTypePopulator { public void populate() { Collection<ScriptRunner> scriptRunners = scriptRunnerFactory.getScriptRunners(); List<ScriptType> newScriptTypes = scriptRunners.stream() .filter(this::notExists) .map(this::createScriptType) .collect(toList()); if (!newScriptTypes.isEmpty()) { persist(newScriptTypes); } } ScriptTypePopulator(
      ScriptRunnerFactory scriptRunnerFactory,
      DataService dataService,
      ScriptTypeFactory scriptTypeFactory); void populate(); }
ScriptTypePopulator { public void populate() { Collection<ScriptRunner> scriptRunners = scriptRunnerFactory.getScriptRunners(); List<ScriptType> newScriptTypes = scriptRunners.stream() .filter(this::notExists) .map(this::createScriptType) .collect(toList()); if (!newScriptTypes.isEmpty()) { persist(newScriptTypes); } } ScriptTypePopulator(
      ScriptRunnerFactory scriptRunnerFactory,
      DataService dataService,
      ScriptTypeFactory scriptTypeFactory); void populate();  }