Search in sources :

Example 1 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_empty1.

// 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]
// Tests_SRS_SERVICE_SDK_JAVA_FEEDBACKBATCHMESSAGE_12_003: [The function shall remove data batch brackets if they exist]
@Test
public void json_data_empty1() {
    // 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 2 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_without_deviceId.

// 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_without_deviceId() throws Exception {
    // Arrange
    String hostName = "xxx";
    String userName = "xxx";
    String sasToken = "xxx";
    IotHubServiceClientProtocol iotHubServiceClientProtocol = IotHubServiceClientProtocol.AMQPS;
    FeedbackReceiver feedbackReceiver = new FeedbackReceiver(hostName, userName, sasToken, iotHubServiceClientProtocol);
    // 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)

Example 3 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_empty_array.

// 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]
// Tests_SRS_SERVICE_SDK_JAVA_FEEDBACKBATCHMESSAGE_12_003: [The function shall remove data batch brackets if they exist]
@Test
public void json_data_empty_array() {
    // 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 4 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_format1.

// 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_format1() {
    // 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 5 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_format3.

// 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_format3() {
    // Arrange
    String jsonString = "Data{[}";
    // Act
    FeedbackBatch feedbackBatch = FeedbackBatchMessage.parse(jsonString);
}
Also used : 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