private function _genStockNotification($transactionId) { $list = array(123, 456, 789); $res = new \Application\Proto\AsyncResponse(); $res->setOperation('PreInventory/Publish'); $res->setChargedCost(0); $res->setTotalSubscriptions(count($list)); // Set one failed item $failedSim = new \Application\Proto\SubscriptionId(); $failedSim->setType(\Application\Proto\SubscriptionId\IdType::ICC); $failedSim->setId($list[0]); $failed = new \Application\Proto\FailedSubscription(); $failed->setSubscription($failedSim); $failed->setReason('Unknown reason'); $res->addFailed($failed); $result = new \Application\Proto\Result(); $result->setCode('OK'); $result->setReason('Operation successful'); $res->setResult($result); $req = new \Application\Proto\AsyncNotification\Service\Request(); $req->setToken($transactionId); $req->setProto('business.common.AsyncResponse'); $req->message = $res; return $req; }
public function testNotifyBusinessAction() { $orgId = \App_Test_PHPUnit_Framework_TestCase::CUSTOMER_ORG_ID; $proto = new \Application\Proto\AsyncNotification\Service\BusinessRuleResponse(); $proto->setAlarmRuleCondition(\Application\Proto\AlarmRuleCondition::CONSUMPTION_D_DATA_THR_1); $proto->setAlarmRuleId('alarmRuleId1'); $proto->setAlarmRuleName('pepito'); $businessRule = new \Application\Proto\BusinessRule(); $businessRule->setBusinessRuleType(\Application\Proto\BusinessRuleType::DISABLE_DATA); $proto->setBusinessRule($businessRule); $subscription = new \Application\Proto\SubscriptionId(); $subscription->setType(\Application\Proto\SubscriptionId\IdType::ID); $subscription->setId('1'); $failed = new \Application\Proto\FailedSubscription(); $failed->setSubscription($subscription); $failed->setReason('Reason in da mix'); $proto->setFailed(array($failed)); $proto->setOrganizationId(\Application\Model\Mapper\OrganizationMapper::cleanOrgId($orgId)); $result = new \Application\Proto\Result(); $result->setCode(0); $proto->setResult($result); $proto->setTotalSubscriptions(1); return $this->_testNotify($proto, 'business.service.asyncnotification.BusinessRuleResponse'); }