View Javadoc
1   /*
2    * SPDX-FileCopyrightText: Copyright (c) 2012-2026 Yegor Bugayenko
3    * SPDX-License-Identifier: MIT
4    */
5   package com.jcabi.dynamo;
6   
7   import org.hamcrest.MatcherAssert;
8   import org.hamcrest.Matchers;
9   import org.junit.jupiter.api.Test;
10  import software.amazon.awssdk.services.dynamodb.model.ConsumedCapacity;
11  
12  /**
13   * Test case for {@link PrintableConsumedCapacity}.
14   * @since 0.22
15   */
16  final class PrintableConsumedCapacityTest {
17  
18      @Test
19      void printsEmptyStringForNullCapacity() {
20          MatcherAssert.assertThat(
21              "does not print empty string for null capacity",
22              new PrintableConsumedCapacity(null).print(),
23              Matchers.equalTo("")
24          );
25      }
26  
27      @Test
28      void printsFormattedCapacityUnits() {
29          MatcherAssert.assertThat(
30              "does not print formatted capacity units",
31              new PrintableConsumedCapacity(
32                  ConsumedCapacity.builder()
33                      .capacityUnits(12.5)
34                      .tableName("t\u00e9st")
35                      .build()
36              ).print(),
37              Matchers.equalTo("12.50 units")
38          );
39      }
40  }