### Question:
DeadRemovalStrategy implements OptimizationStrategy { List<Integer> getDeadAddresses() { return addresses.stream().filter(this::isDead).collect(Collectors.toList()); } DeadRemovalStrategy(ExecutionGraphManipulator manipulator); @Override Map<String, Integer> getOptimizationCounts(); @Override boolean perform(); void setRemoveWeak(boolean removeWeak);  }### Answer:
@Test public void detectsDeadCodeWithStrongSideEffect() { String methodName = "deadCodeWithStrongSideEffect()V"; ExecutionGraphManipulator manipulator = OptimizerTester.getGraphManipulator(CLASS_NAME, methodName); DeadRemovalStrategy strategy = new DeadRemovalStrategy(manipulator); List<Integer> found = strategy.getDeadAddresses(); Collections.sort(found); List<Integer> expected = Collections.singletonList(1); assertEquals(expected, found); }
@Test public void detectsDeadNopPadding() { String methodName = "hasNopPadding()V"; ExecutionGraphManipulator manipulator = OptimizerTester.getGraphManipulator(CLASS_NAME, methodName); DeadRemovalStrategy strategy = new DeadRemovalStrategy(manipulator); List<Integer> found = strategy.getDeadAddresses(); List<Integer> expected = new LinkedList<Integer>(); assertEquals(expected, found); }
@Test public void detectsSimpleDeadCode() { String methodName = "deadCode()V"; ExecutionGraphManipulator manipulator = OptimizerTester.getGraphManipulator(CLASS_NAME, methodName); DeadRemovalStrategy strategy = new DeadRemovalStrategy(manipulator); List<Integer> found = strategy.getDeadAddresses(); Collections.sort(found); List<Integer> expected = Arrays.asList(2, 3, 4, 5); assertEquals(expected, found); }