public function isValid($data, $context = null) { if (empty($data)) { return true; } if ($data == -1) { return true; } if (!isset($context)) { $this->_error(self::INVALID_SIM); return false; } $sim = new SimModel($context); if (!$sim->getCustomer()) { $this->_error(self::INVALID_CUSTOMER); return false; } $simApns = $sim->getApns(); $custApns = $sim->getCustomer()->getApnList(); $apn = $simApns[$data - 1]; if (!$apn) { $this->_error(self::INVALID_APN_INDEX, $data); return false; } if (!$custApns[$apn]) { $this->_error(self::APN_IS_NOT_STATIC, $data); return false; } return true; }
/** * @dataProvider dataProvider */ public function testGetLocationDetails($imsi, $data) { $sim = new SimModel(); $sim->setImsi($imsi); $this->simMapper->getLocationDetails($sim); $this->assertNotNull($sim->getLocationManual()); $this->checkModelAgainstStruct($sim->getLocationManual(), 'presence test', $data['location']['provisioned']); }
public function tearDown() { if ($this->_sim && $this->_sim->getId()) { $this->_sim->delete(); } if ($this->_user->getId()) { $this->_user->delete(); } }
public function isValid($data, $context = null, $removeNotPresentFields = false) { $sim = new SimModel($context); $org = $sim->getCustomer(); if (empty($org)) { $this->_messages = array(self::CUSTOMER_MISSING => $this->_messageTemplatesBilling[self::CUSTOMER_MISSING]); return false; } if (!$org->hasBillingAccountId($data)) { $this->_messages = array(self::BILLING_ACCOUNT_NOT_FOUND => $this->_messageTemplatesBilling[self::BILLING_ACCOUNT_NOT_FOUND]); return false; } return true; }
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)); }
protected function getSim() { $id = $this->_getParam('id'); if (!strlen((string) $id)) { throw new AppEx\InvalidArgumentException('No Id given'); } $sim = SimModel::find($id); if (empty($sim)) { throw new AppEx\NotFoundException("Sim {$id} not found"); } return $sim; }
public function isValid($data, $context = null, $removeNotPresentFields = false) { if (!$context) { return true; } $sim = new SimModel($context); $apn = $sim->getStaticApn(); if (!$apn) { return true; } $vpn = $sim->getCustomer()->getVpnFromApn($apn); if (!$vpn || !$vpn->staticAddressing) { return true; } try { $this->setNetwork($vpn->network, $vpn->mask); } catch (\Exception $e) { $this->_error(self::INVALID_VALUE); return false; } return parent::isValid($data, $context, $removeNotPresentFields); }
protected function _getTimeAndConsumptionVoucherEricsson(SimModel $sim) { /** @var $req \Application\Proto\Subscription\ExpenseDetail\Response */ $req = $this->_createProto(self::METHOD_NAME_GET_TIME_AND_CONSUMPTION_VOUCHER); // Amplia uses the IMSI to identify the SIM $id = new \Application\Proto\SubscriptionId(); $id->setId($sim->getId()); $id->setType(\Application\Proto\SubscriptionId\IdType::ID); $req->setSubscriptionId($id); $response = $this->_sendRequest(self::METHOD_NAME_GET_TIME_AND_CONSUMPTION_VOUCHER, array('protoMessage' => $req)); if ($this->_checkGetResponse($response)) { $data = $response->serialize(new Codec\PhpArray()); $data = $this->_convertFieldNamesToCammelCase($data); if (isset($data['timeAndConsumption'])) { return $data['timeAndConsumption']; } return array(); } return NULL; }
public static function getSubscriptionId(SimModel $sim) { $subs = new SubscriptionId(); switch (true) { case $sim->getId() !== null: $subs->setType(SubscriptionId\IdType::ID); $subs->setId($sim->getId()); break; case $sim->getIcc() !== null: $subs->setType(SubscriptionId\IdType::ICC); $subs->setId($sim->getIcc()); break; case $sim->getImsi() !== null: $subs->setType(SubscriptionId\IdType::IMSI); $subs->setId($sim->getImsi()); break; case $sim->getMsisdn() !== null: $subs->setType(SubscriptionId\IdType::MSISDN); $subs->setId($sim->getMsisdn()); break; default: throw new InvalidArgumentException("Sim must have one identifier at least"); } return $subs; }
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); }
/** * Add alarms list to sim * * @param SimModel $sim */ protected function _addAlarms(SimModel $sim) { try { // Aggregators cannot list alarms, but they can retrieve // alarm list for a sim. Strange behavior, I know. // GLOBALPORTAL-94024 // $dumbModel = new AlarmModel(); // $this->_helper->allowed('list', $dumbModel); $result = array(); /** * @var $alarmService \Application\Service\AlarmService */ $alarmService = \Application\Service\AlarmService::getInstance(); //prepare filter $filterValues = array(); $filterValues[AlarmFilterFields::SIM_ICC] = $sim->getIcc(); $filterValues[AlarmFilterFields::STATE] = "!" . AlarmModel::STATE_CLOSED; $filterValues['sortBy'] = AlarmSortingFields::OPEN_TIME; if (\App::getOrgUserLogged()->type == OrgAggregatorModel::ORG_TYPE) { $filterValues[AlarmFilterFields::ALARM_TYPE] = "!" . AlarmModel::TYPE_SUPERVISION; } $filterList = $alarmService->buildFilterList($filterValues); $alarms = $alarmService->listAll($filterList); $alarms->getIterator()->addPlugin(new Stream\Plugin\Allowed(array('permission' => 'read'))); $alarms->getIterator()->addPlugin(new Stream\Plugin\FilterNotAllowedFields(array('permission' => 'read_field'))); // Add list to sim response $sim->setAlarms($alarms->getItems()); } catch (\Exception $e) { App::log()->err("An exception occurred while retrieving alarms: " . $e->getMessage()); // No, do nothing } }
public function testOrganizationFieldType() { $sim = SimModel::find(self::SIM_ID); $this->assertNotNull($sim); // Test setters $sim->setServiceProviderEnablerId(self::PROVIDER_ENABLER_ORG_ID); // Test getters $id = $sim->getServiceProviderEnablerId(); $this->assertNotEmpty($id); $this->assertTrue(is_string($id)); $name = $sim->getServiceProviderEnablerName(); $this->assertNotEmpty($name); $this->assertTrue(is_string($name)); $org = $sim->getServiceProviderEnabler(); $this->assertNotEmpty($org); $this->assertInstanceOf('\\Application\\Model\\Organization\\OrgServiceProviderModel', $org); }