Skip to content
This repository has been archived by the owner on Jun 25, 2024. It is now read-only.

Commit

Permalink
1)Test cases modified as per new design.
Browse files Browse the repository at this point in the history
2)TestApp changed to demo changed lib.
3)Accept Terms and conditions no longer supported.Instead CreateUser includes json field for "acceptTermsAndConditions".
4)Some of the lib methods added with preProcessing handler to store values to shared prefs(account activation code, RuleId's).
  • Loading branch information
Gutta, RaghavendraX committed Mar 2, 2015
1 parent 1b22c32 commit 0965775
Show file tree
Hide file tree
Showing 20 changed files with 622 additions and 443 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@

import com.intel.iotkitlib.AccountManagement;
import com.intel.iotkitlib.RequestStatusHandler;
import com.intel.iotkitlib.http.CloudResponse;
import com.intel.iotkitlib.utils.Utilities;

import org.json.JSONException;

Expand All @@ -51,99 +53,99 @@ private void waitForServerResponse(Object object) {
public void testCreateAnAccount() {
AccountManagement accountManagement = new AccountManagement(new RequestStatusHandler() {
@Override
public void readResponse(int responseCode, String response) {
//setResponse(responseCode, response);
assertEquals(201, responseCode);
public void readResponse(CloudResponse response) {
//setResponse(response.getCode(), response);
assertEquals(201, response.getCode());
serverResponse = true;
}
});

assertEquals(true, accountManagement.createAnAccount("UnitTesting"));
CloudResponse response = accountManagement.createAnAccount(getAccountName());
assertEquals(true, response.getStatus());
waitForServerResponse(accountManagement);
}

public void testGetAccountInformation() {
AccountManagement accountManagement = new AccountManagement(new RequestStatusHandler() {
@Override
public void readResponse(int responseCode, String response) {
//setResponse(responseCode, response);
assertEquals(200, responseCode);
public void readResponse(CloudResponse response) {
//setResponse(response.getCode(), response);
assertEquals(200, response.getCode());
serverResponse = true;
}
});

assertEquals(true, accountManagement.getAccountInformation());
CloudResponse response = accountManagement.getAccountInformation();
assertEquals(true, response.getStatus());
waitForServerResponse(accountManagement);
}

public void testGetAccountActivationCode() {
AccountManagement accountManagement = new AccountManagement(new RequestStatusHandler() {
@Override
public void readResponse(int responseCode, String response) {
//setResponse(responseCode, response);
assertEquals(200, responseCode);
public void readResponse(CloudResponse response) {
//setResponse(response.getCode(), response);
assertEquals(200, response.getCode());
serverResponse = true;
}
});

assertEquals(true, accountManagement.getAccountActivationCode());
CloudResponse response = accountManagement.getAccountActivationCode();
assertEquals(true, response.getStatus());
waitForServerResponse(accountManagement);
}


public void testRenewAccountActivationCode() {
AccountManagement accountManagement = new AccountManagement(new RequestStatusHandler() {
@Override
public void readResponse(int responseCode, String response) {
//setResponse(responseCode, response);
assertEquals(200, responseCode);
public void readResponse(CloudResponse response) {
//setResponse(response.getCode(), response);
assertEquals(200, response.getCode());
serverResponse = true;
}
});

assertEquals(true, accountManagement.renewAccountActivationCode());
CloudResponse response = accountManagement.renewAccountActivationCode();
assertEquals(true, response.getStatus());
waitForServerResponse(accountManagement);
}

public void testUpdateAnAccount() {
AccountManagement accountManagement = new AccountManagement(new RequestStatusHandler() {
@Override
public void readResponse(int responseCode, String response) {
//setResponse(responseCode, response);
assertEquals(200, responseCode);
public void readResponse(CloudResponse response) {
//setResponse(response.getCode(), response);
assertEquals(200, response.getCode());
serverResponse = true;
}
});

assertEquals(true, accountManagement.updateAnAccount("UnitTestingNewName"));
CloudResponse response = accountManagement.updateAnAccount(accountName);
assertEquals(true, response.getStatus());
waitForServerResponse(accountManagement);
}

public void testDeleteAnAccount() {
AccountManagement accountManagement = new AccountManagement(new RequestStatusHandler() {
@Override
public void readResponse(int responseCode, String response) {
//setResponse(responseCode, response);
assertEquals(204, responseCode);
public void readResponse(CloudResponse response) {
//setResponse(response.getCode(), response);
assertEquals(204, response.getCode());
serverResponse = true;
}
});

assertEquals(true, accountManagement.deleteAnAccount());
CloudResponse response = accountManagement.deleteAnAccount();
assertEquals(true, response.getStatus());
waitForServerResponse(accountManagement);
}

public void testAddAnotherUserToYourAccount() throws JSONException {
AccountManagement accountManagement = new AccountManagement(new RequestStatusHandler() {
@Override
public void readResponse(int responseCode, String response) {
//setResponse(responseCode, response);
assertEquals(200, responseCode);
public void readResponse(CloudResponse response) {
//setResponse(response.getCode(), response);
assertEquals(200, response.getCode());
serverResponse = true;
}
});

assertEquals(true, accountManagement.addAnotherUserToYourAccount("1e5f2301-b121-4933-8f32-1abb0af3d777", "545b0cb707024be10dec1152", false));
CloudResponse response = accountManagement.addAnotherUserToYourAccount(Utilities.sharedPreferences.getString("account_id", ""), "545b0cb707024be10dec1152", true);
assertEquals(true, response.getStatus());
waitForServerResponse(accountManagement);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@

import com.intel.iotkitlib.AdvancedDataInquiry;
import com.intel.iotkitlib.RequestStatusHandler;
import com.intel.iotkitlib.http.CloudResponse;
import com.intel.iotkitlib.models.AttributeFilter;
import com.intel.iotkitlib.utils.Utilities;

import org.json.JSONException;

Expand All @@ -40,76 +42,64 @@ private void waitForServerResponse(Object object) {
}
}

public void testAdvancedDataInquiry() throws JSONException {
AdvancedDataInquiry objAdvancedDataInquiry = new AdvancedDataInquiry(new RequestStatusHandler() {
public void testAdvancedDataEnquiry() throws JSONException {
AdvancedDataInquiry objAdvancedDataEnquiry = new AdvancedDataInquiry(new RequestStatusHandler() {
@Override
public void readResponse(int responseCode, String response) {
assertEquals(200, responseCode);
public void readResponse(CloudResponse response) {
assertEquals(200, response.getCode());
serverResponse = true;
}
});
objAdvancedDataInquiry.addGatewayId("qwertyPAD1");
objAdvancedDataInquiry.addGatewayId("devTest");
//objAdvancedDataInquiry.addGatewayId("02-00-86-81-77-15");

objAdvancedDataInquiry.addDeviceId("qwertyPAD1");
objAdvancedDataInquiry.addDeviceId("devTest");
//objAdvancedDataInquiry.addDeviceId("02-00-86-81-77-19");
objAdvancedDataEnquiry.addGatewayId(deviceName);
objAdvancedDataEnquiry.addDeviceId(deviceName);
objAdvancedDataEnquiry.addComponentId(Utilities.getSensorMatch(deviceComponentName).getValue().toString());

objAdvancedDataInquiry.addComponentId("5C09B9F0-E06B-404A-A882-EAC64675A63E");
objAdvancedDataInquiry.addComponentId("BB9E347D-7895-437E-9ECA-8069879090B7");
objAdvancedDataInquiry.addComponentId("b780757a-4a45-40f3-9804-60eee953e8d2");
//objAdvancedDataInquiry.addComponentId("c4d1f4c1-6fb6-4793-b85d-431c6cba647b");
objAdvancedDataEnquiry.setStartTimestamp(0L);
objAdvancedDataEnquiry.setEndTimestamp(System.currentTimeMillis());

objAdvancedDataInquiry.setStartTimestamp(0L);
objAdvancedDataInquiry.setEndTimestamp(System.currentTimeMillis());
/*objAdvancedDataEnquiry.addReturnedMeasureAttributes("attr_1");
objAdvancedDataEnquiry.addReturnedMeasureAttributes("attr_2");
objAdvancedDataEnquiry.addReturnedMeasureAttributes("attr_3");*/

/*objAdvancedDataInquiry.addReturnedMeasureAttribute("attr_1");
objAdvancedDataInquiry.addReturnedMeasureAttribute("attr_2");
objAdvancedDataInquiry.addReturnedMeasureAttribute("attr_3");*/

//objAdvancedDataInquiry.setShowMeasureLocation(true);
//objAdvancedDataEnquiry.setShowMeasureLocation(true);
//dev comp attrs
AttributeFilter devCompAttributeFilter1 = new AttributeFilter("Tags");
devCompAttributeFilter1.addAttributeFilterValue("created from MAC book pro");
devCompAttributeFilter1.addAttributeFilterValue("intel");
//devCompAttributeFilter1.addAttributeFilterValues("Sacramento");

AttributeFilter devCompAttributeFilter2 = new AttributeFilter("componentType");
devCompAttributeFilter2.addAttributeFilterValue("temperature");
/*devCompAttributeFilter2.addAttributeFilterValue("value22");
devCompAttributeFilter2.addAttributeFilterValue("value33");*/
devCompAttributeFilter2.addAttributeFilterValue("temperature.v1.0");

objAdvancedDataInquiry.addDevCompAttributeFilter(devCompAttributeFilter1);
objAdvancedDataInquiry.addDevCompAttributeFilter(devCompAttributeFilter2);
objAdvancedDataEnquiry.addDevCompAttributeFilter(devCompAttributeFilter1);
objAdvancedDataEnquiry.addDevCompAttributeFilter(devCompAttributeFilter2);
//measure comp attrs
/*AttributeFilter measurementAttributeFilter1 = new AttributeFilter("mfilter_1");
measurementAttributeFilter1.addAttributeFilterValue("mValue1");
measurementAttributeFilter1.addAttributeFilterValue("mValue2");
measurementAttributeFilter1.addAttributeFilterValue("mValue3");
measurementAttributeFilter1.addAttributeFilterValues("mValue1");
measurementAttributeFilter1.addAttributeFilterValues("mValue2");
measurementAttributeFilter1.addAttributeFilterValues("mValue3");
AttributeFilter measurementAttributeFilter2 = new AttributeFilter("mfilter_2");
measurementAttributeFilter2.addAttributeFilterValue("mValue11");
measurementAttributeFilter2.addAttributeFilterValue("mValue22");
measurementAttributeFilter2.addAttributeFilterValue("mValue33");
measurementAttributeFilter2.addAttributeFilterValues("mValue11");
measurementAttributeFilter2.addAttributeFilterValues("mValue22");
measurementAttributeFilter2.addAttributeFilterValues("mValue33");
objAdvancedDataInquiry.addMeasurementAttributeFilter(measurementAttributeFilter1);
objAdvancedDataInquiry.addMeasurementAttributeFilter(measurementAttributeFilter2);
objAdvancedDataEnquiry.addMeasurementAttributeFilter(measurementAttributeFilter1);
objAdvancedDataEnquiry.addMeasurementAttributeFilter(measurementAttributeFilter2);
//value filter
AttributeFilter valueFilter = new AttributeFilter("value");
valueFilter.addAttributeFilterValue("filter_value1");
valueFilter.addAttributeFilterValue("filter_value2");
valueFilter.addAttributeFilterValue("filter_value3");
objAdvancedDataInquiry.addValueFilter(valueFilter);*/
valueFilter.addAttributeFilterValues("filter_value1");
valueFilter.addAttributeFilterValues("filter_value2");
valueFilter.addAttributeFilterValues("filter_value3");
objAdvancedDataEnquiry.addValueFilter(valueFilter);*/

/*objAdvancedDataInquiry.setComponentRowLimit(5);
objAdvancedDataInquiry.setCountOnly(true);*/
/*objAdvancedDataEnquiry.setComponentRowLimit(5);
objAdvancedDataEnquiry.setCountOnly(true);*/
//sort
objAdvancedDataInquiry.addSortInfo("Timestamp", "Asc");
objAdvancedDataInquiry.addSortInfo("Value", "Desc");

assertEquals(true, objAdvancedDataInquiry.request());
waitForServerResponse(objAdvancedDataInquiry);
objAdvancedDataEnquiry.addSortInfo("Timestamp", "Asc");
objAdvancedDataEnquiry.addSortInfo("Value", "Desc");
CloudResponse response = objAdvancedDataEnquiry.request();
assertEquals(true, response.getStatus());
waitForServerResponse(objAdvancedDataEnquiry);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@

import com.intel.iotkitlib.AggregatedReportInterface;
import com.intel.iotkitlib.RequestStatusHandler;
import com.intel.iotkitlib.http.CloudResponse;
import com.intel.iotkitlib.models.AttributeFilter;
import com.intel.iotkitlib.utils.Utilities;

import org.json.JSONException;

Expand All @@ -42,50 +44,38 @@ private void waitForServerResponse(Object object) {
public void testAggregatedReportInterface() throws JSONException {
AggregatedReportInterface aggregatedReportInterface = new AggregatedReportInterface(new RequestStatusHandler() {
@Override
public void readResponse(int responseCode, String response) {
assertEquals(200, responseCode);
public void readResponse(CloudResponse response) {
assertEquals(200, response.getCode());
serverResponse = true;
}
});
aggregatedReportInterface.addGatewayId("qwertyPAD1");
//aggregatedReportInterface.addGatewayId("xxxx");
//advancedDataEnquiry.addGatewayId("02-00-86-81-77-15");

aggregatedReportInterface.addDeviceId("qwertyPAD1");
//aggregatedReportInterface.addDeviceId("xxxx");
//advancedDataEnquiry.addDeviceId("02-00-86-81-77-19");

/* aggregatedReportInterface.addComponentId("436e9e78-8772-4898-9957-26930f5eb7e1");
aggregatedReportInterface.addComponentId("9d44c354-7252-4494-8ade-39508bfdbdaf");
aggregatedReportInterface.addComponentId("c4d1f4c1-6fb6-4793-b85d-431c6cba647b");*/
aggregatedReportInterface.addComponentId("5C09B9F0-E06B-404A-A882-EAC64675A63E");
aggregatedReportInterface.addComponentId("BB9E347D-7895-437E-9ECA-8069879090B7");
aggregatedReportInterface.addGatewayId(deviceName);
aggregatedReportInterface.addDeviceId(deviceName);
aggregatedReportInterface.addComponentId(Utilities.getSensorMatch(deviceComponentName).getValue().toString());

aggregatedReportInterface.setStartTimestamp(0L);
aggregatedReportInterface.setEndTimestamp(System.currentTimeMillis());

//report filters
AttributeFilter filter1 = new AttributeFilter("Tags");
filter1.addAttributeFilterValue("created from MAC book pro");
/*filter1.addAttributeFilterValue("California");
filter1.addAttributeFilterValue("Sacramento");*/
filter1.addAttributeFilterValue("intel");

aggregatedReportInterface.addFilter(filter1);

aggregatedReportInterface.setOutputType("json");
aggregatedReportInterface.setLimit(10);
aggregatedReportInterface.setLimit(100);
aggregatedReportInterface.setOffset(0);

aggregatedReportInterface.addAggregationMethod("average");
aggregatedReportInterface.addAggregationMethod("min");
/*aggregatedReportInterface.addDimension("dim1");
aggregatedReportInterface.addDimension("dim2");
aggregatedReportInterface.setCountOnly(true);*/
/*aggregatedReportInterface.addDimensions("dim1");
aggregatedReportInterface.addDimensions("dim2");
aggregatedReportInterface.setReportCountOnly(true);*/
//sort
aggregatedReportInterface.addSortInfo("timeHour", "Asc");
//aggregatedReportInterface.addSortInfo("sortField2", "Desc");

assertEquals(true, aggregatedReportInterface.request());
CloudResponse response = aggregatedReportInterface.request();
assertEquals(true, response.getStatus());
waitForServerResponse(aggregatedReportInterface);
}
}
Loading

0 comments on commit 0965775

Please sign in to comment.