public function testUploadCSVNewFile()
 {
     $fileName = __DIR__ . '/csv/StockTestingCSVNew.txt';
     $mimeType = new finfo(FILEINFO_MIME_TYPE);
     $data = $this->_service->getData($fileName, $mimeType->file($fileName));
     $this->assertEquals('csv', $data['data']['_type'], var_export($data, true));
     $watcher = $this->_service->createCsv($data);
     $this->assertInstanceOf('\\Core\\Model\\WatcherModel', $watcher);
 }
 public function diagnosticAction()
 {
     if (!$this->getRequest()->isGet()) {
         throw new UnexpectedException("Resquest must be GET");
     }
     // Get sim
     $sim = $this->_getSim();
     $this->_helper->allowed('diagnosis', $sim);
     // Get type
     $map = array('administrative' => SimModel::SIM_DIAGNOSIS_TYPE_ADM_STATUS, 'gsm' => SimModel::SIM_DIAGNOSIS_TYPE_GSM_STATUS, 'gprs' => SimModel::SIM_DIAGNOSIS_TYPE_GPRS_STATUS, 'ip' => SimModel::SIM_DIAGNOSIS_TYPE_IP_REACHABILITY);
     $type = $map[$this->_getParam('type')];
     // Load diagnosis result
     $result = $this->_simSrv->diagnosis($sim, $type);
     if ($type === SimModel::SIM_DIAGNOSIS_TYPE_ADM_STATUS) {
         $this->view->globalStatus = $result['globalDiagnosticResultOk'];
         $this->view->globalIssues = $result['globalIssues'];
         $this->view->voiceStatus = $result['voiceDiagnosticResultOk'];
         $this->view->voiceIssues = $result['voiceIssues'];
         $this->view->dataStatus = $result['dataDiagnosticResultOk'];
         $this->view->dataIssues = $result['dataIssues'];
         $this->view->smsStatus = $result['smsDiagnosticResultOk'];
         $this->view->smsIssues = $result['smsIssues'];
     } else {
         $this->view->transactionId = $result->id;
     }
 }
 public function testSimDiagnostic()
 {
     $this->loginByUserId(\App_Test_PHPUnit_Framework_TestCase::PROVIDER_COMMERCIAL_API_ID, \App_Controller_Plugin_Auth::AUTH_TYPE_EXTERNAL);
     $sim = SimService::getInstance()->load(App_Test_PHPUnit_Framework_TestCase::SIM_ID);
     $watcher = SimService::getInstance()->diagnosis($sim, SimModel::SIM_DIAGNOSIS_TYPE_GPRS_STATUS);
     $transactionId = $watcher->id;
     $result = $this->get(static::NS . '/sim/diagnostic/' . $transactionId);
     $this->assertResponseCode('200');
 }
 /**
  * Validate element value
  *
  * If a translation adapter is registered, any error messages will be
  * translated according to the current locale, using the given error code;
  * if no matching translation is found, the original message will be
  * utilized.
  *
  * Note: The *filtered* value is validated.
  *
  * @param  array   $data
  * @param  mixed   $context
  * @return boolean
  */
 public function isValid($data, $context = null, $removeNotPresentFields = false)
 {
     if (!$data) {
         $parameters = array('lteEnabled' => 'true', 'customer' => $context['id']);
         $filterList = SimService::getInstance()->buildFilterList($parameters);
         $simList = SimService::getInstance()->listAll($filterList, array());
         if ($simList->getCount() != 0) {
             $this->_error(self::LTE_SIMLIST_NOT_EMPTY);
             return false;
         }
     }
     return true;
 }
 /**
  * @group EricssonGroupingInt
  */
 public function testSortByICCAsc()
 {
     $rawFilters = array('sortBy' => \Application\Model\Sorting\SimSortingFields::ICC);
     $filterList = SimService::getInstance()->buildFilterList($rawFilters);
     $filters = array('organizationId' => Application\Model\Organization\OrgServiceProviderModel::ORG_TYPE . '-' . 'sp1 (non-commercial)111111111111', 'filterList' => $filterList);
     $sims = $this->simMapper->findAll($filters, array('count' => 100));
     $this->assertNotNull($sims);
     $this->assertInstanceOf('\\Application\\Model\\ListResultModel', $sims);
     $beforeId = NULL;
     foreach ($sims->getItems() as $sim) {
         $currentId = $sim->getId();
         if ($beforeId) {
             $this->assertTrue($currentId > $beforeId, "Current: {$currentId}. Before: {$beforeId}");
         }
         $beforeId = $sim->getId();
     }
 }
 /**
  * @group EricssonPreinvetoryInt
  */
 public function testDeleteList()
 {
     $fileName = __DIR__ . '/xml/StockTestingList.xml';
     $mimeType = new finfo(FILEINFO_MIME_TYPE);
     $data = $this->_service->getData($fileName, $mimeType->file($fileName));
     $this->assertEquals('sim', $data['_type']);
     $this->_service->createSim($data, $this->_user->getOrganizationId());
     $result = $this->_service->listAll(null, array(), null, $this->_user->getOrganization());
     $resultItems = $result->getItems();
     try {
         $this->_service->deleteList($resultItems);
     } catch (Exception $e) {
         $this->fail('An exception has been raised: ' . $e->getMessage());
     }
     $result = $this->_service->listAll(null, array(), null, $this->_user->getOrganization());
     $this->assertEmpty(0, $result->getItems());
 }
 /**
  * Deletes the given user
  */
 public function deleteAction()
 {
     // Try to load the chosen user
     $id = $this->getRequest()->getParam('id');
     $sim = $this->_simSrv->load($id, \App::getOrgUserLogged());
     if (empty($sim)) {
         throw new NotFoundException('Sim ' . $id . ' not found', 404);
     }
     // Check permissions
     $this->_helper->allowed('delete', $sim);
     // Remove the user
     try {
         $this->_simSrv->delete($id);
     } catch (Exception $e) {
         throw new InvalidArgumentException($e->getMessage(), null, $e);
     }
     $this->view->data = true;
 }
 public function changeLteStatusAction()
 {
     if (!$this->getRequest()->isPut()) {
         throw new AppEx\ForbiddenException("Lte activation/deactivation must be a put request");
     }
     $data = $this->_checkAndGetListData('changeLte', true, array('PUT'));
     $status = $this->_getParam('status', null);
     if (!$status) {
         throw new AppEx\InvalidArgumentException("Status query param is mandatory");
     }
     switch ($status) {
         case self::LTE_STATUS_ACTIVATE:
             $watcher = $this->_simSrv->changeLte(true, $data['list']);
             break;
         case self::LTE_STATUS_DEACTIVATE:
             $watcher = $this->_simSrv->changeLte(false, $data['list']);
             break;
         default:
             throw new AppEx\InvalidArgumentException("Invalid Status");
     }
     $this->view->data = $watcher;
 }
 public function isValid($data, $context = null)
 {
     if (!parent::isValid($data, $context)) {
         return false;
     }
     if (isset($context['customerId'])) {
         if ($this->_supplService && ($data == SupplServicesModel::ST_SUSPENDED || $data == SupplServicesModel::ST_DEACTIVATED)) {
             $filter = array(SimFilterFields::CUSTOMER => $context['customerId'], SimFilterFields::SUPPLEMENTARY_SERVICES => $this->_supplService);
             $service = SimService::getInstance();
             $filterList = $service->buildFilterList($filter);
             $list = $service->listAll($filterList, array('count' => 1));
             if ($list->getCount()) {
                 $this->_error(self::SERVICE_BEING_USED, $data);
                 return false;
             }
         }
     } else {
         if ($data == SupplServicesModel::ST_SUSPENDED) {
             $this->_error(self::UNASSIGNED_CANNOT_BE_SUSPENDED, $data);
             return false;
         }
     }
     return true;
 }
 public function init()
 {
     $this->_service = SteeringListService::getInstance();
     $this->_simService = SimService::getInstance();
 }
 /**
  * @group EricssonGroupingInt
  */
 public function testGroupLocalWithFilterAndHighlight()
 {
     $rawFilters = array('customer' => Application\Model\Organization\OrgCustomerModel::ORG_TYPE . '-' . 'the_fist_customer000000000000000', 'groupBy' => Application\Model\Group\SimGroups::SIM_TYPE, 'group' => 'LOCAL', 'highlighting' => Application\Model\Group\SimGroups::LIFE_CYCLE_STATE);
     $filterList = SimService::getInstance()->buildFilterList($rawFilters);
     $filters = array('organizationId' => Application\Model\Organization\OrgMasterModel::ORG_TYPE . '-' . 'master11111111111111111111111111', 'filterList' => $filterList);
     $sims = $this->simMapper->findAll($filters, array('count' => 100));
     $this->assertNotNull($sims);
     $this->assertInstanceOf('Application\\Model\\GroupListModel', $sims);
     $results = array('TEST' => 0, 'RETIRED' => 0, 'SUSPENDED' => 0, 'INACTIVE_NEW' => 251, 'ACTIVATION_READY' => 0, 'ACTIVE' => 0, 'DEACTIVATED' => 0, 'ACTIVATION_PENDANT' => 0);
     foreach ($results as $state => $count) {
         $simState = $sims->getGroupByLabel($state);
         $this->assertNotNull($simState, $state . " not defined.");
         $this->assertGreaterThanOrEqual($count, $simState->getCount(), $state . " must have " . $count . " items.");
     }
     //         $simLocal = $sims->getGroupByLabel('L');
     //         $this->assertNotNull($simLocal);
     //         $this->assertEquals('251', $simLocal->getCount());
 }
 /**
  * @group EricssonListPagingInt
  */
 public function testFindAllByMasterFilterPaging()
 {
     $rawFilters = array('simType' => SimModel::SIM_TYPE_LOCAL);
     $filterList = SimService::getInstance()->buildFilterList($rawFilters);
     $filters = array('organizationId' => Application\Model\Organization\OrgMasterModel::ORG_TYPE . '-' . 'master11111111111111111111111111', 'filterList' => $filterList);
     $options = array('page' => 1, 'count' => 50);
     $sims = $this->simMapper->findAll($filters, $options);
     echo "\nCount:" . $sims->getCount() . "\n";
     $this->assertNotNull($sims);
     $this->assertEquals('50', count($sims->getItems()), "Page: " . $options['page']);
     $options = array('page' => 2, 'count' => 50);
     $sims = $this->simMapper->findAll($filters, $options);
     $this->assertNotNull($sims);
     $this->assertEquals('50', count($sims->getItems()), "Page: " . $options['page']);
     $options = array('page' => 6, 'count' => 50);
     $sims = $this->simMapper->findAll($filters, $options);
     $this->assertNotNull($sims);
     $this->assertEquals('50', count($sims->getItems()), "Page: " . $options['page']);
     $options = array('page' => 8, 'count' => 50);
     $sims = $this->simMapper->findAll($filters, $options);
     $this->assertNotNull($sims);
     $this->assertGreaterThanOrEqual('26', count($sims->getItems()), "Page: " . $options['page']);
 }
 public function init()
 {
     $this->_stockSrv = \Application\Service\StockService::getInstance();
     $this->_simSrv = SimService::getInstance();
 }
 public function testChangeLteOneValue()
 {
     $data = '1';
     $this->_service->changeLte($data, array());
 }
 public function countSims($supervGroup)
 {
     $filterList = SimService::getInstance()->buildFilterList(array(SimFilterFields::SUPERVISION_GROUP => $supervGroup->getId()));
     $simList = SimService::getInstance()->listAll($filterList, array('count' => 1), null, \App::getOrgUserLogged());
     return $simList->getCount();
 }