Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed PUT / POST handling on multiple instance and mandatory resources. #51

Merged
merged 1 commit into from Mar 14, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 19 additions & 21 deletions api/tests/test_client_define_defaults.cc
Original file line number Diff line number Diff line change
Expand Up @@ -589,8 +589,7 @@ TEST_F(TestClientDefineDefaultsWithDaemon, AwaClient_get_default_value_from_crea
AwaClientGetOperation_Free(&getOperation);
}

// FIXME
TEST_F(TestClientDefineDefaultsWithDaemon, DISABLED_AwaClient_get_default_value_from_created_custom_object_instance_objectlink_array_resource)
TEST_F(TestClientDefineDefaultsWithDaemon, AwaClient_get_default_value_from_created_custom_object_instance_objectlink_array_resource)
{
//Define our custom object
AwaClientDefineOperation * defineOperation = AwaClientDefineOperation_New(session_);
Expand Down Expand Up @@ -836,8 +835,8 @@ TEST_F(TestClientDefineDefaultsWithDaemon, optional_string_array_resource_has_se

const AwaStringArray * valueArray = NULL;
EXPECT_EQ(AwaError_Success, AwaClientGetResponse_GetValuesAsStringArrayPointer(getResponse, "/1000/0/0", &valueArray));
EXPECT_EQ(1u, AwaStringArray_GetValueCount(valueArray));
EXPECT_STREQ("", AwaStringArray_GetValueAsCString(valueArray, 0));
EXPECT_EQ(0u, AwaStringArray_GetValueCount(valueArray));
//EXPECT_STREQ("", AwaStringArray_GetValueAsCString(valueArray, 0));

AwaClientGetOperation_Free(&getOperation);
}
Expand All @@ -864,8 +863,8 @@ TEST_F(TestClientDefineDefaultsWithDaemon, optional_integer_array_resource_has_s

const AwaIntegerArray * valueArray = NULL;
EXPECT_EQ(AwaError_Success, AwaClientGetResponse_GetValuesAsIntegerArrayPointer(getResponse, "/1000/0/0", &valueArray));
EXPECT_EQ(1u, AwaIntegerArray_GetValueCount(valueArray));
EXPECT_EQ(0, AwaIntegerArray_GetValue(valueArray, 0));
EXPECT_EQ(0u, AwaIntegerArray_GetValueCount(valueArray));
//EXPECT_EQ(0, AwaIntegerArray_GetValue(valueArray, 0));

AwaClientGetOperation_Free(&getOperation);
}
Expand All @@ -892,8 +891,8 @@ TEST_F(TestClientDefineDefaultsWithDaemon, optional_float_array_resource_has_sen

const AwaFloatArray * valueArray = NULL;
EXPECT_EQ(AwaError_Success, AwaClientGetResponse_GetValuesAsFloatArrayPointer(getResponse, "/1000/0/0", &valueArray));
EXPECT_EQ(1u, AwaFloatArray_GetValueCount(valueArray));
EXPECT_EQ(0.0f, AwaFloatArray_GetValue(valueArray, 0));
EXPECT_EQ(0u, AwaFloatArray_GetValueCount(valueArray));
//EXPECT_EQ(0.0f, AwaFloatArray_GetValue(valueArray, 0));

AwaClientGetOperation_Free(&getOperation);
}
Expand All @@ -920,8 +919,8 @@ TEST_F(TestClientDefineDefaultsWithDaemon, optional_boolean_array_resource_has_s

const AwaBooleanArray * valueArray = NULL;
EXPECT_EQ(AwaError_Success, AwaClientGetResponse_GetValuesAsBooleanArrayPointer(getResponse, "/1000/0/0", &valueArray));
EXPECT_EQ(1u, AwaBooleanArray_GetValueCount(valueArray));
EXPECT_FALSE(AwaBooleanArray_GetValue(valueArray, 0));
EXPECT_EQ(0u, AwaBooleanArray_GetValueCount(valueArray));
//EXPECT_FALSE(AwaBooleanArray_GetValue(valueArray, 0));

AwaClientGetOperation_Free(&getOperation);
}
Expand All @@ -948,13 +947,12 @@ TEST_F(TestClientDefineDefaultsWithDaemon, optional_time_array_resource_has_sens

const AwaTimeArray * valueArray = NULL;
EXPECT_EQ(AwaError_Success, AwaClientGetResponse_GetValuesAsTimeArrayPointer(getResponse, "/1000/0/0", &valueArray));
EXPECT_EQ(1u, AwaTimeArray_GetValueCount(valueArray));
EXPECT_EQ(0, AwaTimeArray_GetValue(valueArray, 0));
EXPECT_EQ(0u, AwaTimeArray_GetValueCount(valueArray));
//EXPECT_EQ(0, AwaTimeArray_GetValue(valueArray, 0));

AwaClientGetOperation_Free(&getOperation);
}

// FIXME:
TEST_F(TestClientDefineDefaultsWithDaemon, optional_opaque_array_resource_has_sensible_default)
{
ObjectDescription object = { 1000, "Object1000", 0, 1, {
Expand All @@ -977,10 +975,10 @@ TEST_F(TestClientDefineDefaultsWithDaemon, optional_opaque_array_resource_has_se

const AwaOpaqueArray * valueArray = NULL;
EXPECT_EQ(AwaError_Success, AwaClientGetResponse_GetValuesAsOpaqueArrayPointer(getResponse, "/1000/0/0", &valueArray));
EXPECT_EQ(1u, AwaOpaqueArray_GetValueCount(valueArray));
AwaOpaque value = AwaOpaqueArray_GetValue(valueArray, 0);
EXPECT_EQ(NULL, value.Data);
EXPECT_EQ(0u, value.Size);
EXPECT_EQ(0u, AwaOpaqueArray_GetValueCount(valueArray));
// AwaOpaque value = AwaOpaqueArray_GetValue(valueArray, 0);
// EXPECT_EQ(NULL, value.Data);
// EXPECT_EQ(0u, value.Size);

AwaClientGetOperation_Free(&getOperation);
}
Expand All @@ -1007,10 +1005,10 @@ TEST_F(TestClientDefineDefaultsWithDaemon, optional_objectlink_array_resource_ha

const AwaObjectLinkArray * valueArray = NULL;
EXPECT_EQ(AwaError_Success, AwaClientGetResponse_GetValuesAsObjectLinkArrayPointer(getResponse, "/1000/0/0", &valueArray));
EXPECT_EQ(1u, AwaObjectLinkArray_GetValueCount(valueArray));
AwaObjectLink value = AwaObjectLinkArray_GetValue(valueArray, 0);
EXPECT_EQ(0, value.ObjectID);
EXPECT_EQ(0, value.ObjectInstanceID);
EXPECT_EQ(0u, AwaObjectLinkArray_GetValueCount(valueArray));
// AwaObjectLink value = AwaObjectLinkArray_GetValue(valueArray, 0);
// EXPECT_EQ(0, value.ObjectID);
// EXPECT_EQ(0, value.ObjectInstanceID);

AwaClientGetOperation_Free(&getOperation);
}
Expand Down
63 changes: 63 additions & 0 deletions api/tests/test_subscribe_operation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -863,6 +863,69 @@ TEST_F(TestSubscribeToChangeWithConnectedSession, AwaClientSession_AwaChangeSet_
ASSERT_TRUE(NULL == operation);
}

TEST_F(TestSubscribeToChangeWithConnectedSession, AwaClientSubscribeOperation_Subscribe_to_multiple_instance_resource_changes)
{
struct ChangeCallbackHandler2 : public TestSubscribeToChangeWithConnectedSession
{
int count;

ChangeCallbackHandler2() : count(0) {}

void callbackHandler(const AwaChangeSet * changeSet)
{
count ++;

ASSERT_TRUE(NULL != changeSet);
AwaPathIterator * iterator = AwaChangeSet_NewPathIterator(changeSet);
ASSERT_TRUE(NULL != iterator);
EXPECT_TRUE(AwaPathIterator_Next(iterator));
EXPECT_STREQ("/3/0/6", AwaPathIterator_Get(iterator));
EXPECT_FALSE(AwaPathIterator_Next(iterator));

const AwaIntegerArray * valueArray = NULL;
AwaChangeSet_GetValuesAsIntegerArrayPointer(changeSet, "/3/0/6", &valueArray);
ASSERT_TRUE(NULL != valueArray);
EXPECT_EQ(12345, AwaIntegerArray_GetValue(valueArray, 0));
EXPECT_EQ(54321, AwaIntegerArray_GetValue(valueArray, 1));

AwaPathIterator_Free(&iterator);

}
void TestBody() {}
};
ChangeCallbackHandler2 cbHandler;

AwaClientSubscribeOperation * operation = AwaClientSubscribeOperation_New(session_);
ASSERT_TRUE(NULL != operation);

AwaClientChangeSubscription * changeSubscription = AwaClientChangeSubscription_New("/3/0/6", ChangeCallbackRunner, &cbHandler);

ASSERT_EQ(AwaError_Success, AwaClientSubscribeOperation_AddChangeSubscription(operation, changeSubscription));

EXPECT_EQ(AwaError_Success, AwaClientSubscribeOperation_Perform(operation, defaults::timeout));

// set via client api to trigger notification.
AwaClientSetOperation * setOperation = AwaClientSetOperation_New(session_);
ASSERT_TRUE(NULL != setOperation);
ASSERT_EQ(AwaError_Success, AwaClientSetOperation_AddArrayValueAsInteger(setOperation, "/3/0/6", 0, 12345));
ASSERT_EQ(AwaError_Success, AwaClientSetOperation_AddArrayValueAsInteger(setOperation, "/3/0/6", 1, 54321));
EXPECT_EQ(AwaError_Success, AwaClientSetOperation_Perform(setOperation, defaults::timeout));
AwaClientSetOperation_Free(&setOperation);

ASSERT_EQ(AwaError_Success, AwaClientSession_Process(session_, defaults::timeout));

cbHandler.count = 0;
AwaClientSession_DispatchCallbacks(session_);
ASSERT_EQ(1, cbHandler.count);


ASSERT_EQ(AwaError_Success, AwaClientChangeSubscription_Free(&changeSubscription));
ASSERT_TRUE(NULL == changeSubscription);

ASSERT_EQ(AwaError_Success, AwaClientSubscribeOperation_Free(&operation));
ASSERT_TRUE(NULL == operation);
}



// Test ChangeSet functions
Expand Down
Loading