DefaultGemfireRepository implements DataStoreAware, RepositoryMetadataAware { public Object save(Wrapper<Object, Object> wrapper) { log.info("Going to save a wrapped data store object"); final Object entity = wrapper.getEntity(); final Object key = wrapper.getKey(); if (repositoryMetadata.getEntityType().isInstance(entity)) { log.debug("Since the entity is of the same type as the actual entity type supported by the data store, " + "we know how to set the key on the wrapped entity."); PropertyUtils.setPropertyValue(entity, repositoryMetadata.getIdentifierProperty(), key); } dataStore.save(key, entity); return entity; }  Object save(Wrapper<Object, Object> wrapper); @Override void setDataStore(DataStore dataStore); @Override void setRepositoryMetadata(RepositoryMetadata repositoryMetadata);  }
@Test public void testSave() { final MemoryDataStore<Object, Person> dataStore = new MemoryDataStore<>(Person.class); final ImmutableRepositoryMetadata repositoryMetadata = new ImmutableRepositoryMetadata(String.class, Person.class, SimplePersonRepository.class, "id"); final DefaultGemfireRepository repository = new DefaultGemfireRepository(); repository.setDataStore(dataStore); repository.setRepositoryMetadata(repositoryMetadata); final String id = "12345"; final Wrapper<?, ?> wrapper = new Wrapper<>(new Person(), id); final Object saved = repository.save((Wrapper<Object, Object>) wrapper); assertThat(saved, is(notNullValue())); assertThat(saved, is(instanceOf(Person.class))); assertThat(((Person) saved).getId(), is(notNullValue())); assertThat(((Person) saved).getId(), is(id)); }