Map<String, Double> fieldValueCount = new HashMap<String, Double>();
fieldValueCount.put("elephant", 1.0);
fieldValueCount.put("pig", 1.0);
FieldValueCounter c1 = new FieldValueCounter(myFVCounter, fieldValueCount);
FieldValueCounter myCounter = fieldValueCounterRepository.save(c1);
assertThat(myCounter.getName(), is(myFVCounter));
// Create and save a Counter named 'yourCounter'
fieldValueCount = new HashMap<String, Double>();
fieldValueCount.put("turtle", 5.0);
fieldValueCount.put("fish", 6.0);
fieldValueCount.put("bird", 7.0);
FieldValueCounter c2 = new FieldValueCounter(yourFVCounter, fieldValueCount);
FieldValueCounter yourCounter = fieldValueCounterRepository.save(c2);
assertThat(yourCounter.getName(), is(yourFVCounter));
// Retrieve by name
FieldValueCounter result = fieldValueCounterRepository.findOne(myFVCounter);
assertThat(result, is(notNullValue()));
assertThat(result.getName(), equalTo(myCounter.getName()));
assertThat(result.getFieldValueCount().size(), equalTo(2));
fieldValueCount = result.getFieldValueCount();
assertThat(fieldValueCount.get("elephant"), equalTo(1.0));
assertThat(fieldValueCount.get("pig"), equalTo(1.0));
result = fieldValueCounterRepository.findOne(yourCounter.getName());
assertThat(result.getName(), equalTo(yourCounter.getName()));
assertThat(result.getFieldValueCount().size(), equalTo(3));
fieldValueCount = result.getFieldValueCount();
assertThat(fieldValueCount.get("turtle"), equalTo(5.0));
assertThat(fieldValueCount.get("fish"), equalTo(6.0));
assertThat(fieldValueCount.get("bird"), equalTo(7.0));
List<FieldValueCounter> counters = (List<FieldValueCounter>) fieldValueCounterRepository.findAll();