Search in sources :

Example 1 with IllegalShardRoutingStateException

use of org.opensearch.cluster.routing.IllegalShardRoutingStateException in project OpenSearch by opensearch-project.

the class ExceptionSerializationTests method testIllegalShardRoutingStateException.

public void testIllegalShardRoutingStateException() throws IOException {
    final ShardRouting routing = TestShardRouting.newShardRouting("test", 0, "xyz", "def", false, ShardRoutingState.STARTED);
    final String routingAsString = routing.toString();
    IllegalShardRoutingStateException serialize = serialize(new IllegalShardRoutingStateException(routing, "foo", new NullPointerException()));
    assertNotNull(serialize.shard());
    assertEquals(routing, serialize.shard());
    assertEquals(routingAsString + ": foo", serialize.getMessage());
    assertTrue(serialize.getCause() instanceof NullPointerException);
    serialize = serialize(new IllegalShardRoutingStateException(routing, "bar", null));
    assertNotNull(serialize.shard());
    assertEquals(routing, serialize.shard());
    assertEquals(routingAsString + ": bar", serialize.getMessage());
    assertNull(serialize.getCause());
}
Also used : IllegalShardRoutingStateException(org.opensearch.cluster.routing.IllegalShardRoutingStateException) ShardRouting(org.opensearch.cluster.routing.ShardRouting) TestShardRouting(org.opensearch.cluster.routing.TestShardRouting)

Aggregations

IllegalShardRoutingStateException (org.opensearch.cluster.routing.IllegalShardRoutingStateException)1 ShardRouting (org.opensearch.cluster.routing.ShardRouting)1 TestShardRouting (org.opensearch.cluster.routing.TestShardRouting)1