+
+ policyService
+ .getPolicyInstancesByType(policyTypeId)
+ .subscribe(
+ (policyinstances) =>
+ expect(policyinstances).toEqual(
+ expectedPolicyInstances,
+ "should return expected Policy Instances"
+ ),
+ fail
+ );
+
+ const req = httpTestingController.expectOne(
+ basePath +
+ apiVersion2 +
+ "/" +
+ policyService.policyPath +
+ "?" +
+ "policytype_id=" +
+ policyTypeId
+ );
+ expect(req.request.method).toEqual("GET");
+
+ req.flush(expectedPolicyInstances);
+ });
+
+ it("#getPolicyInstance should return one policy instance", () => {
+ const policyId = "2000";
+ const expectedPolicyInstance = {
+ policy_id: "2000",
+ policytype_id: "1",
+ ric_id: "ric1",
+ policy_data: "",
+ service_id: "service1",
+ lastModified: "",
+ } as PolicyInstance;
+
+ policyService
+ .getPolicyInstance(policyId)
+ .subscribe(
+ (policyinstance) =>
+ expect(policyinstance).toEqual(
+ expectedPolicyInstance,
+ "should return expected Policy Instances"
+ ),
+ fail
+ );
+
+ const req = httpTestingController.expectOne(
+ basePath + apiVersion2 + "/" + policyService.policyPath + "/" + policyId
+ );
+ expect(req.request.method).toEqual("GET");
+
+ req.flush(expectedPolicyInstance);
+ });
+
+ it("#getPolicyStatus should return policy status", () => {
+ const policyId = "2000";
+ const expectedPolicyStatus = {
+ last_modified: "modified",
+ } as PolicyStatus;
+
+ policyService
+ .getPolicyStatus(policyId)
+ .subscribe(
+ (policyinstance) =>
+ expect(policyinstance).toEqual(
+ expectedPolicyStatus,
+ "should return expected Policy status"
+ ),
+ fail
+ );
+
+ const req = httpTestingController.expectOne(
+ basePath +
+ apiVersion2 +
+ "/" +
+ policyService.policyPath +
+ "/" +
+ policyId +
+ "/status"
+ );
+ expect(req.request.method).toEqual("GET");
+
+ req.flush(expectedPolicyStatus);
+ });
+
+ it("#putPolicy should return ok response", () => {
+ const createPolicyInstance = { policy_id: "2000" } as CreatePolicyInstance;
+
+ policyService
+ .putPolicy(createPolicyInstance)
+ .subscribe(
+ (response) =>
+ expect(response.status).toEqual(
+ 200,
+ "should return expected response"
+ ),
+ fail
+ );
+
+ const req = httpTestingController.expectOne(
+ basePath + apiVersion2 + "/" + policyService.policyPath
+ );
+ expect(req.request.method).toEqual("PUT");
+
+ req.flush(200);
+ });
+
+ it("#deletePolicy should return ok response", () => {
+ const policyId = "2000";
+
+ policyService
+ .deletePolicy(policyId)
+ .subscribe(
+ (response) =>
+ expect(response.status).toEqual(
+ 200,
+ "should return expected response"
+ ),
+ fail