public function testGetKeepAliveHistory()
 {
     $sim = new \Application\Model\SimModel();
     $sim->setImsi("214071000000002");
     $from = '2008-11-15T21:07+0000';
     $until = '2012-12-14T21:07+0000';
     $data = $this->simMapper->getKeepAliveHistory($sim, $from, $until);
     // Structure
     $this->assertInternalType('array', $data);
     $this->assertNotEmpty($data);
     $this->assertArrayHasKey('timestamp', $data[0]);
     $this->assertArrayHasKey('status', $data[0]);
     // Count
     $this->assertEquals(2, count($data));
 }
 /**
  * @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 EricssonInt
  */
 public function testFindAllByMaster()
 {
     $this->markTestSkipped("Not implemented by Ericsson");
     $filters = array('organizationId' => Application\Model\Organization\OrgMasterModel::ORG_TYPE . '-' . 'MASTER:0000000000000000000000001');
     $sims = $this->simMapper->findAll($filters);
     $this->assertNotNull($sims);
     $this->assertEquals('100', count($sims));
     echo 'simsCount: ' . count($sims);
 }
 public function testDiagnosisHistory()
 {
     $sim = $this->simMapper->findOneById("00000000000000000015", self::MASTER_ORG_ID);
     $data = $this->simMapper->getDiagnosisHistory($sim);
     $this->assertInternalType('array', $data);
     $this->assertNotEmpty($data);
     $this->assertArrayHasKey('end_date', $data[0]);
     $this->assertArrayHasKey('description', $data[0]);
 }
 public function testGetLifeCycleHistoryEmpty()
 {
     $sim = new SimModel();
     $sim->setId('00000000000000000000000000000002');
     $from = '2011-07-15';
     $until = '2011-08-20';
     $this->assertInstanceOf('\\Application\\Model\\SimModel', $sim);
     $data = $this->simMapper->getLifeCycleHistory($sim, $from, $until);
     $this->assertInternalType('array', $data);
     $this->assertEmpty($data);
 }
 /**
  * @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']);
 }
예제 #8
0
 protected function _mapData($data)
 {
     $data = SimMapper::getInstance()->mapEricssonModelToModel($data);
     return new SimModel($data);
 }
예제 #9
0
 /**
  *
  * @param  string                      $id
  * @return \Application\Model\SimModel | null
  */
 public static function find($id)
 {
     $sim = SimMapper::getInstance()->findOneById($id, \App::getOrgUserLogged()->getId());
     return $sim;
 }
예제 #10
0
 /**
  * @param $state
  * @param $data array|App_FilterList
  * @return void
  */
 public function changeLifeCycleStateSync($oldState, $newState, $simId)
 {
     if (!in_array($oldState, LifeCycleModel::getStatuses()) || !in_array($newState, LifeCycleModel::getStatuses())) {
         throw new InvalidArgumentException("Invalid state");
     }
     $mapper = SimMapper::getInstance();
     if ($newState === LifeCycleModel::STATUS_RESTORE) {
         $result = $mapper->restoreSuspendedLifeCycleStateSync($simId);
     } else {
         //find operation cost
         $cost = $mapper->getLifeCycleStateCost($oldState, $newState, $simId);
         $result = $mapper->changeLifeCycleStateSync($oldState, $newState, $simId, $cost);
     }
     \App::audit('Changed life cycle status on sims to ' . $newState . '. Handler: ' . $result, null);
     return $result;
 }
예제 #11
0
 public function testGetLegacy()
 {
     $sim = $this->simMapper->findOneById(self::SIM_ID, self::MASTER_ORG_ID);
     $this->assertNotNull($sim);
     $this->assertTrue($sim->getLegacy());
 }
 /**
  * @expectedException \Application\Exceptions\InvalidArgumentException
  */
 public function testGetLocationDetailsFail()
 {
     $sim = new SimModel();
     $this->simMapper->getLocationDetails($sim);
 }
예제 #13
0
 protected function _mapEricssonModelToModel(array $data)
 {
     $data = parent::_mapEricssonModelToModel($data);
     if (isset($data['entity']) && isset($data['entity']['universeType']) && ($universeType = AlarmRuleMapper::getInstance()->mapUniverseFromEricsson($data['entity']['universeType']))) {
         $data['entity']['universeType'] = $universeType;
         if (isset($data['entity']['customer']['id'])) {
             $data['entity']['customerId'] = $data['entity']['customer']['id'];
             if (isset($data['entity']['customer']['name'])) {
                 $data['entity']['customerName'] = $data['entity']['customer']['name'];
             }
             unset($data['entity']['customer']);
         }
         if (isset($data['entity']['billingAccount']['id'])) {
             $data['entity']['billingAccountId'] = $data['entity']['billingAccount']['id'];
             if (isset($data['entity']['billingAccount']['name'])) {
                 $data['entity']['billingAccountName'] = $data['entity']['billingAccount']['name'];
             }
             unset($data['entity']['billingAccount']);
         }
         if (isset($data['entity']['commercialGroup']['id'])) {
             $data['entity']['commercialGroupId'] = $data['entity']['commercialGroup']['id'];
             if (isset($data['entity']['commercialGroup']['name'])) {
                 $data['entity']['commercialGroupName'] = $data['entity']['commercialGroup']['name'];
             }
             unset($data['entity']['commercialGroup']);
         }
         if (isset($data['entity']['customerId'])) {
             $data['entity']['customerId'] = OrgCustomerMapper::buildOrgId($data['entity']['customerId']);
         }
         if (isset($data['entity']['subscriptionId'])) {
             foreach ($data['entity']['subscriptionId'] as &$simId) {
                 if (isset($simId['type'])) {
                     $idType = SimMapper::mapSubscriptionIdFromEricsson($simId['type']);
                     $simId['type'] = $idType;
                 }
             }
         }
         if (isset($data['businessRule'])) {
             foreach ($data['businessRule'] as &$businessRule) {
                 $businessRule = AlarmRuleMapper::getInstance()->mapBusinessRuleToModel($businessRule);
             }
         }
     }
     if (isset($data['state']) && ($state = $this->_mapStateToModel($data['state']))) {
         $data['state'] = $state;
     }
     if (isset($data['alarmRule']['id'])) {
         $data['alarmRuleId'] = $data['alarmRule']['id'];
         if (isset($data['alarmRule']['name'])) {
             $data['alarmRuleName'] = $data['alarmRule']['name'];
         }
         unset($data['alarmRule']);
     }
     $alarmRuleMapper = AlarmRuleMapper::getInstance();
     if (isset($data['severity']) && ($severity = $alarmRuleMapper->mapSeverityFromEricsson($data['severity']))) {
         $data['severity'] = $severity;
     }
     if (isset($data['condition']) && ($condition = $alarmRuleMapper->mapConditionFromEricsson($data['condition']))) {
         $data['condition'] = $condition;
     }
     return $data;
 }