@Test public void testInsert() { Entity entity1 = new MongoEntity("studentSectionAssociation", new HashMap<String, Object>(studentSectionAssociation)); entity1.getBody().put("sectionId", SECTION2); entity1.getBody().put("endDate", ENDDATE2); entity1.getMetaData().put("tenantId", "TEST"); Entity entity2 = new MongoEntity("studentSectionAssociation", new HashMap<String, Object>(studentSectionAssociation)); entity2.getBody().put("studentId", STUDENT2); entity2.getMetaData().put("tenantId", "TEST"); assertTrue(denormalizer.denormalization("studentSectionAssociation").insert(Arrays.asList(entity1, entity2))); verify(studentCollection).update(eq(BasicDBObjectBuilder.start("_id", STUDENT2).get()), argThat(new ArgumentMatcher<DBObject>() { @Override @SuppressWarnings("unchecked") public boolean matches(Object argument) { DBObject updateObject = (DBObject) argument; Map<String, Object> push = (Map<String, Object>) updateObject.get("$pushAll"); if (push == null) { return false; } Collection<Object> toPush = push.values(); if (toPush.size() != 1) { return false; } Object[] sectionRefsToPush = (Object[]) toPush.iterator().next(); List<String> ssaIds = new ArrayList<String>(push.keySet()); return ((((Map<String, Object>) sectionRefsToPush[0]).get("_id").equals(SECTION1)) && (((Map<String, Object>) sectionRefsToPush[0]).get("endDate").equals(ENDDATE2)) && (((Map<String, Object>) sectionRefsToPush[0]).get("beginDate").equals(BEGINDATE)) && ssaIds.get(0).equals("section")); } }), eq(true), eq(true), eq(WriteConcern.SAFE)); verify(studentCollection).update(eq(BasicDBObjectBuilder.start("_id", STUDENT1).get()), argThat(new ArgumentMatcher<DBObject>() { @Override @SuppressWarnings("unchecked") public boolean matches(Object argument) { DBObject updateObject = (DBObject) argument; Map<String, Object> push = (Map<String, Object>) updateObject.get("$pushAll"); if (push == null) { return false; } Collection<Object> toPush = push.values(); if (toPush.size() != 1) { return false; } Object[] sectionRefsToPush = (Object[]) toPush.iterator().next(); List<String> ssaIds = new ArrayList<String>(push.keySet()); return ((((Map<String, Object>) sectionRefsToPush[0]).get("_id").equals(SECTION2)) && (((Map<String, Object>) sectionRefsToPush[0]).get("endDate").equals(ENDDATE2)) && (((Map<String, Object>) sectionRefsToPush[0]).get("beginDate").equals(BEGINDATE)) && ssaIds.get(0).equals("section")); } }), eq(true), eq(true), eq(WriteConcern.SAFE)); }
public Denormalization denormalization(String docType) { return denormalizations.get(docType); }
Denormalizer { public Denormalization denormalization(String docType) { return denormalizations.get(docType); } }
Denormalizer { public Denormalization denormalization(String docType) { return denormalizations.get(docType); } Denormalizer(MongoTemplate template); }
Denormalizer { public Denormalization denormalization(String docType) { return denormalizations.get(docType); } Denormalizer(MongoTemplate template); DenormalizationBuilder denormalize(String type); boolean isDenormalizedDoc(String docType); Denormalization denormalization(String docType); boolean isCached(String docType); void addToCache(List<Entity> entityList, String collectionName); }
Denormalizer { public Denormalization denormalization(String docType) { return denormalizations.get(docType); } Denormalizer(MongoTemplate template); DenormalizationBuilder denormalize(String type); boolean isDenormalizedDoc(String docType); Denormalization denormalization(String docType); boolean isCached(String docType); void addToCache(List<Entity> entityList, String collectionName);  }