Search in sources :

Example 6 with FeedbackBatch

use of com.microsoft.azure.sdk.iot.service.FeedbackBatch in project azure-iot-sdk-java by Azure.

the class FeedbackBatchMessageTest method json_empty.

// Tests_SRS_SERVICE_SDK_JAVA_FEEDBACKBATCHMESSAGE_12_001: [The function shall return an empty FeedbackBatch object if the input is empty or null]
@Test
public void json_empty() {
    // Arrange
    String jsonString = "";
    // Act
    FeedbackBatch feedbackBatch = FeedbackBatchMessage.parse(jsonString);
    // Assert
    assertNotNull(feedbackBatch);
}
Also used : FeedbackBatch(com.microsoft.azure.sdk.iot.service.FeedbackBatch) Test(org.junit.Test)

Example 7 with FeedbackBatch

use of com.microsoft.azure.sdk.iot.service.FeedbackBatch in project azure-iot-sdk-java by Azure.

the class FeedbackBatchMessageTest method json_data_invalid_format4.

// Tests_SRS_SERVICE_SDK_JAVA_FEEDBACKBATCHMESSAGE_12_004: [The function shall throw a JsonParsingException if the parsing failed]
// Assert
@Test(expected = JsonParsingException.class)
public void json_data_invalid_format4() {
    // Arrange
    String jsonString = "Data{[]";
    // Act
    FeedbackBatch feedbackBatch = FeedbackBatchMessage.parse(jsonString);
}
Also used : FeedbackBatch(com.microsoft.azure.sdk.iot.service.FeedbackBatch) Test(org.junit.Test)

Example 8 with FeedbackBatch

use of com.microsoft.azure.sdk.iot.service.FeedbackBatch in project azure-iot-sdk-java by Azure.

the class FeedbackBatchMessageTest method json_data_invalid_format2.

// Tests_SRS_SERVICE_SDK_JAVA_FEEDBACKBATCHMESSAGE_12_002: [The function shall return an empty FeedbackBatch object if the content of the Data input is empty]
@Test
public void json_data_invalid_format2() {
    // Arrange
    String jsonString = "Data{]";
    // Act
    FeedbackBatch feedbackBatch = FeedbackBatchMessage.parse(jsonString);
    // Assert
    assertNotNull(feedbackBatch);
}
Also used : FeedbackBatch(com.microsoft.azure.sdk.iot.service.FeedbackBatch) Test(org.junit.Test)

Example 9 with FeedbackBatch

use of com.microsoft.azure.sdk.iot.service.FeedbackBatch in project azure-iot-sdk-java by Azure.

the class FeedbackBatchMessageTest method json_data_invalid_format6.

// Tests_SRS_SERVICE_SDK_JAVA_FEEDBACKBATCHMESSAGE_12_004: [The function shall throw a JsonParsingException if the parsing failed]
// Assert
@Test(expected = JsonParsingException.class)
public void json_data_invalid_format6() {
    // Arrange
    String jsonString = "[,xxx]";
    // Act
    FeedbackBatch feedbackBatch = FeedbackBatchMessage.parse(jsonString);
}
Also used : FeedbackBatch(com.microsoft.azure.sdk.iot.service.FeedbackBatch) Test(org.junit.Test)

Example 10 with FeedbackBatch

use of com.microsoft.azure.sdk.iot.service.FeedbackBatch in project azure-iot-sdk-java by Azure.

the class FeedbackReceiverTest method receive_async.

// Tests_SRS_SERVICE_SDK_JAVA_FEEDBACKRECEIVER_12_013: [The function shall create an async wrapper around the receive() function call]
@Test
public void receive_async() throws Exception {
    // Arrange
    String hostName = "xxx";
    String userName = "xxx";
    String sasToken = "xxx";
    String deviceId = "xxx";
    IotHubServiceClientProtocol iotHubServiceClientProtocol = IotHubServiceClientProtocol.AMQPS;
    FeedbackReceiver feedbackReceiver = new FeedbackReceiver(hostName, userName, sasToken, iotHubServiceClientProtocol, deviceId);
    // Assert
    new Expectations() {

        {
            amqpReceive.receive(Deencapsulation.getField(feedbackReceiver, "DEFAULT_TIMEOUT_MS"));
            feedbackReceiver.receive();
        }
    };
    // Act
    CompletableFuture<FeedbackBatch> completableFuture = feedbackReceiver.receiveAsync();
    completableFuture.get();
}
Also used : Expectations(mockit.Expectations) FeedbackReceiver(com.microsoft.azure.sdk.iot.service.FeedbackReceiver) IotHubServiceClientProtocol(com.microsoft.azure.sdk.iot.service.IotHubServiceClientProtocol) FeedbackBatch(com.microsoft.azure.sdk.iot.service.FeedbackBatch) Test(org.junit.Test)

Aggregations

FeedbackBatch (com.microsoft.azure.sdk.iot.service.FeedbackBatch)15 Test (org.junit.Test)15 FeedbackReceiver (com.microsoft.azure.sdk.iot.service.FeedbackReceiver)4 IotHubServiceClientProtocol (com.microsoft.azure.sdk.iot.service.IotHubServiceClientProtocol)4 Expectations (mockit.Expectations)4