public function testGetUnhandledScannerDetectedLicensesWithMappedMatch() { /** @var LicenseRef $licenseRef */ list($scannerResults, $licenseRef) = $this->createScannerDetectedLicenses(); $offset = 0; $clearingEvent = $this->createClearingEvent($eventId = 123, $this->timestamp, $licenseRef->getId() + $offset, $licenseRef->getShortName(), $licenseRef->getFullName()); $this->clearingDao->shouldReceive("getRelevantClearingEvents")->with($this->itemTreeBounds, $this->groupId)->andReturn(array($clearingEvent->getLicenseId() => $clearingEvent)); $this->agentLicenseEventProcessor->shouldReceive("getScannerEvents")->with($this->itemTreeBounds, LicenseMap::CONCLUSION)->andReturn($scannerResults); $licenseMap = M::mock(LicenseMap::classname()); $licenseMap->shouldReceive('getProjectedId')->andReturnUsing(function ($id) { return $id; }); $licenseMap->shouldReceive('getUsage')->andReturn(LicenseMap::CONCLUSION); $hasUnhandledScannerDetectedLicenses = $this->clearingDecisionProcessor->hasUnhandledScannerDetectedLicenses($this->itemTreeBounds, $this->groupId, array(), $licenseMap); assertThat($hasUnhandledScannerDetectedLicenses, is(False)); }
/** * @param ItemTreeBounds $itemTreeBounds * @param int $userId */ protected function processClearingEventsForItem(ItemTreeBounds $itemTreeBounds, $userId, $groupId, $additionalEventsFromThisJob) { $this->dbManager->begin(); $itemId = $itemTreeBounds->getItemId(); switch ($this->conflictStrategyId) { case self::FORCE_DECISION: $createDecision = true; break; default: $createDecision = !$this->clearingDecisionProcessor->hasUnhandledScannerDetectedLicenses($itemTreeBounds, $groupId, $additionalEventsFromThisJob, $this->licenseMap); } if ($createDecision) { $this->clearingDecisionProcessor->makeDecisionFromLastEvents($itemTreeBounds, $userId, $groupId, DecisionTypes::IDENTIFIED, $this->decisionIsGlobal, $additionalEventsFromThisJob); } else { foreach ($additionalEventsFromThisJob as $eventId) { $this->clearingDao->copyEventIdTo($eventId, $itemId, $userId, $groupId); } $this->clearingDao->markDecisionAsWip($itemId, $userId, $groupId); } $this->heartbeat(1); $this->dbManager->commit(); }