public function testValidateRestrictionsExists() { $restrictions = new RestrictionModel($this->_data); RestrictionMapper::getInstance()->insert($restrictions); $this->_restrictionsIdToDelete = $restrictions->getId(); $this->assertNotNull($restrictions->getId()); $result = $this->_validator->isValid($restrictions->getId()); $this->assertTrue($result); }
public function setUp() { parent::setUp(); $this->_spMapper = \Application\Model\Mapper\ServicePackMapper::getInstance(); $this->_lfMapper = \Application\Model\Mapper\LifeCycleMapper::getInstance(); $this->_restMapper = \Application\Model\Mapper\RestrictionMapper::getInstance(); $this->_tflcMapper = \Application\Model\Mapper\TariffPlanLifeCycleMapper::getInstance(); $this->_tfservMapper = \Application\Model\Mapper\TariffPlanServicesMapper::getInstance(); $this->_servicePackData = array("name" => "SPTesting" . "-" . microtime(true), "description" => "A service pack for integration test", "currency" => self::CURRENCY, "changeCost" => 3000, "whiteList" => array("34696*", "34697*", "34695777888"), "blackList" => array("34666*", "34677*", "34655777888"), "roamingList" => array("34666*", "34677*", "34655777888"), "listsLocked" => true); $this->_lifeCycleData = array("name" => "LifeCycle" . "-" . microtime(true), "description" => "LifeCycle for integration tests", "status" => array(array('status' => LifeCycleModel::STATUS_INACTIVE_NEW, 'timer' => 100, 'transitions' => array(array('destinationStatus' => LifeCycleModel::STATUS_TEST, 'manual' => true, 'automatic' => false), array('destinationStatus' => LifeCycleModel::STATUS_SUSPENDED, 'manual' => true, 'automatic' => true, 'automaticInfo' => array('timerCause' => true, 'firstUseCause' => false, 'voucherCause' => false)))), array('status' => LifeCycleModel::STATUS_TEST, 'vouchers' => array('voice' => array('home' => 234)), 'transitions' => array(array('destinationStatus' => LifeCycleModel::STATUS_ACTIVATION_READY, 'manual' => true, 'automatic' => true, 'automaticInfo' => array('timerCause' => false, 'firstUseCause' => false, 'voucherCause' => true, 'voucherCauseInfo' => array('type' => Model\LifeCycle\VoucherCauseInfoModel::CAUSE_TYPE_ANY, 'vouchers' => array(Model\LifeCycle\VoucherCauseInfoModel::VOUCHER_TYPE_VOICE_HOME)))), array('destinationStatus' => LifeCycleModel::STATUS_SUSPENDED, 'manual' => true, 'automatic' => false))), array('status' => LifeCycleModel::STATUS_ACTIVATION_READY, 'transitions' => array(array('destinationStatus' => LifeCycleModel::STATUS_ACTIVE, 'manual' => false, 'automatic' => true, 'automaticInfo' => array('timerCause' => false, 'firstUseCause' => true, 'voucherCause' => false)), array('destinationStatus' => LifeCycleModel::STATUS_SUSPENDED, 'manual' => true, 'automatic' => false))), array('status' => LifeCycleModel::STATUS_ACTIVE, 'transitions' => array(array('destinationStatus' => LifeCycleModel::STATUS_DEACTIVATED, 'manual' => true, 'automatic' => false), array('destinationStatus' => LifeCycleModel::STATUS_SUSPENDED, 'manual' => true, 'automatic' => false))), array('status' => LifeCycleModel::STATUS_DEACTIVATED, 'transitions' => array(array('destinationStatus' => LifeCycleModel::STATUS_ACTIVE, 'manual' => true, 'automatic' => false), array('destinationStatus' => LifeCycleModel::STATUS_SUSPENDED, 'manual' => true, 'automatic' => false))), array('status' => LifeCycleModel::STATUS_SUSPENDED, 'transitions' => array(array('destinationStatus' => LifeCycleModel::STATUS_DEACTIVATED, 'manual' => true, 'automatic' => false), array('destinationStatus' => LifeCycleModel::STATUS_ACTIVE, 'manual' => true, 'automatic' => false), array('destinationStatus' => LifeCycleModel::STATUS_ACTIVATION_READY, 'manual' => true, 'automatic' => false), array('destinationStatus' => LifeCycleModel::STATUS_TEST, 'manual' => true, 'automatic' => false), array('destinationStatus' => LifeCycleModel::STATUS_INACTIVE_NEW, 'manual' => true, 'automatic' => false), array('destinationStatus' => LifeCycleModel::STATUS_RETIRED, 'manual' => true, 'automatic' => false))), array('status' => LifeCycleModel::STATUS_RETIRED))); $this->_restrictionsData = array('name' => "RestTest" . "-" . microtime(true), 'description' => "Restrinctions for integration test", 'operator' => array(self::OPERATOR), 'voice' => array('mo' => array('home' => true, 'roaming' => true, 'international' => true), 'mt' => array('home' => true, 'roaming' => true, 'international' => true)), 'sms' => array('mo' => array('home' => true, 'roaming' => true, 'international' => true), 'mt' => array('home' => true, 'roaming' => true, 'international' => true)), 'data' => array('home' => false, 'roaming' => false)); $this->_lifeCycleTariffPlanData = array('name' => "LCTPlantesting" . "-" . microtime(true), 'description' => "LifeCycle TariffPlan for integration tests", 'status' => array(array('status' => LifeCycleModel::STATUS_ACTIVE, 'cost' => 20), array('status' => LifeCycleModel::STATUS_DEACTIVATED, 'cost' => 120)), 'transitions' => array(array('statusStart' => LifeCycleModel::STATUS_INACTIVE_NEW, 'statusFinal' => LifeCycleModel::STATUS_ACTIVATION_READY, 'cost' => 12), array('statusStart' => LifeCycleModel::STATUS_INACTIVE_NEW, 'statusFinal' => LifeCycleModel::STATUS_TEST, 'cost' => 12), array('statusStart' => LifeCycleModel::STATUS_INACTIVE_NEW, 'statusFinal' => LifeCycleModel::STATUS_ACTIVATION_PENDANT, 'cost' => 12), array('statusStart' => LifeCycleModel::STATUS_DEACTIVATED, 'statusFinal' => LifeCycleModel::STATUS_ACTIVE, 'cost' => 12), array('statusStart' => LifeCycleModel::STATUS_SUSPENDED, 'statusFinal' => LifeCycleModel::STATUS_RETIRED, 'cost' => 12))); $this->_servicesTariffPlanData = array('name' => "STPlanTesting" . "-" . microtime(true), 'description' => "Services TariffPlan for integration tests", 'defaultData' => array("t2N" => 7, "t2Q" => 8, 'pool' => true), 'data' => array(array('zoneId' => self::ZONE_ID_2, 'destinationId' => self::DESTINATION_ID_2, 'n1' => 1, "n2" => 2, "n3" => 3, "n4" => 4, "n5" => 5, "q1" => 6, "t2N" => 7, "t2Q" => 8, "t4N" => 9, "t4Q" => 10, "t6N" => 11, "t6Q" => 12, 'pool' => true)), 'defaultOrigVoice' => array("t2N" => 7, "t2Q" => 8, 'pool' => true), 'origVoice' => array(array('zoneId' => self::ZONE_ID_2, 'destinationId' => self::DESTINATION_ID_2, "t2N" => 7, "t2Q" => 8, 'pool' => true)), 'defaultTermVoice' => array("t2N" => 7, "t2Q" => 8, 'pool' => true), 'termVoice' => array(array('zoneId' => self::ZONE_ID_1, 'destinationId' => self::DESTINATION_ID_1, "t2N" => 7, "t2Q" => 8, 'pool' => true)), 'defaultSms' => array("t2N" => 1, "t2Q" => 2, 'pool' => true), 'sms' => array(array('zoneId' => self::ZONE_ID_2, 'destinationId' => self::DESTINATION_ID_2, "t2N" => 7, "t2Q" => 8, 'pool' => true))); }
public function setUp() { $this->restictionMapper = RestrictionMapper::getInstance(); $this->_user = $this->_createAuthUser(array('userName' => 'RestrictionUserTest', 'organizationId' => self::PROVIDER_COMMERCIAL_ORG_ID)); }
/** * @param string $id * @return \Application\Model\SimModel */ public function load($id, $org = null, $idType = 'Id') { $mapper = $this->getMapper(); $idType = ucfirst(strtolower($idType)); $sim = $mapper->{'findOneBy' . $idType}($id); if (is_null($sim)) { return null; } //retrieve the restriction: $resMapper = \Application\Model\Mapper\RestrictionMapper::getInstance(); $restrictions = $resMapper->findOneBySubscriptionId($sim->getId()); if (!is_null($restrictions)) { $sim->setRestrictions($restrictions); } //retrive the customer supplservices if ($sim->getCustomer()) { $orgMapper = \Application\Model\Mapper\Organization\OrgCustomerMapper::getInstance(); $customer = $orgMapper->findOneById($sim->getCustomer()->getId()); $supplServicesMapper = \Application\Model\Mapper\SupplServicesMapper::getInstance(); if ($customer->getSupplementaryServicesId()) { $supplServices = $supplServicesMapper->findOneById($customer->getSupplementaryServicesId()); if (!is_null($supplServices)) { $supplServices->setTariffs(array()); $sim->setCustomerSupplServices($supplServices); } } } // Grow the model with additional data try { $mapper->getConsumption($sim); } catch (\Exception $e) { \App::log()->warn($e); } try { $mapper->getLifeCycle($sim); } catch (\Exception $e) { \App::log()->warn($e); } try { $mapper->getPresenceDetails($sim); } catch (\Exception $e) { \App::log()->warn($e); } try { $mapper->getLocationDetails($sim); } catch (\Exception $e) { \App::log()->warn($e); } try { $mapper->getTimeAndConsumptionVoucher($sim); } catch (\Exception $e) { \App::log()->warn($e); } return $sim; }
protected function _changeRestriction(\Application\Proto\SubscriptionSelect $sims, \Application\Model\RestrictionModel $restriction, $watcher) { $methodName = self::METHOD_NAME_CHANGE_RESTRICTION; /** * @var $proto \Application\Proto\Inventory\ChangeRestrictionsQuery */ $proto = $this->_createProto($methodName); $proto->setSubscriptions($sims); $restrictionMapper = RestrictionMapper::getInstance(); $mappedData = $restrictionMapper->_mapModelToEricssonModel($restriction->exportData()); $proto->parse($mappedData, new \DrSlump\Protobuf\Codec\PhpArray()); // Return the transaction ID return $this->_sendAsyncRequest($methodName, $proto, $sims, array(), $watcher); }
protected function _mapEricssonModelToModel(array $data) { $data = parent::_mapEricssonModelToModel($data); // Transformations after "lowercamelcasing" names if (isset($data['lifeCycleState'])) { $data['lifeCycleStatus'] = $this->_mapEricssonEnumToEnum($data['lifeCycleState'], $this->_lifeCycleStatusMap); unset($data['lifeCycleState']); } if (isset($data['simType'])) { $this->_mapEricssonEnumToEnum($data['simType'], $this->_simTypeMap); } if (isset($data['gprsStatus']) && isset($data['gprsStatus']['status'])) { $this->_mapEricssonEnumToEnum($data['gprsStatus']['status'], $this->_connStatusMap); } if (isset($data['ipStatus']) && isset($data['ipStatus']['status'])) { $this->_mapEricssonEnumToEnum($data['ipStatus']['status'], $this->_connStatusMap); } if (isset($data['billingAccount'])) { $this->_mapReference($data, 'billingAccount'); } if (isset($data['servicePack'])) { $this->_mapReference($data, 'servicePack'); } if (isset($data['commercialGroup'])) { $this->_mapReference($data, 'commercialGroup'); } if (isset($data['supervisionGroup '])) { $this->_mapReference($data, 'supervisionGroup'); } // Ericsson issue if (!isset($data['apns']) && isset($data['apn'])) { $data['apns'] = $data['apn']; } if (isset($data['apns'])) { $data['apns'] = array_values($data['apns']); } //Invalid 0 as index... strange ericsson behaivor if (isset($data['staticIpApnIndex']) && !$data['staticIpApnIndex']) { unset($data['staticIpApnIndex']); } if (isset($data['customerId']) && ($customer = OrgService::getInstance()->load($data['customerId']))) { $data['customerCurrency'] = $customer->getCurrency(); if ($currency = EnumeratedService::getInstance()->findCurrencyById($customer->getCurrency())) { $data['customerCurrencyName'] = $currency['name']; } } if (isset($data['restrictions'])) { $data['restrictions'] = RestrictionMapper::getInstance()->mapEricssonModelToModel(array('restrictions' => $data['restrictions'])); } if (isset($data['isLegacy'])) { $data['legacy'] = $data['isLegacy']; unset($data['isLegacy']); } if (isset($data['logisticsProfile'])) { $data['logistics'] = $data['logisticsProfile']; unset($data['logisticsProfile']); } return $data; }