@Test public void shouldComputePreparationsId() throws Exception { final Stream<Preparation> initialPreparations = preparationRepository.list(Preparation.class); final List<String> initialIds = initialPreparations.map(Preparation::getId).collect(Collectors.toList()); task.run(); final Stream<Preparation> preparations = preparationRepository.list(Preparation.class); final List<String> updatedIds = preparations.map(Preparation::getId).collect(Collectors.toList()); assertEquals(initialIds.size(), updatedIds.size()); updatedIds.forEach(id -> assertFalse(initialIds.contains(id))); }
@Override public void run() { final Stream<Preparation> preparations = repository.list(Preparation.class); preparations.forEach(p -> { repository.remove(p); p.setId(UUID.randomUUID().toString()); repository.add(p); LOG.debug("preparation {} has a new id {}", p.getName(), p.getName()); }); }
ComputePreparationId implements BaseUpgradeTaskTo_1_2_0_PE { @Override public void run() { final Stream<Preparation> preparations = repository.list(Preparation.class); preparations.forEach(p -> { repository.remove(p); p.setId(UUID.randomUUID().toString()); repository.add(p); LOG.debug("preparation {} has a new id {}", p.getName(), p.getName()); }); } }
ComputePreparationId implements BaseUpgradeTaskTo_1_2_0_PE { @Override public void run() { final Stream<Preparation> preparations = repository.list(Preparation.class); preparations.forEach(p -> { repository.remove(p); p.setId(UUID.randomUUID().toString()); repository.add(p); LOG.debug("preparation {} has a new id {}", p.getName(), p.getName()); }); }  }
ComputePreparationId implements BaseUpgradeTaskTo_1_2_0_PE { @Override public void run() { final Stream<Preparation> preparations = repository.list(Preparation.class); preparations.forEach(p -> { repository.remove(p); p.setId(UUID.randomUUID().toString()); repository.add(p); LOG.debug("preparation {} has a new id {}", p.getName(), p.getName()); }); }  @Override int getOrder(); @Override target getTarget(); @Override void run(); }
ComputePreparationId implements BaseUpgradeTaskTo_1_2_0_PE { @Override public void run() { final Stream<Preparation> preparations = repository.list(Preparation.class); preparations.forEach(p -> { repository.remove(p); p.setId(UUID.randomUUID().toString()); repository.add(p); LOG.debug("preparation {} has a new id {}", p.getName(), p.getName()); }); }  @Override int getOrder(); @Override target getTarget(); @Override void run();  }