### Question:
CarManufacturer { public Car manufactureCar(Specification spec) { Car car = carFactory.createCar(spec); entityManager.merge(car); return car; }  Car manufactureCar(Specification spec);  }### Answer:
@Test public void test() { Specification spec = new Specification(); Car car = new Car(spec); when(entityManager.merge(any())).then(a -> a.getArgument(0)); when(carFactory.createCar(any())).thenReturn(car); assertThat(testObject.manufactureCar(spec)).isEqualTo(car); verify(carFactory).createCar(spec); verify(entityManager).merge(car); }
@Test public void test() { Specification spec = new Specification(); Car car = new Car(spec); when(testObject.entityManager.merge(any())).then(a -> a.getArgument(0)); when(testObject.carFactory.createCar(any())).thenReturn(car); assertThat(testObject.manufactureCar(spec)).isEqualTo(car); verify(testObject.carFactory).createCar(spec); verify(testObject.entityManager).merge(car); }