@Test public void testMultipleInsert() { Entity ssa1 = new MongoEntity("studentSectionAssociation", studentSectionAssociation); Entity ssa2 = new MongoEntity("studentSectionAssociation", new HashMap<String, Object>( studentSectionAssociation)); ssa2.getBody().put("studentId", STUDENT2); Entity ssa3 = new MongoEntity("studentSectionAssociation", new HashMap<String, Object>( studentSectionAssociation)); ssa3.getBody().put("sectionId", SECTION2); assertTrue(underTest.subDoc("studentSectionAssociation").insert(Arrays.asList(ssa1, ssa2, ssa3))); verify(sectionCollection).update(argThat(new ArgumentMatcher<DBObject>() { @Override public boolean matches(Object argument) { DBObject query = (DBObject) argument; DBObject sectionQuery = (DBObject) query.get("studentSectionAssociation._id"); return query.get("_id").equals(SECTION2) && sectionQuery != null && sectionQuery.get("$nin").equals(Arrays.asList("subdocid")); } }), 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[] studentSectionsToPush = (Object[]) toPush.iterator().next(); List<String> ssaIds = new ArrayList<String>(push.keySet()); return ((Map<String, Map<String, Object>>) studentSectionsToPush[0]).get("body").get("beginDate") .equals(BEGINDATE) && ssaIds.get(0).equals("studentSectionAssociation"); } }), eq(false), eq(false), eq(WriteConcern.SAFE)); verify(sectionCollection).update(argThat(new ArgumentMatcher<DBObject>() { @Override public boolean matches(Object argument) { DBObject query = (DBObject) argument; DBObject sectionQuery = (DBObject) query.get("studentSectionAssociation._id"); return query.get("_id").equals(SECTION1) && sectionQuery != null && sectionQuery.get("$nin").equals(Arrays.asList("subdocid", "subdocid")); } }), 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[] studentSectionsToPush = (Object[]) toPush.iterator().next(); return studentSectionsToPush.length == 2; } }), eq(false), eq(false), eq(WriteConcern.SAFE)); }
public Location subDoc(String docType) { return locations.get(docType); }
SubDocAccessor { public Location subDoc(String docType) { return locations.get(docType); } }
SubDocAccessor { public Location subDoc(String docType) { return locations.get(docType); } SubDocAccessor(MongoTemplate template, UUIDGeneratorStrategy didGenerator,
                          INaturalKeyExtractor naturalKeyExtractor); }
SubDocAccessor { public Location subDoc(String docType) { return locations.get(docType); } SubDocAccessor(MongoTemplate template, UUIDGeneratorStrategy didGenerator,
                          INaturalKeyExtractor naturalKeyExtractor); LocationBuilder store(String type); Location createLocation(String type, String parentColl, Map<String, String> lookup, String subField); boolean isSubDoc(String docType); Location subDoc(String docType); static void main(String[] args); }
SubDocAccessor { public Location subDoc(String docType) { return locations.get(docType); } SubDocAccessor(MongoTemplate template, UUIDGeneratorStrategy didGenerator,
                          INaturalKeyExtractor naturalKeyExtractor); LocationBuilder store(String type); Location createLocation(String type, String parentColl, Map<String, String> lookup, String subField); boolean isSubDoc(String docType); Location subDoc(String docType); static void main(String[] args);  }