Spring Data KeyValue looks great for quickly knocking up a mock microservice. How can I bootstrap it with data?
I tried adding stuff to the KeyValueAdapter
, but by specifying the bean myself, I've ended up with Repository
s that have been wired with a different KeyValueAdapter
, and so don't have the data available.
@Configuration
@EnableMapRepositories
public class PersistenceConfig
{
@Bean
public KeyValueAdapter keyValueAdapter() {
KeyValueAdapter adapter = new MapKeyValueAdapter(ConcurrentHashMap.class);
Account testAccount = new Account();
testAccount.id = "dj-asc-test";
testAccount.givenName = "Gertrude";
adapter.put(testAccount.id, testAccount, "accounts");
Account read = (Account) adapter.get("dj-asc-test", "accounts");
Assert.notNull(read);
return adapter;
}
}