@Test
public void getPrimitive_works() throws Exception {

  KeyTypeManager<AesGcmKey> keyManager =
      new TestKeyTypeManager(
          new TestKeyTypeManager.PrimitiveFactory<Primitive1, AesGcmKey>(Primitive1.class) {
            @Override
            public Primitive1 getPrimitive(AesGcmKey key) {
              return new Primitive1(key.getKeyValue());
            }
          },
          new TestKeyTypeManager.PrimitiveFactory<Primitive2, AesGcmKey>(Primitive2.class) {
            @Override
            public Primitive2 getPrimitive(AesGcmKey key) {
              return new Primitive2(key.getKeyValue().size());
            }
          });
  Primitive1 primitive1 =
      keyManager.getPrimitive(
          AesGcmKey.newBuilder().setKeyValue(TEST_BYTESTRING).build(), Primitive1.class);
  assertThat(primitive1.getKeyValue()).isEqualTo(TEST_BYTESTRING);
  Primitive2 primitive2 =
      keyManager.getPrimitive(
          AesGcmKey.newBuilder().setKeyValue(TEST_BYTESTRING).build(), Primitive2.class);
  assertThat(primitive2.getSize()).isEqualTo(TEST_BYTESTRING.size());
}