/* **************************************************************************** * * entityTypeFilterNotExist - * */ TEST(mongoQueryContextExistEntity, entityTypeFilterNotExist) { HttpStatusCode ms; QueryContextRequest req; QueryContextResponse res; utInit(); /* Prepare database */ prepareDatabase(); /* Forge the request (from "inside" to "outside") */ EntityId en("E1", "", "false"); req.entityIdVector.push_back(&en); /* Define filter scope */ Scope sc; sc.type = "FIWARE::Filter::Existence"; sc.oper = "not"; sc.value = "entity::type"; req.restriction.scopeVector.push_back(&sc); /* Invoke the function in mongoBackend library */ ms = mongoQueryContext(&req, &res, "", servicePathVector , uriParams); /* Check response is as expected */ EXPECT_EQ(SccOk, ms); EXPECT_EQ(SccNone, res.errorCode.code); EXPECT_EQ("", res.errorCode.reasonPhrase); EXPECT_EQ("", res.errorCode.details); ASSERT_EQ(1, res.contextElementResponseVector.size()); /* Context Element response # 1 */ EXPECT_EQ("E1", RES_CER(0).entityId.id); EXPECT_EQ("", RES_CER(0).entityId.type); EXPECT_EQ("false", RES_CER(0).entityId.isPattern); ASSERT_EQ(1, RES_CER(0).contextAttributeVector.size()); EXPECT_EQ("A1", RES_CER_ATTR(0, 0)->name); EXPECT_EQ("TA1", RES_CER_ATTR(0, 0)->type); EXPECT_EQ("val1b", RES_CER_ATTR(0, 0)->value); EXPECT_EQ(SccOk, RES_CER_STATUS(0).code); EXPECT_EQ("OK", RES_CER_STATUS(0).reasonPhrase); EXPECT_EQ(0, RES_CER_STATUS(0).details.size()); /* Release connection */ mongoDisconnect(); utExit(); }
/* **************************************************************************** * * noPatternAttrsSubset - * * Discover: E3 - (A1, A2) * Result: E3 - (A1, A2) - http://cr1.com */ TEST(mongoContextProvidersUpdateRequest, noPatternAttrsSubset) { HttpStatusCode ms; UpdateContextRequest req; UpdateContextResponse res; /* Prepare database */ utInit(); prepareDatabase(); /* Forge the request (from "inside" to "outside") */ ContextElement ce; ce.entityId.fill("E3", "T3", "false"); ContextAttribute ca1("A1", "TA1", "new_val"); ContextAttribute ca2("A2", "TA2", "new_val"); ce.contextAttributeVector.push_back(&ca1); ce.contextAttributeVector.push_back(&ca2); req.contextElementVector.push_back(&ce); req.updateActionType.set("UPDATE"); /* Invoke the function in mongoBackend library */ ms = mongoUpdateContext(&req, &res, "", servicePathVector, uriParams); /* Check response is as expected */ EXPECT_EQ(SccOk, ms); EXPECT_EQ(SccNone, res.errorCode.code); EXPECT_EQ(0, res.errorCode.reasonPhrase.size()); EXPECT_EQ(0, res.errorCode.details.size()); ASSERT_EQ(1,res.contextElementResponseVector.size()); EXPECT_EQ("E3", RES_CER(0).entityId.id); EXPECT_EQ("T3", RES_CER(0).entityId.type); EXPECT_EQ("false", RES_CER(0).entityId.isPattern); ASSERT_EQ(2, RES_CER(0).contextAttributeVector.size()); EXPECT_EQ("A1", RES_CER_ATTR(0, 0)->name); EXPECT_EQ("TA1", RES_CER_ATTR(0, 0)->type); EXPECT_EQ("A2", RES_CER_ATTR(0, 1)->name); EXPECT_EQ("TA2", RES_CER_ATTR(0, 1)->type); EXPECT_EQ(SccFound, RES_CER_STATUS(0).code); EXPECT_EQ("Found", RES_CER_STATUS(0).reasonPhrase); EXPECT_EQ("http://cr1.com", RES_CER_STATUS(0).details); /* Release connection */ mongoDisconnect(); utExit(); }
/* **************************************************************************** * * entityTypeWithoutFilter - * */ TEST(mongoQueryContextExistEntity, entityTypeWithoutFilter) { HttpStatusCode ms; QueryContextRequest req; QueryContextResponse res; utInit(); /* Prepare database */ prepareDatabase(); /* Forge the request (from "inside" to "outside") */ EntityId en("E1", "", "false"); req.entityIdVector.push_back(&en); /* Invoke the function in mongoBackend library */ ms = mongoQueryContext(&req, &res, "", servicePathVector , uriParams); /* Check response is as expected */ EXPECT_EQ(SccOk, ms); EXPECT_EQ(SccNone, res.errorCode.code); EXPECT_EQ("", res.errorCode.reasonPhrase); EXPECT_EQ("", res.errorCode.details); ASSERT_EQ(2, res.contextElementResponseVector.size()); /* Context Element response # 1 */ EXPECT_EQ("E1", RES_CER(0).entityId.id); EXPECT_EQ("T1", RES_CER(0).entityId.type); EXPECT_EQ("false", RES_CER(0).entityId.isPattern); ASSERT_EQ(1, RES_CER(0).contextAttributeVector.size()); EXPECT_EQ("A1", RES_CER_ATTR(0, 0)->name); EXPECT_EQ("TA1", RES_CER_ATTR(0, 0)->type); EXPECT_EQ("val1", RES_CER_ATTR(0, 0)->stringValue); EXPECT_EQ(SccOk, RES_CER_STATUS(0).code); EXPECT_EQ("OK", RES_CER_STATUS(0).reasonPhrase); EXPECT_EQ("", RES_CER_STATUS(0).details); /* Context Element response # 2 */ EXPECT_EQ("E1", RES_CER(1).entityId.id); EXPECT_EQ("", RES_CER(1).entityId.type); EXPECT_EQ("false", RES_CER(1).entityId.isPattern); ASSERT_EQ(1, RES_CER(1).contextAttributeVector.size()); EXPECT_EQ("A1", RES_CER_ATTR(1, 0)->name); EXPECT_EQ("TA1", RES_CER_ATTR(1, 0)->type); EXPECT_EQ("val1b", RES_CER_ATTR(1, 0)->stringValue); EXPECT_EQ(SccOk, RES_CER_STATUS(1).code); EXPECT_EQ("OK", RES_CER_STATUS(1).reasonPhrase); EXPECT_EQ(0, RES_CER_STATUS(1).details.size()); utExit(); }