diff --git a/device/iot-device-client/src/main/java/com/microsoft/azure/sdk/iot/device/DeviceTwin/Pair.java b/device/iot-device-client/src/main/java/com/microsoft/azure/sdk/iot/device/DeviceTwin/Pair.java index 2ffde8baf9..eb2ca9a909 100644 --- a/device/iot-device-client/src/main/java/com/microsoft/azure/sdk/iot/device/DeviceTwin/Pair.java +++ b/device/iot-device-client/src/main/java/com/microsoft/azure/sdk/iot/device/DeviceTwin/Pair.java @@ -8,7 +8,7 @@ public class Pair private Type1 key; private Type2 value; - Pair(Type1 t1, Type2 t2) + public Pair(Type1 t1, Type2 t2) { /* **Codes_SRS_Pair_25_001: [**The constructor shall save the key and value representing this Pair.**]** diff --git a/device/iot-device-client/src/test/java/tests/unit/com/microsoft/azure/sdk/iot/device/DeviceTwin/DeviceTwinTest.java b/device/iot-device-client/src/test/java/tests/unit/com/microsoft/azure/sdk/iot/device/DeviceTwin/DeviceTwinTest.java index 7f46e6ba09..f362d40d27 100644 --- a/device/iot-device-client/src/test/java/tests/unit/com/microsoft/azure/sdk/iot/device/DeviceTwin/DeviceTwinTest.java +++ b/device/iot-device-client/src/test/java/tests/unit/com/microsoft/azure/sdk/iot/device/DeviceTwin/DeviceTwinTest.java @@ -1,11 +1,12 @@ // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -package com.microsoft.azure.sdk.iot.device.DeviceTwin; +package tests.unit.com.microsoft.azure.sdk.iot.device.DeviceTwin; import com.microsoft.azure.sdk.iot.deps.serializer.Twin; import com.microsoft.azure.sdk.iot.deps.serializer.TwinChangedCallback; import com.microsoft.azure.sdk.iot.device.*; +import com.microsoft.azure.sdk.iot.device.DeviceTwin.*; import mockit.*; import org.junit.Test; diff --git a/device/iot-device-client/src/test/java/tests/unit/com/microsoft/azure/sdk/iot/device/DeviceTwin/PairTest.java b/device/iot-device-client/src/test/java/tests/unit/com/microsoft/azure/sdk/iot/device/DeviceTwin/PairTest.java index a3721dbeb2..67cf9ccb03 100644 --- a/device/iot-device-client/src/test/java/tests/unit/com/microsoft/azure/sdk/iot/device/DeviceTwin/PairTest.java +++ b/device/iot-device-client/src/test/java/tests/unit/com/microsoft/azure/sdk/iot/device/DeviceTwin/PairTest.java @@ -1,8 +1,9 @@ // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -package com.microsoft.azure.sdk.iot.device.DeviceTwin; +package tests.unit.com.microsoft.azure.sdk.iot.device.DeviceTwin; +import com.microsoft.azure.sdk.iot.device.DeviceTwin.Pair; import org.junit.Test; import static org.junit.Assert.assertEquals; diff --git a/device/iot-device-client/src/test/java/tests/unit/com/microsoft/azure/sdk/iot/device/transport/mqtt/MqttDeviceMethodTest.java b/device/iot-device-client/src/test/java/tests/unit/com/microsoft/azure/sdk/iot/device/transport/mqtt/MqttDeviceMethodTest.java index ea37bd9a0c..f9b46b6ed6 100644 --- a/device/iot-device-client/src/test/java/tests/unit/com/microsoft/azure/sdk/iot/device/transport/mqtt/MqttDeviceMethodTest.java +++ b/device/iot-device-client/src/test/java/tests/unit/com/microsoft/azure/sdk/iot/device/transport/mqtt/MqttDeviceMethodTest.java @@ -1,16 +1,16 @@ // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -package com.microsoft.azure.sdk.iot.device.transport.mqtt; +package tests.unit.com.microsoft.azure.sdk.iot.device.transport.mqtt; import com.microsoft.azure.sdk.iot.device.Message; import com.microsoft.azure.sdk.iot.device.MessageType; import com.microsoft.azure.sdk.iot.device.DeviceTwin.DeviceMethodMessage; import com.microsoft.azure.sdk.iot.device.DeviceTwin.DeviceOperations; -import mockit.Deencapsulation; -import mockit.Mocked; -import mockit.Verifications; +import com.microsoft.azure.sdk.iot.device.transport.mqtt.Mqtt; +import com.microsoft.azure.sdk.iot.device.transport.mqtt.MqttDeviceMethod; +import mockit.*; import org.junit.Test; import java.io.IOException; @@ -70,12 +70,13 @@ public void startSucceedsCalls() throws IOException new Verifications() { { - mockedMqtt.subscribe(anyString); + Deencapsulation.invoke(mockedMqtt, "subscribe", anyString); times = 0; } }; } + @Test public void startSucceedsDoesNotCallsSubscribeIfStarted() throws IOException { @@ -89,7 +90,7 @@ public void startSucceedsDoesNotCallsSubscribeIfStarted() throws IOException new Verifications() { { - mockedMqtt.subscribe(anyString); + Deencapsulation.invoke(mockedMqtt, "subscribe", anyString); maxTimes = 0; } }; @@ -109,10 +110,11 @@ public void stopSucceedsCallsUnSubscribe() throws IOException testMethod.stop(); //assert + new Verifications() { { - mockedMqtt.unsubscribe(anyString); + Deencapsulation.invoke(mockedMqtt, "unsubscribe", anyString); maxTimes = 1; } }; @@ -133,7 +135,7 @@ public void stopSucceedsDoesNotCallUnSubscribeIfStopped() throws IOException new Verifications() { { - mockedMqtt.unsubscribe(anyString); + Deencapsulation.invoke(mockedMqtt, "unsubscribe", anyString); maxTimes = 1; } }; @@ -152,7 +154,7 @@ public void stopSucceedsDoesNotCallUnSubscribeIfNotStarted() throws IOException new Verifications() { { - mockedMqtt.unsubscribe(anyString); + Deencapsulation.invoke(mockedMqtt, "unsubscribe", anyString); maxTimes = 0; } }; @@ -184,7 +186,7 @@ public void sendSucceedsCallsSubscribe() throws IOException new Verifications() { { - mockedMqtt.subscribe(actualSubscribeTopic); + Deencapsulation.invoke(mockedMqtt, "subscribe", actualSubscribeTopic); maxTimes = 1; } }; @@ -214,7 +216,7 @@ public void sendSucceedsCallsPublish() throws IOException new Verifications() { { - mockedMqtt.publish(anyString, actualPayload); + Deencapsulation.invoke(mockedMqtt, "publish", anyString, actualPayload); maxTimes = 1; } }; @@ -279,9 +281,9 @@ public void sendDoesNotSendOnDifferentMessageType() throws IOException new Verifications() { { - mockedMqtt.publish(anyString, actualPayload); + Deencapsulation.invoke(mockedMqtt, "publish", anyString, actualPayload); maxTimes = 0; - mockedMqtt.subscribe(anyString); + Deencapsulation.invoke(mockedMqtt, "subscribe", anyString); maxTimes = 0; } }; diff --git a/device/iot-device-client/src/test/java/tests/unit/com/microsoft/azure/sdk/iot/device/transport/mqtt/MqttDeviceTwinTest.java b/device/iot-device-client/src/test/java/tests/unit/com/microsoft/azure/sdk/iot/device/transport/mqtt/MqttDeviceTwinTest.java index 57357bffb3..5cb89faa82 100644 --- a/device/iot-device-client/src/test/java/tests/unit/com/microsoft/azure/sdk/iot/device/transport/mqtt/MqttDeviceTwinTest.java +++ b/device/iot-device-client/src/test/java/tests/unit/com/microsoft/azure/sdk/iot/device/transport/mqtt/MqttDeviceTwinTest.java @@ -1,12 +1,14 @@ // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -package com.microsoft.azure.sdk.iot.device.transport.mqtt; +package tests.unit.com.microsoft.azure.sdk.iot.device.transport.mqtt; import com.microsoft.azure.sdk.iot.device.DeviceTwin.DeviceTwinMessage; import com.microsoft.azure.sdk.iot.device.DeviceTwin.DeviceOperations; import com.microsoft.azure.sdk.iot.device.MessageType; +import com.microsoft.azure.sdk.iot.device.transport.mqtt.Mqtt; +import com.microsoft.azure.sdk.iot.device.transport.mqtt.MqttDeviceTwin; import mockit.*; import mockit.Deencapsulation; import mockit.Mocked; @@ -69,7 +71,7 @@ public void startSubscribesToDeviceTwinResponse(@Mocked final Mqtt mockMqtt) thr new Verifications() { { - mockMqtt.subscribe(resTopic); + Deencapsulation.invoke(mockMqtt, "subscribe", resTopic); times = 1; } @@ -88,7 +90,7 @@ public void startThrowsExceptionIfSubscribesFails(@Mocked final Mqtt mockMqtt) t new StrictExpectations() { { - mockMqtt.subscribe(resTopic); + Deencapsulation.invoke(mockMqtt, "subscribe", resTopic); result = mockIOException; } }; @@ -123,7 +125,7 @@ public void stopUnsubscribesFromDeviceTwinResponse(@Mocked final Mqtt mockMqtt) new Verifications() { { - mockMqtt.unsubscribe(resTopic); + Deencapsulation.invoke(mockMqtt, "unsubscribe", resTopic); times = 1; } @@ -141,7 +143,7 @@ public void stopThrowsExceptionIfUnSubscribesFails(@Mocked final Mqtt mockMqtt) new StrictExpectations() { { - mockMqtt.unsubscribe(resTopic); + Deencapsulation.invoke(mockMqtt, "unsubscribe", resTopic); result = mockIOException; } }; @@ -174,7 +176,7 @@ public void parseTopicLooksForDeviceTwinTopic(@Mocked final Mqtt mockMqtt) throw //act - String parsedTopic = testTwin.parseTopic(); + String parsedTopic = Deencapsulation.invoke(testTwin, "parseTopic") ; //assert assertNotNull(parsedTopic); @@ -196,7 +198,7 @@ public void parseTopicReturnsNullIfNoDeviceTwinTopicFound(@Mocked final Mqtt moc Deencapsulation.setField(mockMqtt, "allReceivedMessages", testMap); //act - String parsedTopic = testTwin.parseTopic(); + String parsedTopic = Deencapsulation.invoke(testTwin, "parseTopic") ; //assert assertNull(parsedTopic); @@ -214,7 +216,7 @@ public void parseTopicReturnsNullIfRecevedQueueIsEmpty(@Mocked final Mqtt mockMq Deencapsulation.setField(mockMqtt, "allReceivedMessages", testMap); //act - String parsedTopic = testTwin.parseTopic(); + String parsedTopic = Deencapsulation.invoke(testTwin, "parseTopic") ; //assert assertNull(parsedTopic); @@ -231,7 +233,7 @@ public void parseTopicThrowsExceptionIfQueueIsNull(@Mocked final Mqtt mockMqtt) Deencapsulation.setField(mockMqtt, "allReceivedMessages", testMap); //act - String parsedTopic = testTwin.parseTopic(); + String parsedTopic = Deencapsulation.invoke(testTwin, "parseTopic") ; //assert assertNull(parsedTopic); @@ -247,7 +249,7 @@ public void parsePayloadReturnNullIfTopicIsNull(@Mocked final Mqtt mockMqtt) thr MqttDeviceTwin testTwin = new MqttDeviceTwin(); //act - byte[] parsedPayload = testTwin.parsePayload(null); + byte[] parsedPayload = Deencapsulation.invoke(testTwin, "parsePayload", String.class) ; //assert assertNull(parsedPayload); @@ -266,7 +268,7 @@ public void parsePayloadThrowsExceptionIfQueueIsNull(@Mocked final Mqtt mockMqtt Deencapsulation.setField(mockMqtt, "allReceivedMessages", testMap); //act - byte[] parsedPayload = testTwin.parsePayload(resTopic); + byte[] parsedPayload = Deencapsulation.invoke(testTwin, "parsePayload", resTopic) ; //assert @@ -288,7 +290,7 @@ public void parsePayloadThrowsExceptionTopicIsNotFound(@Mocked final Mqtt mockMq Deencapsulation.setField(mockMqtt, "allReceivedMessages", testMap); //act - byte[] parsedPayload = testTwin.parsePayload(notTwinTopic); + byte[] parsedPayload = Deencapsulation.invoke(testTwin, "parsePayload", notTwinTopic); //assert @@ -309,7 +311,7 @@ public void parsePayloadReturnsBytesForSpecifiedTopic(@Mocked final Mqtt mockMqt Deencapsulation.setField(mockMqtt, "allReceivedMessages", testMap); //act - byte[] parsedPayload = testTwin.parsePayload(insertTopic); + byte[] parsedPayload = Deencapsulation.invoke(testTwin, "parsePayload", insertTopic); //assert assertNotNull(parsedPayload); @@ -336,7 +338,7 @@ public void parsePayloadRemovesTopicIfFound(@Mocked final Mqtt mockMqtt) throws Deencapsulation.setField(mockMqtt, "allReceivedMessages", testMap); //act - byte[] parsedPayload = testTwin.parsePayload(insertTopic); + byte[] parsedPayload = Deencapsulation.invoke(testTwin, "parsePayload", insertTopic); //assert ConcurrentSkipListMap retrieveTestMap = Deencapsulation.getField(mockMqtt, "allReceivedMessages"); @@ -378,7 +380,7 @@ public void sendPublishesMessageForGetTwinOnCorrectTopic(@Mocked final Mqtt mock { mockMessage.getBytes(); times = 2; - mockMqtt.publish(expectedTopic, actualPayload); + Deencapsulation.invoke(mockMqtt, "publish", expectedTopic, actualPayload); times = 1; } @@ -425,7 +427,7 @@ public void sendThrowsExceptionForGetTwinOnCorrectTopicIfReqIdIsNullOrEmpty(@Moc { mockMessage.getBytes(); times = 1; - mockMqtt.publish(expectedTopic, actualPayload); + Deencapsulation.invoke(mockMqtt, "publish", expectedTopic, actualPayload); times = 0; } @@ -470,7 +472,7 @@ public void sendPublishesMessageForUpdateReportedPropertiesOnCorrectTopic(@Mocke { mockMessage.getBytes(); times = 2; - mockMqtt.publish(expectedTopic, actualPayload); + Deencapsulation.invoke(mockMqtt, "publish", expectedTopic, actualPayload); times = 1; } @@ -513,7 +515,7 @@ public void sendThrowsExceptionForUpdateReportedPropertiesOnCorrectTopicIfReqIdI { mockMessage.getBytes(); times = 1; - mockMqtt.publish(expectedTopic, actualPayload); + Deencapsulation.invoke(mockMqtt, "publish", expectedTopic, actualPayload); times = 0; } @@ -556,9 +558,9 @@ public void sendDoesNotPublishesMessageForSubscribeToDesiredPropertiesOnCorrectT { mockMessage.getBytes(); times = 1; - mockMqtt.subscribe(expectedTopic); + Deencapsulation.invoke(mockMqtt, "subscribe", expectedTopic); times = 1; - mockMqtt.publish(expectedTopic, actualPayload); + Deencapsulation.invoke(mockMqtt, "publish", expectedTopic, actualPayload); times = 0; } @@ -601,9 +603,9 @@ public void sendSubscribesMessageForSubscribeToDesiredPropertiesOnCorrectTopic(@ { mockMessage.getBytes(); times = 1; - mockMqtt.subscribe(expectedSubscribeTopic); + Deencapsulation.invoke(mockMqtt, "subscribe", expectedSubscribeTopic); times = 1; - mockMqtt.publish(expectedTopic, actualPayload); + Deencapsulation.invoke(mockMqtt, "publish", expectedTopic, actualPayload); times = 0; } @@ -633,7 +635,7 @@ public void sendThrowsIoExceptionIfMessageIsNull(@Mocked final Mqtt mockMqtt, @M { mockMessage.getBytes(); times = 0; - mockMqtt.publish(expectedTopic, actualPayload); + Deencapsulation.invoke(mockMqtt, "publish", expectedTopic, actualPayload); times = 0; } @@ -674,7 +676,7 @@ public void sendDoesNotThrowsIoExceptionIfMessageIsEmpty(@Mocked final Mqtt mock { mockMessage.getBytes(); times = 2; - mockMqtt.publish(expectedTopic, actualPayload); + Deencapsulation.invoke(mockMqtt, "publish", expectedTopic, actualPayload); times = 1; } diff --git a/device/iot-device-client/src/test/java/tests/unit/com/microsoft/azure/sdk/iot/device/transport/mqtt/MqttMessagingTest.java b/device/iot-device-client/src/test/java/tests/unit/com/microsoft/azure/sdk/iot/device/transport/mqtt/MqttMessagingTest.java index e6312972fe..0ce1cc966c 100644 --- a/device/iot-device-client/src/test/java/tests/unit/com/microsoft/azure/sdk/iot/device/transport/mqtt/MqttMessagingTest.java +++ b/device/iot-device-client/src/test/java/tests/unit/com/microsoft/azure/sdk/iot/device/transport/mqtt/MqttMessagingTest.java @@ -2,11 +2,13 @@ // Licensed under the MIT license. See LICENSE file in the project root for full license information. -package com.microsoft.azure.sdk.iot.device.transport.mqtt; +package tests.unit.com.microsoft.azure.sdk.iot.device.transport.mqtt; import com.microsoft.azure.sdk.iot.device.Message; import com.microsoft.azure.sdk.iot.device.MessageProperty; +import com.microsoft.azure.sdk.iot.device.transport.mqtt.Mqtt; +import com.microsoft.azure.sdk.iot.device.transport.mqtt.MqttMessaging; import mockit.*; import org.junit.Test; @@ -89,8 +91,8 @@ public void startCallsConnectAndSubscribe(@Mocked final Mqtt mockMqtt) throws I new NonStrictExpectations() { { - mockMqtt.connect(); - mockMqtt.subscribe(anyString); + Deencapsulation.invoke(mockMqtt, "connect"); + Deencapsulation.invoke(mockMqtt, "subscribe", anyString); } }; @@ -100,11 +102,10 @@ public void startCallsConnectAndSubscribe(@Mocked final Mqtt mockMqtt) throws I new Verifications() { { - mockMqtt.connect(); + Deencapsulation.invoke(mockMqtt, "connect"); times = 1; - mockMqtt.subscribe(anyString); + Deencapsulation.invoke(mockMqtt, "subscribe", anyString); times = 1; - } }; @@ -116,7 +117,7 @@ public void startThrowsIoExceptionIfConnectFails(@Mocked final Mqtt mockMqtt) th new StrictExpectations() { { - mockMqtt.connect(); + Deencapsulation.invoke(mockMqtt, "connect"); result = mockIOException; } }; @@ -127,9 +128,9 @@ public void startThrowsIoExceptionIfConnectFails(@Mocked final Mqtt mockMqtt) th new Verifications() { { - mockMqtt.connect(); + Deencapsulation.invoke(mockMqtt, "connect"); times = 1; - mockMqtt.subscribe(anyString); + Deencapsulation.invoke(mockMqtt, "subscribe", anyString); times = 0; } @@ -143,8 +144,8 @@ public void startThrowsIoExceptionIfSubscribeFails(@Mocked final Mqtt mockMqtt) new StrictExpectations() { { - mockMqtt.connect(); - mockMqtt.subscribe(anyString); + Deencapsulation.invoke(mockMqtt, "connect"); + Deencapsulation.invoke(mockMqtt, "subscribe", anyString); result = mockIOException; } }; @@ -155,9 +156,9 @@ public void startThrowsIoExceptionIfSubscribeFails(@Mocked final Mqtt mockMqtt) new Verifications() { { - mockMqtt.connect(); + Deencapsulation.invoke(mockMqtt, "connect"); times = 1; - mockMqtt.subscribe(anyString); + Deencapsulation.invoke(mockMqtt, "subscribe", anyString); times = 1; } @@ -176,7 +177,7 @@ public void stopCallsDisconnectAndRestartBase(@Mocked final Mqtt mockMqtt) throw new NonStrictExpectations() { { - mockMqtt.disconnect(); + Deencapsulation.invoke(mockMqtt, "disconnect"); mockMqtt.restartBaseMqtt(); } }; @@ -188,7 +189,7 @@ public void stopCallsDisconnectAndRestartBase(@Mocked final Mqtt mockMqtt) throw new Verifications() { { - mockMqtt.disconnect(); + Deencapsulation.invoke(mockMqtt, "disconnect"); times = 1; mockMqtt.restartBaseMqtt(); times = 1; @@ -204,9 +205,9 @@ public void stopCallsRestartBaseEvenIfDisconnectFailsAndThrowsIOException(@Mocke new StrictExpectations() { { - mockMqtt.connect(); - mockMqtt.subscribe(anyString); - mockMqtt.disconnect(); + Deencapsulation.invoke(mockMqtt, "connect"); + Deencapsulation.invoke(mockMqtt, "subscribe", anyString); + Deencapsulation.invoke(mockMqtt, "disconnect"); result = mockIOException; mockMqtt.restartBaseMqtt(); } @@ -219,7 +220,7 @@ public void stopCallsRestartBaseEvenIfDisconnectFailsAndThrowsIOException(@Mocke new Verifications() { { - mockMqtt.disconnect(); + Deencapsulation.invoke(mockMqtt, "disconnect"); times = 1; mockMqtt.restartBaseMqtt(); times = 1; @@ -242,7 +243,7 @@ public void parseTopicLooksForNextAvailableMessagesForDeviceMessagingTopic(@Mock testMap.put(insertTopic, "DataData".getBytes()); Deencapsulation.setField(mockMqtt, "allReceivedMessages", testMap); - String retrieveTopic = testMqttMessaging.parseTopic(); + String retrieveTopic = Deencapsulation.invoke(testMqttMessaging, "parseTopic"); assertEquals(retrieveTopic.length(),insertTopic.length()); for (int i = 0 ; i < retrieveTopic.length(); i++) @@ -263,7 +264,7 @@ public void parseTopicReturnsNullIfQueueIsEmpty(@Mocked final Mqtt mockMqtt) thr Deencapsulation.setField(mockMqtt, "allReceivedMessages", testMap); - String retrieveTopic = testMqttMessaging.parseTopic(); + String retrieveTopic = Deencapsulation.invoke(testMqttMessaging, "parseTopic"); assertNull(retrieveTopic); } @@ -281,7 +282,7 @@ public void parseTopicReturnsNullIfNoMessageMatchingKeyIsFound(@Mocked final Mqt testMap.put(insertTopic, "DataData".getBytes()); Deencapsulation.setField(mockMqtt, "allReceivedMessages", testMap); - String retrieveTopic = testMqttMessaging.parseTopic(); + String retrieveTopic = Deencapsulation.invoke(testMqttMessaging, "parseTopic"); assertNull(retrieveTopic); @@ -301,7 +302,7 @@ public void parsePayloadLooksForValueWithGivenKeyTopic(@Mocked final Mqtt mockMq testMap.put(insertTopic, insertMessage); Deencapsulation.setField(mockMqtt, "allReceivedMessages", testMap); - byte[] retrieveMessage = testMqttMessaging.parsePayload(insertTopic); + byte[] retrieveMessage = Deencapsulation.invoke(testMqttMessaging, "parsePayload", insertTopic); assertEquals(insertMessage.length, retrieveMessage.length); for (int i = 0 ; i < retrieveMessage.length; i++) @@ -325,7 +326,7 @@ public void parsePayloadRemovesTheKeyValuePairFromQueueIfFound(@Mocked final Mqt testMap.put(insertTopic, insertMessage); Deencapsulation.setField(mockMqtt, "allReceivedMessages", testMap); - byte[] retrieveMessage = testMqttMessaging.parsePayload(insertTopic); + byte[] retrieveMessage = Deencapsulation.invoke(testMqttMessaging, "parsePayload", insertTopic); assertTrue(testMap.isEmpty()); @@ -342,7 +343,7 @@ public void parsePayloadShallThrowIOExceptionIfQueueIsEmpty(@Mocked final Mqtt m Deencapsulation.setField(mockMqtt, "allReceivedMessages", testMap); - byte[] retrieveMessage = testMqttMessaging.parsePayload(insertTopic); + byte[] retrieveMessage = Deencapsulation.invoke(testMqttMessaging, "parsePayload", insertTopic); assertNull(retrieveMessage); } @@ -362,9 +363,8 @@ public void parsePayloadShallReturnNullIfTopicIsNull(@Mocked final Mqtt mockMqtt Deencapsulation.setField(mockMqtt, "allReceivedMessages", testMap); - byte[] retrieveMessage = testMqttMessaging.parsePayload(null); + byte[] retrieveMessage = Deencapsulation.invoke(testMqttMessaging, "parsePayload", String.class); assertNull(retrieveMessage); - } /* @@ -383,7 +383,7 @@ public void parsePayloadShallThrowIOExceptionIfTopicIsNotFound(@Mocked final Mqt Deencapsulation.setField(mockMqtt, "allReceivedMessages", testMap); - byte[] retrieveMessage = testMqttMessaging.parsePayload(insertTopic_messaging); + byte[] retrieveMessage = Deencapsulation.invoke(testMqttMessaging, "parsePayload", insertTopic_messaging); } @@ -401,7 +401,7 @@ public void parsePayloadShallThrowIOExceptionIfQueueIsNull(@Mocked final Mqtt mo Deencapsulation.setField(mockMqtt, "allReceivedMessages", testMap); - byte[] retrieveMessage = testMqttMessaging.parsePayload(insertTopic); + byte[] retrieveMessage = Deencapsulation.invoke(testMqttMessaging, "parsePayload", insertTopic); } @@ -417,8 +417,7 @@ public void sendShallMessageToLowerLayer(@Mocked final Mqtt mockMqtt) throws IOE { mockMessage.getBytes(); result = messageBody; - mockMqtt.publish(anyString, messageBody); - + Deencapsulation.invoke(mockMqtt, "publish", anyString, messageBody); } }; @@ -430,7 +429,7 @@ public void sendShallMessageToLowerLayer(@Mocked final Mqtt mockMqtt) throws IOE { mockMessage.getBytes(); times = 2; - mockMqtt.publish(anyString, messageBody); + Deencapsulation.invoke(mockMqtt, "publish", anyString, messageBody); times = 1; } @@ -447,7 +446,7 @@ public void sendShallThrowIOExceptionIfMessageIsEmpty(@Mocked final Mqtt mockMqt { mockMessage.getBytes(); result = messageBody; - mockMqtt.publish(anyString, messageBody); + Deencapsulation.invoke(mockMqtt, "publish", anyString, messageBody); result = mockIOException; } @@ -461,7 +460,7 @@ public void sendShallThrowIOExceptionIfMessageIsEmpty(@Mocked final Mqtt mockMqt { mockMessage.getBytes(); times = 1; - mockMqtt.publish(mockParseTopic, new byte[1]); + Deencapsulation.invoke(mockMqtt, "publish", mockParseTopic, new byte[1]); times = 1; } @@ -484,7 +483,7 @@ public void sendShallThrowIOExceptionIfMessageIsNull(@Mocked final Mqtt mockMqtt { mockMessage.getBytes(); times = 0; - mockMqtt.publish(mockParseTopic, new byte[1]); + Deencapsulation.invoke(mockMqtt, "publish", mockParseTopic, new byte[1]); times = 0; } @@ -512,7 +511,7 @@ public void sendShallMessageWithPropertiesToLowerLayer(@Mocked final Mqtt mockMq result = messageBody; mockMessage.getProperties(); result = messageProperties; - mockMqtt.publish(anyString, messageBody); + Deencapsulation.invoke(mockMqtt, "publish", anyString, messageBody); } }; @@ -527,7 +526,7 @@ public void sendShallMessageWithPropertiesToLowerLayer(@Mocked final Mqtt mockMq mockMessage.getBytes(); times = 2; mockMessage.getProperties(); - mockMqtt.publish(publishTopicWithProperties, messageBody); + Deencapsulation.invoke(mockMqtt, "publish", publishTopicWithProperties, messageBody); times = 1; } }; @@ -556,7 +555,7 @@ public void sendShallMessageWithPropsAndMessageIdToLowerLayer(@Mocked final Mqtt result = messageProperties; mockMessage.getMessageId(); result = messageidValue; - mockMqtt.publish(anyString, messageBody); + Deencapsulation.invoke(mockMqtt, "publish", anyString, messageBody); } }; @@ -571,7 +570,7 @@ public void sendShallMessageWithPropsAndMessageIdToLowerLayer(@Mocked final Mqtt mockMessage.getBytes(); times = 2; mockMessage.getProperties(); - mockMqtt.publish(publishTopicWithProperties, messageBody); + Deencapsulation.invoke(mockMqtt, "publish", publishTopicWithProperties, messageBody); times = 1; mockMessage.getMessageId(); times = 2; diff --git a/device/iot-device-client/src/test/java/tests/unit/com/microsoft/azure/sdk/iot/device/transport/mqtt/TopicParserTest.java b/device/iot-device-client/src/test/java/tests/unit/com/microsoft/azure/sdk/iot/device/transport/mqtt/TopicParserTest.java index a89a4b6aec..4931a149d0 100644 --- a/device/iot-device-client/src/test/java/tests/unit/com/microsoft/azure/sdk/iot/device/transport/mqtt/TopicParserTest.java +++ b/device/iot-device-client/src/test/java/tests/unit/com/microsoft/azure/sdk/iot/device/transport/mqtt/TopicParserTest.java @@ -1,8 +1,9 @@ // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -package com.microsoft.azure.sdk.iot.device.transport.mqtt; +package tests.unit.com.microsoft.azure.sdk.iot.device.transport.mqtt; +import com.microsoft.azure.sdk.iot.device.transport.mqtt.TopicParser; import mockit.Deencapsulation; import org.junit.Test; @@ -59,7 +60,7 @@ public void getStatusGets() throws IOException TopicParser testParser = new TopicParser(validString); //act - String status = testParser.getStatus(3); + String status = Deencapsulation.invoke(testParser, "getStatus", 3); //assert assertNotNull(status); @@ -77,7 +78,7 @@ public void getStatusInvalidTokenThrows() throws IOException TopicParser testParser = new TopicParser(validString); //act - String status = testParser.getStatus(4); + String status = Deencapsulation.invoke(testParser, "getStatus", 4); } @@ -91,7 +92,7 @@ public void getStatusMandatoryStatusExpected() throws IOException TopicParser testParser = new TopicParser(validString); //act - String status = testParser.getStatus(3); + String status = Deencapsulation.invoke(testParser, "getStatus", 3); } /* @@ -105,7 +106,7 @@ public void getRequestIdGets() throws IOException TopicParser testParser = new TopicParser(validString); //act - String status = testParser.getRequestId(3); + String status = Deencapsulation.invoke(testParser, "getRequestId", 3); //assert assertNotNull(status); @@ -120,7 +121,7 @@ public void getRequestIdGets_pattern1() throws IOException TopicParser testParser = new TopicParser(validString); //act - String status = testParser.getRequestId(3); + String status = Deencapsulation.invoke(testParser, "getRequestId", 3); //assert assertNull(status); @@ -134,7 +135,7 @@ public void getRequestIdGets_pattern2() throws IOException TopicParser testParser = new TopicParser(validString); //act - String status = testParser.getRequestId(3); + String status = Deencapsulation.invoke(testParser, "getRequestId", 3); //assert assertNotNull(status); @@ -148,7 +149,7 @@ public void getRequestIdGets_pattern3() throws IOException TopicParser testParser = new TopicParser(validString); //act - String status = testParser.getRequestId(3); + String status = Deencapsulation.invoke(testParser, "getRequestId", 3); assertNull(status); } @@ -163,7 +164,7 @@ public void getRequestIdGetsNullIfNotFound() throws IOException TopicParser testParser = new TopicParser(validString); //act - String status = testParser.getRequestId(3); + String status = Deencapsulation.invoke(testParser, "getRequestId", 3); //assert assertNull(status); @@ -178,7 +179,7 @@ public void getRequestIdOnTopicWithVersionGets() throws IOException TopicParser testParser = new TopicParser(validString); //act - String status = testParser.getRequestId(3); + String status = Deencapsulation.invoke(testParser, "getRequestId", 3); //assert assertNotNull(status); @@ -194,7 +195,7 @@ public void getRequestIdOnTopicWithVersionBeforeRidGets() throws IOException TopicParser testParser = new TopicParser(validString); //act - String status = testParser.getRequestId(3); + String status = Deencapsulation.invoke(testParser, "getRequestId", 3); //assert assertNotNull(status); @@ -213,7 +214,7 @@ public void getRequestIdInvalidTokenThrows() throws IOException TopicParser testParser = new TopicParser(validString); //act - String status = testParser.getRequestId(4); + String status = Deencapsulation.invoke(testParser, "getRequestId", 4); } @@ -228,7 +229,7 @@ public void getVersionGets() throws IOException TopicParser testParser = new TopicParser(validString); //act - String version = testParser.getVersion(3); + String version = Deencapsulation.invoke(testParser, "getVersion", 3); //assert assertNotNull(version); @@ -243,7 +244,7 @@ public void getVersionGets_pattern1() throws IOException TopicParser testParser = new TopicParser(validString); //act - String status = testParser.getVersion(3); + String status = Deencapsulation.invoke(testParser, "getVersion", 3); //assert assertNull(status); @@ -257,7 +258,7 @@ public void getVersionGets_pattern2() throws IOException TopicParser testParser = new TopicParser(validString); //act - String status = testParser.getVersion(3); + String status = Deencapsulation.invoke(testParser, "getVersion", 3); //assert assertNotNull(status); @@ -271,7 +272,7 @@ public void getVersionGets_pattern3() throws IOException TopicParser testParser = new TopicParser(validString); //act - String status = testParser.getVersion(3); + String status = Deencapsulation.invoke(testParser, "getVersion", 3); assertNull(status); } @@ -287,7 +288,7 @@ public void getVersionGetsNullIfNotPresent() throws IOException TopicParser testParser = new TopicParser(validString); //act - String version = testParser.getVersion(3); + String version = Deencapsulation.invoke(testParser, "getVersion", 3); //assert assertNull(version); @@ -300,7 +301,7 @@ public void getVersionOnTopicWithRIDGets() throws IOException TopicParser testParser = new TopicParser(validString); //act - String version = testParser.getVersion(3); + String version = Deencapsulation.invoke(testParser, "getVersion", 3); //assert assertNotNull(version); @@ -316,7 +317,7 @@ public void getVersionOnTopicWithVersionBeforeRIDGets() throws IOException TopicParser testParser = new TopicParser(validString); //act - String version = testParser.getVersion(3); + String version = Deencapsulation.invoke(testParser, "getVersion", 3); //assert assertNotNull(version); @@ -334,7 +335,7 @@ public void getVersionInvalidTokenThrows() throws IOException TopicParser testParser = new TopicParser(validString); //act - String version = testParser.getVersion(0); + String version = Deencapsulation.invoke(testParser, "getVersion", 0); } @@ -351,7 +352,7 @@ public void getMethodNameGets() throws IOException TopicParser testParser = new TopicParser(validString); //act - String methodName = testParser.getMethodName(3); + String methodName = Deencapsulation.invoke(testParser, "getMethodName", 3); //assert assertNotNull(methodName); @@ -371,7 +372,7 @@ public void getMethodNameInvalidTokenThrows() throws IOException TopicParser testParser = new TopicParser(validString); //act - String methodName = testParser.getMethodName(4); + String methodName = Deencapsulation.invoke(testParser, "getMethodName", 4); } @Test (expected = IllegalArgumentException.class) @@ -382,7 +383,7 @@ public void getMethodNameInvalidTokenThrows_1() throws IOException TopicParser testParser = new TopicParser(validString); //act - String methodName = testParser.getMethodName(3); + String methodName = Deencapsulation.invoke(testParser, "getMethodName", 3); } @Test (expected = IllegalArgumentException.class) @@ -393,6 +394,6 @@ public void getMethodNameInvalidTokenThrows_2() throws IOException TopicParser testParser = new TopicParser(validString); //act - String methodName = testParser.getMethodName(3); + String methodName = Deencapsulation.invoke(testParser, "getMethodName", 3); } } diff --git a/device/iot-device-samples/device-method-sample/pom.xml b/device/iot-device-samples/device-method-sample/pom.xml index c74f21b6db..ec46a4b30c 100644 --- a/device/iot-device-samples/device-method-sample/pom.xml +++ b/device/iot-device-samples/device-method-sample/pom.xml @@ -1,7 +1,7 @@ 4.0.0 - com.microsoft.azure.sdk.iot.samples.iot-device-samples + com.microsoft.azure.sdk.iot.samples.device device-method-sample Device Method Sample @@ -28,7 +28,7 @@ true - samples.com.microsoft.azure.sdk.iot.device.DeviceMethodSample + samples.com.microsoft.azure.sdk.iot.DeviceMethodSample diff --git a/device/iot-device-samples/device-method-sample/src/main/java/samples/com/microsoft/azure/sdk/iot/DeviceMethodSample.java b/device/iot-device-samples/device-method-sample/src/main/java/samples/com/microsoft/azure/sdk/iot/DeviceMethodSample.java index b7ab66eace..70ee439506 100644 --- a/device/iot-device-samples/device-method-sample/src/main/java/samples/com/microsoft/azure/sdk/iot/DeviceMethodSample.java +++ b/device/iot-device-samples/device-method-sample/src/main/java/samples/com/microsoft/azure/sdk/iot/DeviceMethodSample.java @@ -1,7 +1,7 @@ // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -package samples.com.microsoft.azure.sdk.iot.device; +package samples.com.microsoft.azure.sdk.iot; import com.microsoft.azure.sdk.iot.device.*; import com.microsoft.azure.sdk.iot.device.DeviceTwin.*; @@ -23,7 +23,7 @@ public class DeviceMethodSample private static int method_command(Object command) { - System.out.println("invoking" + command + " on this device"); + System.out.println("invoking command on this device"); // Insert code to invoke command here return METHOD_SUCCESS; } diff --git a/device/iot-device-samples/device-twin-sample/pom.xml b/device/iot-device-samples/device-twin-sample/pom.xml index cf556c4d00..3a14f71ad3 100644 --- a/device/iot-device-samples/device-twin-sample/pom.xml +++ b/device/iot-device-samples/device-twin-sample/pom.xml @@ -1,7 +1,7 @@ 4.0.0 - com.microsoft.azure.sdk.iot.samples.iot-device-samples + com.microsoft.azure.sdk.iot.samples.device device-twin-sample Device Twin Sample @@ -28,7 +28,7 @@ true - samples.com.microsoft.azure.sdk.iot.device.DeviceTwinSample + samples.com.microsoft.azure.sdk.iot.DeviceTwinSample diff --git a/device/iot-device-samples/device-twin-sample/src/main/java/samples/com/microsoft/azure/sdk/iot/DeviceTwinSample.java b/device/iot-device-samples/device-twin-sample/src/main/java/samples/com/microsoft/azure/sdk/iot/DeviceTwinSample.java index 029ee637bf..93f29cae1a 100644 --- a/device/iot-device-samples/device-twin-sample/src/main/java/samples/com/microsoft/azure/sdk/iot/DeviceTwinSample.java +++ b/device/iot-device-samples/device-twin-sample/src/main/java/samples/com/microsoft/azure/sdk/iot/DeviceTwinSample.java @@ -1,7 +1,7 @@ // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -package samples.com.microsoft.azure.sdk.iot.device; +package samples.com.microsoft.azure.sdk.iot; import com.microsoft.azure.sdk.iot.device.*; import com.microsoft.azure.sdk.iot.device.DeviceTwin.Device; diff --git a/device/iot-device-samples/handle-messages/pom.xml b/device/iot-device-samples/handle-messages/pom.xml index 704abad4e6..a91276eeb7 100644 --- a/device/iot-device-samples/handle-messages/pom.xml +++ b/device/iot-device-samples/handle-messages/pom.xml @@ -1,6 +1,6 @@ 4.0.0 - com.microsoft.azure.sdk.iot.samples.iot-device-samples + com.microsoft.azure.sdk.iot.samples.device handle-messages Handle Messages Sample @@ -27,7 +27,7 @@ true - samples.com.microsoft.azure.sdk.iot.device.HandleMessages + samples.com.microsoft.azure.sdk.iot.HandleMessages diff --git a/device/iot-device-samples/handle-messages/src/main/java/samples/com/microsoft/azure/sdk/iot/HandleMessages.java b/device/iot-device-samples/handle-messages/src/main/java/samples/com/microsoft/azure/sdk/iot/HandleMessages.java index 65ff278a22..a96fb9a03e 100644 --- a/device/iot-device-samples/handle-messages/src/main/java/samples/com/microsoft/azure/sdk/iot/HandleMessages.java +++ b/device/iot-device-samples/handle-messages/src/main/java/samples/com/microsoft/azure/sdk/iot/HandleMessages.java @@ -1,7 +1,7 @@ // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -package samples.com.microsoft.azure.sdk.iot.device; +package samples.com.microsoft.azure.sdk.iot; import com.microsoft.azure.sdk.iot.device.DeviceClient; import com.microsoft.azure.sdk.iot.device.IotHubClientProtocol; diff --git a/device/iot-device-samples/pom.xml b/device/iot-device-samples/pom.xml index 8cc203cf3e..81f86dd9d4 100644 --- a/device/iot-device-samples/pom.xml +++ b/device/iot-device-samples/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.microsoft.azure.sdk.iot.samples iot-device-samples - IoT Hub Java Device Client Samples + IoT Hub Java Device SDK Samples pom diff --git a/device/iot-device-samples/send-event/pom.xml b/device/iot-device-samples/send-event/pom.xml index 26e7dc7ce6..bdf069fb72 100644 --- a/device/iot-device-samples/send-event/pom.xml +++ b/device/iot-device-samples/send-event/pom.xml @@ -1,6 +1,6 @@ 4.0.0 - com.microsoft.azure.sdk.iot.samples.iot-device-samples + com.microsoft.azure.sdk.iot.samples.device send-event Send Event Sample @@ -27,7 +27,7 @@ true - samples.com.microsoft.azure.sdk.iot.device.SendEvent + samples.com.microsoft.azure.sdk.iot.SendEvent diff --git a/device/iot-device-samples/send-event/src/main/java/samples/com/microsoft/azure/sdk/iot/SendEvent.java b/device/iot-device-samples/send-event/src/main/java/samples/com/microsoft/azure/sdk/iot/SendEvent.java index fe95ee2a54..edeaa68e85 100644 --- a/device/iot-device-samples/send-event/src/main/java/samples/com/microsoft/azure/sdk/iot/SendEvent.java +++ b/device/iot-device-samples/send-event/src/main/java/samples/com/microsoft/azure/sdk/iot/SendEvent.java @@ -1,7 +1,7 @@ // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -package samples.com.microsoft.azure.sdk.iot.device; +package samples.com.microsoft.azure.sdk.iot; import com.microsoft.azure.sdk.iot.device.*; diff --git a/device/iot-device-samples/send-receive-sample/pom.xml b/device/iot-device-samples/send-receive-sample/pom.xml index 037396b02e..5140d41ac2 100644 --- a/device/iot-device-samples/send-receive-sample/pom.xml +++ b/device/iot-device-samples/send-receive-sample/pom.xml @@ -1,6 +1,6 @@ 4.0.0 - com.microsoft.azure.sdk.iot.samples.iot-device-samples + com.microsoft.azure.sdk.iot.samples.device send-receive-sample Sender and Receiver Sample @@ -27,7 +27,7 @@ true - samples.com.microsoft.azure.sdk.iot.device.SendReceive + samples.com.microsoft.azure.sdk.iot.SendReceive diff --git a/device/iot-device-samples/send-receive-sample/src/main/java/samples/com/microsoft/azure/sdk/iot/SendReceive.java b/device/iot-device-samples/send-receive-sample/src/main/java/samples/com/microsoft/azure/sdk/iot/SendReceive.java index 265f05a519..05d982b3ce 100644 --- a/device/iot-device-samples/send-receive-sample/src/main/java/samples/com/microsoft/azure/sdk/iot/SendReceive.java +++ b/device/iot-device-samples/send-receive-sample/src/main/java/samples/com/microsoft/azure/sdk/iot/SendReceive.java @@ -1,7 +1,7 @@ // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -package samples.com.microsoft.azure.sdk.iot.device; +package samples.com.microsoft.azure.sdk.iot; import com.microsoft.azure.sdk.iot.device.*; diff --git a/device/iot-device-samples/send-serialized-event/pom.xml b/device/iot-device-samples/send-serialized-event/pom.xml index f54c47aed8..5e6cfb5754 100644 --- a/device/iot-device-samples/send-serialized-event/pom.xml +++ b/device/iot-device-samples/send-serialized-event/pom.xml @@ -1,6 +1,6 @@ 4.0.0 - com.microsoft.azure.sdk.iot.samples.iot-device-samples + com.microsoft.azure.sdk.iot.samples.device send-serialized-event Send Serialized Event Sample @@ -34,7 +34,7 @@ true - samples.com.microsoft.azure.sdk.iot.device.SendSerializedEvent + samples.com.microsoft.azure.sdk.iot.SendSerializedEvent diff --git a/device/iot-device-samples/send-serialized-event/src/main/java/samples/com/microsoft/azure/sdk/iot/ContosoAnemometer.java b/device/iot-device-samples/send-serialized-event/src/main/java/samples/com/microsoft/azure/sdk/iot/ContosoAnemometer.java index ecc1cff954..b0e40a534e 100644 --- a/device/iot-device-samples/send-serialized-event/src/main/java/samples/com/microsoft/azure/sdk/iot/ContosoAnemometer.java +++ b/device/iot-device-samples/send-serialized-event/src/main/java/samples/com/microsoft/azure/sdk/iot/ContosoAnemometer.java @@ -1,7 +1,7 @@ // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -package samples.com.microsoft.azure.sdk.iot.device; +package samples.com.microsoft.azure.sdk.iot; import com.google.gson.Gson; diff --git a/device/iot-device-samples/send-serialized-event/src/main/java/samples/com/microsoft/azure/sdk/iot/SendSerializedEvent.java b/device/iot-device-samples/send-serialized-event/src/main/java/samples/com/microsoft/azure/sdk/iot/SendSerializedEvent.java index 909bf290a8..c6d1d8f20c 100644 --- a/device/iot-device-samples/send-serialized-event/src/main/java/samples/com/microsoft/azure/sdk/iot/SendSerializedEvent.java +++ b/device/iot-device-samples/send-serialized-event/src/main/java/samples/com/microsoft/azure/sdk/iot/SendSerializedEvent.java @@ -1,7 +1,7 @@ // Copyright (c) Microsoft. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. -package samples.com.microsoft.azure.sdk.iot.device; +package samples.com.microsoft.azure.sdk.iot; import com.microsoft.azure.sdk.iot.device.DeviceClient; import com.microsoft.azure.sdk.iot.device.IotHubClientProtocol; diff --git a/service/iot-service-client/pom.xml b/service/iot-service-client/pom.xml index 8253257a7d..02d873e71e 100644 --- a/service/iot-service-client/pom.xml +++ b/service/iot-service-client/pom.xml @@ -1,7 +1,7 @@ 4.0.0 iot-service-client - IotHub Java Service SDK + Iot Hub Java Service SDK The Microsoft Azure IoT Service SDK for Java diff --git a/service/iot-service-client/src/main/java/com/microsoft/azure/sdk/iot/service/DeviceTwin/DeviceMethod.java b/service/iot-service-client/src/main/java/com/microsoft/azure/sdk/iot/service/devicetwin/DeviceMethod.java similarity index 100% rename from service/iot-service-client/src/main/java/com/microsoft/azure/sdk/iot/service/DeviceTwin/DeviceMethod.java rename to service/iot-service-client/src/main/java/com/microsoft/azure/sdk/iot/service/devicetwin/DeviceMethod.java diff --git a/service/iot-service-client/src/main/java/com/microsoft/azure/sdk/iot/service/DeviceTwin/DeviceOperations.java b/service/iot-service-client/src/main/java/com/microsoft/azure/sdk/iot/service/devicetwin/DeviceOperations.java similarity index 100% rename from service/iot-service-client/src/main/java/com/microsoft/azure/sdk/iot/service/DeviceTwin/DeviceOperations.java rename to service/iot-service-client/src/main/java/com/microsoft/azure/sdk/iot/service/devicetwin/DeviceOperations.java diff --git a/service/iot-service-client/src/main/java/com/microsoft/azure/sdk/iot/service/DeviceTwin/DeviceTwin.java b/service/iot-service-client/src/main/java/com/microsoft/azure/sdk/iot/service/devicetwin/DeviceTwin.java similarity index 100% rename from service/iot-service-client/src/main/java/com/microsoft/azure/sdk/iot/service/DeviceTwin/DeviceTwin.java rename to service/iot-service-client/src/main/java/com/microsoft/azure/sdk/iot/service/devicetwin/DeviceTwin.java diff --git a/service/iot-service-client/src/main/java/com/microsoft/azure/sdk/iot/service/DeviceTwin/DeviceTwinDevice.java b/service/iot-service-client/src/main/java/com/microsoft/azure/sdk/iot/service/devicetwin/DeviceTwinDevice.java similarity index 100% rename from service/iot-service-client/src/main/java/com/microsoft/azure/sdk/iot/service/DeviceTwin/DeviceTwinDevice.java rename to service/iot-service-client/src/main/java/com/microsoft/azure/sdk/iot/service/devicetwin/DeviceTwinDevice.java diff --git a/service/iot-service-client/src/main/java/com/microsoft/azure/sdk/iot/service/DeviceTwin/MethodResult.java b/service/iot-service-client/src/main/java/com/microsoft/azure/sdk/iot/service/devicetwin/MethodResult.java similarity index 100% rename from service/iot-service-client/src/main/java/com/microsoft/azure/sdk/iot/service/DeviceTwin/MethodResult.java rename to service/iot-service-client/src/main/java/com/microsoft/azure/sdk/iot/service/devicetwin/MethodResult.java diff --git a/service/iot-service-client/src/main/java/com/microsoft/azure/sdk/iot/service/DeviceTwin/Pair.java b/service/iot-service-client/src/main/java/com/microsoft/azure/sdk/iot/service/devicetwin/Pair.java similarity index 100% rename from service/iot-service-client/src/main/java/com/microsoft/azure/sdk/iot/service/DeviceTwin/Pair.java rename to service/iot-service-client/src/main/java/com/microsoft/azure/sdk/iot/service/devicetwin/Pair.java diff --git a/service/iot-service-samples/device-manager-sample/pom.xml b/service/iot-service-samples/device-manager-sample/pom.xml index 5c2e308e89..667be23db4 100644 --- a/service/iot-service-samples/device-manager-sample/pom.xml +++ b/service/iot-service-samples/device-manager-sample/pom.xml @@ -1,7 +1,7 @@ 4.0.0 - com.microsoft.azure.sdk.iot.samples.iot-service-samples - DeviceManagerSample + com.microsoft.azure.sdk.iot.samples.service + device-manager-sample 1.1.15 Device Manager Sample @@ -28,7 +28,7 @@ true - samples.com.microsoft.azure.sdk.iot.service.DeviceManagerSample + samples.com.microsoft.azure.sdk.iot.DeviceManagerSample diff --git a/service/iot-service-samples/device-manager-sample/src/main/java/samples/com/microsoft/azure/sdk/iot/service/sdk/DeviceManagerExportSample.java b/service/iot-service-samples/device-manager-sample/src/main/java/samples/com/microsoft/azure/sdk/iot/DeviceManagerExportSample.java similarity index 74% rename from service/iot-service-samples/device-manager-sample/src/main/java/samples/com/microsoft/azure/sdk/iot/service/sdk/DeviceManagerExportSample.java rename to service/iot-service-samples/device-manager-sample/src/main/java/samples/com/microsoft/azure/sdk/iot/DeviceManagerExportSample.java index 8199691fc6..fa63be852b 100644 --- a/service/iot-service-samples/device-manager-sample/src/main/java/samples/com/microsoft/azure/sdk/iot/service/sdk/DeviceManagerExportSample.java +++ b/service/iot-service-samples/device-manager-sample/src/main/java/samples/com/microsoft/azure/sdk/iot/DeviceManagerExportSample.java @@ -3,7 +3,7 @@ * Licensed under the MIT license. See LICENSE file in the project root for full license information. */ -package samples.com.microsoft.azure.sdk.iot.service; +package samples.com.microsoft.azure.sdk.iot; import com.microsoft.azure.sdk.iot.service.JobProperties; import com.microsoft.azure.sdk.iot.service.RegistryManager; @@ -24,15 +24,13 @@ public static void main(String[] args) throws Exception { System.out.println("Starting export sample..."); - CloudStorageAccount storageAccount = CloudStorageAccount.parse(samples.com.microsoft.azure.sdk.iot.service - .SampleUtils.storageConnectionString); + CloudStorageAccount storageAccount = CloudStorageAccount.parse(SampleUtils.storageConnectionString); CloudBlobClient blobClient = storageAccount.createCloudBlobClient(); CloudBlobContainer container = blobClient.getContainerReference(DeviceManagerExportSample.sampleContainerName); container.createIfNotExists(); - String containerSasUri = samples.com.microsoft.azure.sdk.iot.service.SampleUtils.getContainerSasUri(container); + String containerSasUri = SampleUtils.getContainerSasUri(container); - RegistryManager registryManager = RegistryManager.createFromConnectionString(samples.com.microsoft.azure.sdk - .iot.service.SampleUtils.iotHubConnectionString); + RegistryManager registryManager = RegistryManager.createFromConnectionString(SampleUtils.iotHubConnectionString); JobProperties exportJob = registryManager.exportDevices(containerSasUri, excludeKeys); while(true) @@ -50,11 +48,10 @@ public static void main(String[] args) throws Exception if (blobItem instanceof CloudBlob) { CloudBlob blob = (CloudBlob) blobItem; - blob.download(new FileOutputStream(samples.com.microsoft.azure.sdk.iot.service.SampleUtils.exportFileLocation + blob.getName())); + blob.download(new FileOutputStream(SampleUtils.exportFileLocation + blob.getName())); } } - System.out.println("Export job completed. Results are in " + samples.com.microsoft.azure.sdk.iot.service - .SampleUtils.exportFileLocation); + System.out.println("Export job completed. Results are in " + SampleUtils.exportFileLocation); } } \ No newline at end of file diff --git a/service/iot-service-samples/device-manager-sample/src/main/java/samples/com/microsoft/azure/sdk/iot/service/sdk/DeviceManagerImportSample.java b/service/iot-service-samples/device-manager-sample/src/main/java/samples/com/microsoft/azure/sdk/iot/DeviceManagerImportSample.java similarity index 90% rename from service/iot-service-samples/device-manager-sample/src/main/java/samples/com/microsoft/azure/sdk/iot/service/sdk/DeviceManagerImportSample.java rename to service/iot-service-samples/device-manager-sample/src/main/java/samples/com/microsoft/azure/sdk/iot/DeviceManagerImportSample.java index 3c9a4f3cdc..b94b01c21f 100644 --- a/service/iot-service-samples/device-manager-sample/src/main/java/samples/com/microsoft/azure/sdk/iot/service/sdk/DeviceManagerImportSample.java +++ b/service/iot-service-samples/device-manager-sample/src/main/java/samples/com/microsoft/azure/sdk/iot/DeviceManagerImportSample.java @@ -3,7 +3,7 @@ * Licensed under the MIT license. See LICENSE file in the project root for full license information. */ -package samples.com.microsoft.azure.sdk.iot.service; +package samples.com.microsoft.azure.sdk.iot; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -28,12 +28,11 @@ public static void main(String[] args) throws Exception System.out.println("Starting import sample..."); // Creating Azure storage container and getting its URI - CloudStorageAccount storageAccount = CloudStorageAccount.parse(samples.com.microsoft.azure.sdk.iot.service - .SampleUtils.storageConnectionString); + CloudStorageAccount storageAccount = CloudStorageAccount.parse(SampleUtils.storageConnectionString); CloudBlobClient blobClient = storageAccount.createCloudBlobClient(); CloudBlobContainer container = blobClient.getContainerReference(DeviceManagerImportSample.importContainerName); container.createIfNotExists(); - String containerSasUri = samples.com.microsoft.azure.sdk.iot.service.SampleUtils.getContainerSasUri(container); + String containerSasUri = SampleUtils.getContainerSasUri(container); // Creating the list of devices to be submitted for import StringBuilder devicesToImport = new StringBuilder(); @@ -67,8 +66,7 @@ public static void main(String[] args) throws Exception importBlob.upload(stream, blobToImport.length); // Starting the import job - RegistryManager registryManager = RegistryManager.createFromConnectionString(samples.com.microsoft.azure.sdk - .iot.service.SampleUtils.iotHubConnectionString); + RegistryManager registryManager = RegistryManager.createFromConnectionString(SampleUtils.iotHubConnectionString); JobProperties importJob = registryManager.importDevices(containerSasUri, containerSasUri); // Waiting for the import job to complete diff --git a/service/iot-service-samples/device-manager-sample/src/main/java/samples/com/microsoft/azure/sdk/iot/service/sdk/DeviceManagerSample.java b/service/iot-service-samples/device-manager-sample/src/main/java/samples/com/microsoft/azure/sdk/iot/DeviceManagerSample.java similarity index 77% rename from service/iot-service-samples/device-manager-sample/src/main/java/samples/com/microsoft/azure/sdk/iot/service/sdk/DeviceManagerSample.java rename to service/iot-service-samples/device-manager-sample/src/main/java/samples/com/microsoft/azure/sdk/iot/DeviceManagerSample.java index 8da9082ea8..628e783670 100644 --- a/service/iot-service-samples/device-manager-sample/src/main/java/samples/com/microsoft/azure/sdk/iot/service/sdk/DeviceManagerSample.java +++ b/service/iot-service-samples/device-manager-sample/src/main/java/samples/com/microsoft/azure/sdk/iot/DeviceManagerSample.java @@ -3,7 +3,7 @@ * Licensed under the MIT license. See LICENSE file in the project root for full license information. */ -package samples.com.microsoft.azure.sdk.iot.service; +package samples.com.microsoft.azure.sdk.iot; import com.microsoft.azure.sdk.iot.service.exceptions.IotHubException; import com.microsoft.azure.sdk.iot.service.Device; @@ -45,10 +45,9 @@ public static void main(String[] args) throws Exception private static void AddDevice() throws Exception { - RegistryManager registryManager = RegistryManager.createFromConnectionString(samples.com.microsoft.azure.sdk - .iot.service.SampleUtils.iotHubConnectionString); + RegistryManager registryManager = RegistryManager.createFromConnectionString(SampleUtils.iotHubConnectionString); - Device device = Device.createFromId(samples.com.microsoft.azure.sdk.iot.service.SampleUtils.deviceId, null, null); + Device device = Device.createFromId(SampleUtils.deviceId, null, null); try { device = registryManager.addDevice(device); @@ -68,13 +67,12 @@ private static void AddDevice() throws Exception private static void GetDevice() throws Exception { - RegistryManager registryManager = RegistryManager.createFromConnectionString(samples.com.microsoft.azure.sdk - .iot.service.SampleUtils.iotHubConnectionString); + RegistryManager registryManager = RegistryManager.createFromConnectionString(SampleUtils.iotHubConnectionString); Device returnDevice = null; try { - returnDevice = registryManager.getDevice(samples.com.microsoft.azure.sdk.iot.service.SampleUtils.deviceId); + returnDevice = registryManager.getDevice(SampleUtils.deviceId); System.out.println("Device: " + returnDevice.getDeviceId()); System.out.println("Device primary key: " + returnDevice.getPrimaryKey()); @@ -96,10 +94,9 @@ private static void UpdateDevice() throws Exception String primaryKey = "[New primary key goes here]"; String secondaryKey = "[New secondary key goes here]"; - RegistryManager registryManager = RegistryManager.createFromConnectionString(samples.com.microsoft.azure.sdk - .iot.service.SampleUtils.iotHubConnectionString); + RegistryManager registryManager = RegistryManager.createFromConnectionString(SampleUtils.iotHubConnectionString); - Device device = Device.createFromId(samples.com.microsoft.azure.sdk.iot.service.SampleUtils.deviceId, null, null); + Device device = Device.createFromId(SampleUtils.deviceId, null, null); device.getSymmetricKey().setPrimaryKey(primaryKey); device.getSymmetricKey().setSecondaryKey(secondaryKey); try @@ -122,13 +119,12 @@ private static void UpdateDevice() throws Exception private static void RemoveDevice() throws Exception { - RegistryManager registryManager = RegistryManager.createFromConnectionString(samples.com.microsoft.azure.sdk - .iot.service.SampleUtils.iotHubConnectionString); + RegistryManager registryManager = RegistryManager.createFromConnectionString(SampleUtils.iotHubConnectionString); try { - registryManager.removeDevice(samples.com.microsoft.azure.sdk.iot.service.SampleUtils.deviceId); - System.out.println("Device removed: " + samples.com.microsoft.azure.sdk.iot.service.SampleUtils.deviceId); + registryManager.removeDevice(SampleUtils.deviceId); + System.out.println("Device removed: " + SampleUtils.deviceId); } catch (IotHubException iote) { diff --git a/service/iot-service-samples/device-manager-sample/src/main/java/samples/com/microsoft/azure/sdk/iot/service/sdk/SampleUtils.java b/service/iot-service-samples/device-manager-sample/src/main/java/samples/com/microsoft/azure/sdk/iot/SampleUtils.java similarity index 97% rename from service/iot-service-samples/device-manager-sample/src/main/java/samples/com/microsoft/azure/sdk/iot/service/sdk/SampleUtils.java rename to service/iot-service-samples/device-manager-sample/src/main/java/samples/com/microsoft/azure/sdk/iot/SampleUtils.java index 85ca5880d4..7592b90a03 100644 --- a/service/iot-service-samples/device-manager-sample/src/main/java/samples/com/microsoft/azure/sdk/iot/service/sdk/SampleUtils.java +++ b/service/iot-service-samples/device-manager-sample/src/main/java/samples/com/microsoft/azure/sdk/iot/SampleUtils.java @@ -3,7 +3,7 @@ * Licensed under the MIT license. See LICENSE file in the project root for full license information. */ -package samples.com.microsoft.azure.sdk.iot.service; +package samples.com.microsoft.azure.sdk.iot; import com.microsoft.azure.storage.StorageException; import com.microsoft.azure.storage.blob.CloudBlobContainer; diff --git a/service/iot-service-samples/device-method-sample/pom.xml b/service/iot-service-samples/device-method-sample/pom.xml index 446acffa6d..0cc1346cfa 100644 --- a/service/iot-service-samples/device-method-sample/pom.xml +++ b/service/iot-service-samples/device-method-sample/pom.xml @@ -1,7 +1,7 @@ 4.0.0 - com.microsoft.azure.sdk.iot.samples.iot-service-samples - DeviceMethodSample + com.microsoft.azure.sdk.iot.samples.service + device-method-sample 1.1.15 Device Method Sample diff --git a/service/iot-service-samples/device-twin-sample/pom.xml b/service/iot-service-samples/device-twin-sample/pom.xml index 577ad9eea6..5edca8810b 100644 --- a/service/iot-service-samples/device-twin-sample/pom.xml +++ b/service/iot-service-samples/device-twin-sample/pom.xml @@ -1,7 +1,7 @@ 4.0.0 - com.microsoft.azure.sdk.iot.samples.iot-service-samples - DeviceTwinSample + com.microsoft.azure.sdk.iot.samples.service + device-twin-sample 1.1.15 Device Twin Sample @@ -28,7 +28,7 @@ true - samples.com.microsoft.azure.sdk.iot.service.DeviceTwinSample + samples.com.microsoft.azure.sdk.iot.DeviceTwinSample diff --git a/service/iot-service-samples/device-twin-sample/src/main/java/samples/com/microsoft/azure/sdk/iot/service/sdk/DeviceTwinSample.java b/service/iot-service-samples/device-twin-sample/src/main/java/samples/com/microsoft/azure/sdk/iot/DeviceTwinSample.java similarity index 96% rename from service/iot-service-samples/device-twin-sample/src/main/java/samples/com/microsoft/azure/sdk/iot/service/sdk/DeviceTwinSample.java rename to service/iot-service-samples/device-twin-sample/src/main/java/samples/com/microsoft/azure/sdk/iot/DeviceTwinSample.java index 3dc26eed00..686b4ad976 100644 --- a/service/iot-service-samples/device-twin-sample/src/main/java/samples/com/microsoft/azure/sdk/iot/service/sdk/DeviceTwinSample.java +++ b/service/iot-service-samples/device-twin-sample/src/main/java/samples/com/microsoft/azure/sdk/iot/DeviceTwinSample.java @@ -3,7 +3,7 @@ * Licensed under the MIT license. See LICENSE file in the project root for full license information. */ -package samples.com.microsoft.azure.sdk.iot.service; +package samples.com.microsoft.azure.sdk.iot; import com.microsoft.azure.sdk.iot.service.devicetwin.DeviceTwin; import com.microsoft.azure.sdk.iot.service.devicetwin.DeviceTwinDevice; diff --git a/service/iot-service-samples/readme.md b/service/iot-service-samples/readme.md index 12c256ff73..225ee22caa 100644 --- a/service/iot-service-samples/readme.md +++ b/service/iot-service-samples/readme.md @@ -56,7 +56,7 @@ You need to first clone the repository or download the sample project folder on To run the Device Manager Sample application using Maven, execute the following command. ``` - mvn exec:java -Dexec.mainClass="samples.com.microsoft.azure.sdk.iot.service.DeviceManagerSample" + mvn exec:java -Dexec.mainClass="DeviceManagerSample" ``` You can verify the result of your operation by using [Device Explorer or iothub-explorer tool][lnk-manage-iot-hub]. @@ -93,7 +93,7 @@ You need to first clone the repository or download the sample project folder on To run the Service Client Sample application using Maven, execute the following command. ``` - mvn exec:java -Dexec.mainClass="samples.com.microsoft.azure.sdk.iot.service.ServiceClientSample" + mvn exec:java -Dexec.mainClass="ServiceClientSample" ``` You can verify the result of your operation by using [Device Explorer or iothub-explorer tool][lnk-manage-iot-hub]. diff --git a/service/iot-service-samples/service-client-sample/pom.xml b/service/iot-service-samples/service-client-sample/pom.xml index cd602608c8..d4b5fe104b 100644 --- a/service/iot-service-samples/service-client-sample/pom.xml +++ b/service/iot-service-samples/service-client-sample/pom.xml @@ -1,7 +1,7 @@ 4.0.0 - com.microsoft.azure.sdk.iot.samples.iot-service-samples - ServiceClientSample + com.microsoft.azure.sdk.iot.samples.service + service-client-sample 1.1.15 Service Client Sample @@ -28,7 +28,7 @@ true - samples.com.microsoft.azure.sdk.iot.service.ServiceClientSample + samples.com.microsoft.azure.sdk.iot.ServiceClientSample diff --git a/service/iot-service-samples/service-client-sample/src/main/java/samples/com/microsoft/azure/sdk/iot/service/sdk/ServiceClientSample.java b/service/iot-service-samples/service-client-sample/src/main/java/samples/com/microsoft/azure/sdk/iot/ServiceClientSample.java similarity index 99% rename from service/iot-service-samples/service-client-sample/src/main/java/samples/com/microsoft/azure/sdk/iot/service/sdk/ServiceClientSample.java rename to service/iot-service-samples/service-client-sample/src/main/java/samples/com/microsoft/azure/sdk/iot/ServiceClientSample.java index d91e3a2012..1fe502eec1 100644 --- a/service/iot-service-samples/service-client-sample/src/main/java/samples/com/microsoft/azure/sdk/iot/service/sdk/ServiceClientSample.java +++ b/service/iot-service-samples/service-client-sample/src/main/java/samples/com/microsoft/azure/sdk/iot/ServiceClientSample.java @@ -3,7 +3,7 @@ * Licensed under the MIT license. See LICENSE file in the project root for full license information. */ -package samples.com.microsoft.azure.sdk.iot.service; +package samples.com.microsoft.azure.sdk.iot; import com.microsoft.azure.sdk.iot.service.*; import com.microsoft.azure.sdk.iot.service.exceptions.IotHubDeviceMaximumQueueDepthExceededException;