use of mockit.NonStrictExpectations in project azure-iot-sdk-java by Azure.
the class AmqpResponseVerificationTest method constructor_saves_NOT_ALLOWED_exception.
//Tests_SRS_SERVICE_SDK_JAVA_AMQPRESPONSEVERIFICATION_25_003: [** The function shall save IotHubInvalidOperationException if the amqp delivery state is rejected and error condition is amqp error code amqp:not-allowed **]**
@Test
public void constructor_saves_NOT_ALLOWED_exception() {
//Arrange
String errorDescription = "TestDescription";
new NonStrictExpectations() {
{
mockedRejected.getError();
result = mockedErrorCondition;
mockedErrorCondition.getCondition();
result = AmqpError.NOT_ALLOWED;
mockedErrorCondition.getDescription();
result = errorDescription;
}
};
//Act
AmqpResponseVerification testVerification = new AmqpResponseVerification(mockedRejected);
//Assert
new Verifications() {
{
assertTrue(testVerification.getException() instanceof IotHubInvalidOperationException);
}
};
}
use of mockit.NonStrictExpectations in project azure-iot-sdk-java by Azure.
the class AmqpResponseVerificationTest method constructor_saves_RESOURCE_LIMIT_EXCEEDED_exception.
//Tests_SRS_SERVICE_SDK_JAVA_AMQPRESPONSEVERIFICATION_25_005: [** The function shall save IotHubDeviceMaximumQueueDepthExceededException if the amqp delivery state is rejected and error condition is amqp error code amqp:resource-limit-exceeded **]**
@Test
public void constructor_saves_RESOURCE_LIMIT_EXCEEDED_exception() {
//Arrange
String errorDescription = "TestDescription";
new NonStrictExpectations() {
{
mockedRejected.getError();
result = mockedErrorCondition;
mockedErrorCondition.getCondition();
result = AmqpError.RESOURCE_LIMIT_EXCEEDED;
mockedErrorCondition.getDescription();
result = errorDescription;
}
};
//Act
AmqpResponseVerification testVerification = new AmqpResponseVerification(mockedRejected);
//Assert
new Verifications() {
{
assertTrue(testVerification.getException() instanceof IotHubDeviceMaximumQueueDepthExceededException);
}
};
}
use of mockit.NonStrictExpectations in project azure-iot-sdk-java by Azure.
the class AmqpResponseVerificationTest method getExceptionGets.
//Tests_SRS_SERVICE_SDK_JAVA_AMQPRESPONSEVERIFICATION_25_007: [** The function shall return the exception saved earlier by the constructor **]**
@Test
public void getExceptionGets() {
//Arrange
String errorDescription = "TestDescription";
new NonStrictExpectations() {
{
mockedRejected.getError();
result = mockedErrorCondition;
mockedErrorCondition.getCondition();
result = AmqpError.RESOURCE_LIMIT_EXCEEDED;
mockedErrorCondition.getDescription();
result = errorDescription;
}
};
//Act
AmqpResponseVerification testVerification = new AmqpResponseVerification(mockedRejected);
//Assert
new Verifications() {
{
assertTrue(testVerification.getException() instanceof IotHubDeviceMaximumQueueDepthExceededException);
}
};
}
use of mockit.NonStrictExpectations in project azure-iot-sdk-java by Azure.
the class DeviceClientTest method openBadOpensTransportThrows.
/* Codes_SRS_DEVICECLIENT_21_007: [If the opening a connection via deviceIO is not successful, the open shall throw IOException.] */
@Test
public void openBadOpensTransportThrows() throws IOException, URISyntaxException {
// arrange
final String connString = "HostName=iothub.device.com;CredentialType=SharedAccessKey;DeviceId=testdevice;" + "SharedAccessKey=adjkl234j52=";
final IotHubClientProtocol protocol = IotHubClientProtocol.AMQPS;
new NonStrictExpectations() {
{
mockDeviceIO.open();
result = new IOException();
}
};
DeviceClient client = new DeviceClient(connString, protocol);
// act
try {
client.open();
} catch (IOException expected) {
// Don't do anything, throw expected.
}
// assert
new Verifications() {
{
mockDeviceIO.open();
times = 1;
}
};
}
use of mockit.NonStrictExpectations in project azure-iot-sdk-java by Azure.
the class CustomLoggerTest method testLogTrace.
// Tests_SRS_CUSTOMERLOGGER_25_002: [The function shall print message for TRACE level.]
@Test
public void testLogTrace(@Mocked final Logger mockLogger) {
final String message = "This is TRACE message";
new NonStrictExpectations() {
{
Logger.getLogger((Class) any);
result = mockLogger;
mockLogger.isEnabledFor(Level.TRACE);
result = true;
}
};
new CustomLogger(this.getClass()).LogTrace(message);
new Verifications() {
{
mockLogger.trace(anyString);
times = 1;
}
};
}
Aggregations