public function testGetAgentMap() { $successfulAgents = array($this->agentName => array(new AgentRef($this->agentId, $this->agentName, 'a0815'))); $this->pretendScanAgentStatus($successfulAgents); $expected = array($this->agentId => "{$this->agentName} a0815"); $map = $this->scanJobProxy->getAgentMap(); assertThat($map, is(equalTo($expected))); }
/** * \brief Given an $Uploadtree_pk, display: * - The histogram for the directory BY LICENSE. * - The file listing for the directory. */ private function showUploadHist(ItemTreeBounds $itemTreeBounds) { $groupId = Auth::getGroupId(); $selectedAgentId = GetParm('agentId', PARM_INTEGER); $tag_pk = GetParm("tag", PARM_INTEGER); $uploadId = $itemTreeBounds->getUploadId(); $scannerAgents = array_keys($this->agentNames); $scanJobProxy = new ScanJobProxy($this->agentDao, $uploadId); $scannerVars = $scanJobProxy->createAgentStatus($scannerAgents); $agentMap = $scanJobProxy->getAgentMap(); $vars = array('agentId' => GetParm('agentId', PARM_INTEGER), 'agentShowURI' => Traceback_uri() . '?mod=' . Traceback_parm(), 'agentMap' => $agentMap, 'scanners' => $scannerVars); $selectedAgentIds = empty($selectedAgentId) ? $scanJobProxy->getLatestSuccessfulAgentIds() : $selectedAgentId; if (!empty($agentMap)) { $licVars = $this->createLicenseHistogram($itemTreeBounds->getItemId(), $tag_pk, $itemTreeBounds, $selectedAgentIds, $groupId); $vars = array_merge($vars, $licVars); } $this->licenseProjector = new LicenseMap($this->getObject('db.manager'), $groupId, LicenseMap::CONCLUSION, true); $dirVars = $this->countFileListing($itemTreeBounds); $childCount = $dirVars['iTotalRecords']; /*************************************** * Problem: $ChildCount can be zero if you have a container that does not * unpack to a directory. For example: * file.gz extracts to archive.txt that contains a license. * Same problem seen with .pdf and .Z files. * Solution: if $ChildCount == 0, then just view the license! * * $ChildCount can also be zero if the directory is empty. * **************************************/ if ($childCount == 0) { return new RedirectResponse("?mod=view-license" . Traceback_parm_keep(array("upload", "item"))); } $vars['licenseUri'] = Traceback_uri() . "?mod=popup-license&rf="; $vars['bulkUri'] = Traceback_uri() . "?mod=popup-license"; return array_merge($vars, $dirVars); }