SimpleSerializedDataTypeRegistry implements SerializedDataTypeRegistry { @Override @NotNull public Class<?> findClass(@NotNull final SerializedDataType type) { Contract.requireArgNotNull("type", type); final Class<?> clasz = map.get(type); if (clasz == null) { throw new IllegalArgumentException("No class found for: " + type); } return clasz; } SimpleSerializedDataTypeRegistry(); final void add(@NotNull final SerializedDataType type, final Class<?> clasz); @Override @NotNull Class<?> findClass(@NotNull final SerializedDataType type);  }
@Test public void testFindClass() { final SimpleSerializedDataTypeRegistry testee = new SimpleSerializedDataTypeRegistry(); final SerializedDataType type = new SerializedDataType("String"); testee.add(type, String.class); assertThat(testee.findClass(type)).isEqualTo(String.class); try { testee.findClass(new SerializedDataType("NotExists")); fail(); } catch (final IllegalArgumentException ex) { assertThat(ex.getMessage()).isEqualTo("No class found for: NotExists"); } }