### Question:
DefaultUpgradeService implements UpgradeService { protected List<UpgradeUnit> upgradeDOM(Resource resource, List<UpgradeHandler> handlerList) { List<UpgradeUnit> allUnits = new ArrayList<>(); Document projectDocument = Util.readDocument(resource.getURL()); UpgradeUnit projectUnit = new UpgradeUnit(resource, projectDocument); allUnits.add(projectUnit); List<Resource> dataMapResources = getAdditionalDatamapResources(projectUnit); List<UpgradeUnit> dataMapUnits = new ArrayList<>(dataMapResources.size()); for (Resource dataMapResource : dataMapResources) { dataMapUnits.add(new UpgradeUnit(dataMapResource, Util.readDocument(dataMapResource.getURL()))); } allUnits.addAll(dataMapUnits); for(UpgradeHandler handler : handlerList) { handler.processProjectDom(projectUnit); for(UpgradeUnit dataMapUnit : dataMapUnits) { handler.processDataMapDom(dataMapUnit); } } return allUnits; } DefaultUpgradeService(@Inject List<UpgradeHandler> handlerList); @Override UpgradeMetaData getUpgradeType(Resource resource); @Override Resource upgradeProject(Resource resource); static final String UNKNOWN_VERSION; static final String MIN_SUPPORTED_VERSION; }### Answer:
@Test public void upgradeDOM() throws Exception { Resource resource = new URLResource(getClass().getResource("../cayenne-PROJECT1.xml")); upgradeService = mock(DefaultUpgradeService.class); when(upgradeService.upgradeDOM(any(Resource.class), ArgumentMatchers.<UpgradeHandler>anyList())) .thenCallRealMethod(); when(upgradeService.getAdditionalDatamapResources(any(UpgradeUnit.class))) .thenCallRealMethod(); upgradeService.upgradeDOM(resource, handlers); for(UpgradeHandler handler : handlers) { verify(handler).getVersion(); verify(handler).processProjectDom(any(UpgradeUnit.class)); verify(handler, times(2)).processDataMapDom(any(UpgradeUnit.class)); verifyNoMoreInteractions(handler); } }