--- /dev/null
+/*
+ * //******************************************************************
+ * //
+ * // Copyright 2016 Samsung Electronics All Rights Reserved.
+ * //
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ * //
+ * // Licensed under the Apache License, Version 2.0 (the "License");
+ * // you may not use this file except in compliance with the License.
+ * // You may obtain a copy of the License at
+ * //
+ * // http://www.apache.org/licenses/LICENSE-2.0
+ * //
+ * // Unless required by applicable law or agreed to in writing, software
+ * // distributed under the License is distributed on an "AS IS" BASIS,
+ * // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * // See the License for the specific language governing permissions and
+ * // limitations under the License.
+ * //
+ * //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+ */
+package com.samsung.ci.test.useractions;
+
+import com.google.gson.Gson;
+import com.samsung.ci.basic.api.MQPublisherAPI;
+import com.samsung.ci.basic.api.Rest;
+import io.restassured.response.Response;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+
+import java.util.List;
+import java.util.Map;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+public class DeviceApiWithoutCloudTest extends BasicUserAction {
+
+ private static final String DEVICE_DUID = "D-0000000-1111-2222-3333-4444444444444";
+ private static final String DEVICE_DUID2 = "D2-0000000-1111-2222-3333-4444444444444";
+ private static final String DEVICE_UNREGISTER_ACTION = "unregister";
+ private static final String DEVICE_NAME = "TV";
+ private static final String DEVICE_TYPE = "tv";
+ private static final String DEVICE_MODEL1 = "standard";
+ private static final String DEVICE_MODEL2 = "standard-new";
+ private static final String DEVICE_PARENT_DUID = "D-55555555-6666-7777-8888-999999999999";
+
+ @BeforeAll
+ public static void info() {
+ //@formatter:off
+ log("Positive case for DeviceApiWithoutCloudTest:\n" +
+ "1. Create new user \n" +
+ "2. Create IoTCloud User\n" +
+ "3. Register device\n" +
+ "4. checkfindByCloudUserUuidExceptModelStandard\n" +
+ "5. Unregister device\n" +
+ "6. Delete IoTCloud User\n");
+ //@formatter:on
+ }
+
+ private void registerDevices(String uuid) {
+ log("Device registration");
+ assertTrue(MQPublisherAPI
+ .deviceRegistrationInDSM(DEVICE_DUID, uuid, DEVICE_NAME, DEVICE_TYPE, DEVICE_MODEL1, DEVICE_PARENT_DUID));
+ assertTrue(MQPublisherAPI
+ .deviceRegistrationInDSM(DEVICE_DUID2, uuid, DEVICE_NAME, DEVICE_TYPE, DEVICE_MODEL2, DEVICE_PARENT_DUID));
+ }
+
+ private void unregisterDevices(String uuid) {
+ log("Device unregistration");
+ assertTrue(MQPublisherAPI.deviceUnRegistrationInDSM(DEVICE_DUID, DEVICE_UNREGISTER_ACTION));
+ assertTrue(MQPublisherAPI.deviceUnRegistrationInDSM(DEVICE_DUID2, DEVICE_UNREGISTER_ACTION));
+ }
+
+ private void checkfindByCloudUserUuidExceptModelStandard(String uuid) {
+ log("checkfindByCloudUserUuidExceptModelStandard");
+ Response resp = Rest.findDeviceByCloudUserUuidExceptModelStandard(uuid);
+ final int size = 1;
+ checkResponseSize(resp, size);
+ }
+
+ private void checkResponseSize(Response resp, int size) {
+ String response = resp.getBody().asString();
+ assertNotNull(response);
+ Gson gson = new Gson();
+ @SuppressWarnings("unchecked")
+ List<Map<String, String>> list = (List<Map<String, String>>) gson.fromJson(response, List.class);
+ assertTrue(list.size() == size);
+ }
+
+ @Test
+ public void testDeviceApiWithoutCloud() throws InterruptedException {
+ log("Create new user for testDeviceApiWithoutCloud scenario");
+ createNewUser();
+ String uuid = "iot-cloud-user-uuid";
+ createIoTUser(USER_EMAIL, uuid);
+
+ registerDevices(uuid);
+ Thread.sleep(TIMEOUT);
+
+ checkfindByCloudUserUuidExceptModelStandard(uuid);
+
+ unregisterDevices(uuid);
+ deleteIoTUser(uuid);
+ }
+
+}