-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add common methods to DeliveryState.
- Loading branch information
Showing
2 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
sdk/core/azure-core-amqp/src/test/java/com/azure/core/amqp/models/DeliveryStateTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
package com.azure.core.amqp.models; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.MethodSource; | ||
|
||
import java.util.Collection; | ||
import java.util.stream.Stream; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
/** | ||
* Tests {@link DeliveryState} | ||
*/ | ||
public class DeliveryStateTest { | ||
/** | ||
* Tests that all the values are available. | ||
*/ | ||
@Test | ||
public void values() { | ||
// Arrange | ||
final DeliveryState[] expected = new DeliveryState[] { | ||
DeliveryState.ACCEPTED, DeliveryState.MODIFIED, DeliveryState.RECEIVED, DeliveryState.REJECTED, | ||
DeliveryState.RELEASED, DeliveryState.TRANSACTIONAL | ||
}; | ||
|
||
// Act | ||
final Collection<DeliveryState> actual = DeliveryState.values(); | ||
|
||
// Assert | ||
for (DeliveryState state : expected) { | ||
assertTrue(actual.contains(state)); | ||
} | ||
} | ||
|
||
/** | ||
* Arguments for fromString. | ||
* @return Test arguments. | ||
*/ | ||
public static Stream<String> fromString() { | ||
return Stream.of("MODIFIED", "FOO-BAR-NEW"); | ||
} | ||
|
||
/** | ||
* Tests that we can get the corresponding value and a new one if it does not exist. | ||
* | ||
* @param deliveryState Delivery states to test. | ||
*/ | ||
@MethodSource | ||
@ParameterizedTest | ||
public void fromString(String deliveryState) { | ||
// Act | ||
final DeliveryState state = DeliveryState.fromString(deliveryState); | ||
|
||
// Assert | ||
assertNotNull(state); | ||
assertEquals(deliveryState, state.toString()); | ||
} | ||
} |