Search in sources :

Example 1 with NonStrictExpectations

use of mockit.NonStrictExpectations in project azure-iot-sdk-java by Azure.

the class IotHubCompleteUriTest method toStringIsCorrect.

// Tests_SRS_IOTHUBCOMPLETEURI_11_002: [The string representation of the IoT Hub event URI shall be constructed with the format "[iotHubHostname]/devices/[deviceId]/messages/devicebound/[eTag]?api-version=2016-02-03".]
@Test
public void toStringIsCorrect() throws URISyntaxException {
    final String iotHubHostname = "test.iothub";
    final String deviceId = "test-deviceid";
    final String eTag = "test-etag";
    final String uriStr = "test-uri-str";
    new NonStrictExpectations() {

        {
            mockIotHubUri.toString();
            result = uriStr;
        }
    };
    IotHubCompleteUri completeUri = new IotHubCompleteUri(iotHubHostname, deviceId, eTag);
    String testUriStr = completeUri.toString();
    final String expectedUriStr = uriStr;
    assertThat(testUriStr, is(expectedUriStr));
}
Also used : IotHubCompleteUri(com.microsoft.azure.sdk.iot.device.net.IotHubCompleteUri) NonStrictExpectations(mockit.NonStrictExpectations) Test(org.junit.Test)

Example 2 with NonStrictExpectations

use of mockit.NonStrictExpectations in project azure-iot-sdk-java by Azure.

the class IotHubCompleteUriTest method getHostnameIsCorrect.

// Tests_SRS_IOTHUBCOMPLETEURI_11_003: [The function shall return the hostname given in the constructor.] 
@Test
public void getHostnameIsCorrect() throws URISyntaxException {
    final String iotHubHostname = "test.iothub";
    final String deviceId = "test-deviceid";
    final String eTag = "test-etag";
    final String hostname = "test-hostname";
    new NonStrictExpectations() {

        {
            mockIotHubUri.getHostname();
            result = hostname;
        }
    };
    IotHubCompleteUri completeUri = new IotHubCompleteUri(iotHubHostname, deviceId, eTag);
    String testHostname = completeUri.getHostname();
    final String expectedHostname = hostname;
    assertThat(testHostname, is(expectedHostname));
}
Also used : IotHubCompleteUri(com.microsoft.azure.sdk.iot.device.net.IotHubCompleteUri) NonStrictExpectations(mockit.NonStrictExpectations) Test(org.junit.Test)

Example 3 with NonStrictExpectations

use of mockit.NonStrictExpectations in project azure-iot-sdk-java by Azure.

the class IotHubEventUriTest method getHostnameIsCorrect.

// Tests_SRS_IOTHUBEVENTURI_11_003: [The function shall return the hostname given in the constructor.]
@Test
public void getHostnameIsCorrect() throws URISyntaxException {
    final String iotHubHostname = "test.iothub";
    final String deviceId = "test-deviceid";
    final String hostname = "test-hostname";
    new NonStrictExpectations() {

        {
            mockIotHubUri.getHostname();
            result = hostname;
        }
    };
    IotHubEventUri eventUri = new IotHubEventUri(iotHubHostname, deviceId);
    String testHostname = eventUri.getHostname();
    final String expectedHostname = hostname;
    assertThat(testHostname, is(expectedHostname));
}
Also used : IotHubEventUri(com.microsoft.azure.sdk.iot.device.net.IotHubEventUri) NonStrictExpectations(mockit.NonStrictExpectations) Test(org.junit.Test)

Example 4 with NonStrictExpectations

use of mockit.NonStrictExpectations in project azure-iot-sdk-java by Azure.

the class IotHubEventUriTest method toStringIsCorrect.

// Tests_SRS_IOTHUBEVENTURI_11_002: [The string representation of the IoT Hub event URI shall be constructed with the format '[iotHubHostname]/devices/[deviceId]/messages/events?api-version=2016-02-03 '.]
@Test
public void toStringIsCorrect() throws URISyntaxException {
    final String iotHubHostname = "test.iothub";
    final String deviceId = "test-deviceid";
    final String uriStr = "test-uri-str";
    new NonStrictExpectations() {

        {
            mockIotHubUri.toString();
            result = uriStr;
        }
    };
    IotHubEventUri eventUri = new IotHubEventUri(iotHubHostname, deviceId);
    String testUriStr = eventUri.toString();
    final String expectedUriStr = uriStr;
    assertThat(testUriStr, is(expectedUriStr));
}
Also used : IotHubEventUri(com.microsoft.azure.sdk.iot.device.net.IotHubEventUri) NonStrictExpectations(mockit.NonStrictExpectations) Test(org.junit.Test)

Example 5 with NonStrictExpectations

use of mockit.NonStrictExpectations in project azure-iot-sdk-java by Azure.

the class IotHubMessageUriTest method getPathIsCorrect.

// Tests_SRS_IOTHUBMESSAGEURI_11_004: [The function shall return a URI with the format '/devices/[deviceId]/messages/devicebound.]
@Test
public void getPathIsCorrect() throws URISyntaxException {
    final String iotHubHostname = "test.iothub";
    final String deviceId = "test-deviceid";
    final String path = "test-path";
    new NonStrictExpectations() {

        {
            mockIotHubUri.getPath();
            result = path;
        }
    };
    IotHubMessageUri messageUri = new IotHubMessageUri(iotHubHostname, deviceId);
    String testPath = messageUri.getPath();
    final String expectedPath = path;
    assertThat(testPath, is(expectedPath));
}
Also used : IotHubMessageUri(com.microsoft.azure.sdk.iot.device.net.IotHubMessageUri) NonStrictExpectations(mockit.NonStrictExpectations) Test(org.junit.Test)

Aggregations

NonStrictExpectations (mockit.NonStrictExpectations)476 Test (org.junit.Test)470 Verifications (mockit.Verifications)154 IotHubConnectionString (com.microsoft.azure.sdk.iot.service.IotHubConnectionString)77 IOException (java.io.IOException)64 HttpConnection (com.microsoft.azure.sdk.iot.service.transport.http.HttpConnection)51 HttpMethod (com.microsoft.azure.sdk.iot.service.transport.http.HttpMethod)51 DeviceTwin (com.microsoft.azure.sdk.iot.service.devicetwin.DeviceTwin)47 MessageProperty (com.microsoft.azure.sdk.iot.device.MessageProperty)32 HttpsSingleMessage (com.microsoft.azure.sdk.iot.device.transport.https.HttpsSingleMessage)31 HttpConnection (com.microsoft.azure.sdk.iot.deps.transport.http.HttpConnection)26 HttpMethod (com.microsoft.azure.sdk.iot.deps.transport.http.HttpMethod)26 HttpsConnection (com.microsoft.azure.sdk.iot.device.transport.https.HttpsConnection)26 HttpsMethod (com.microsoft.azure.sdk.iot.device.transport.https.HttpsMethod)26 HashMap (java.util.HashMap)26 JobClient (com.microsoft.azure.sdk.iot.service.jobs.JobClient)25 IotHubConnectionString (com.microsoft.azure.sdk.iot.device.IotHubConnectionString)17 Date (java.util.Date)16 HashSet (java.util.HashSet)16 Query (com.microsoft.azure.sdk.iot.service.devicetwin.Query)15