}
@Test
public void shouldApplyConfiguredWriteConcernForUpdateOfAssociationStoredAsDocument() {
// given a persisted player with one associated golf course
MockMongoClient mockClient = mockClient()
.insert( "GolfPlayer", getPlayer() )
.insert( "GolfCourse", getGolfCourse() )
.insert( "Associations", getPlayedCoursesAssociationAsDocument() )
.build();
setupSessionFactory( new MongoDBDatastoreProvider( mockClient.getClient() ), AssociationStorageType.ASSOCIATION_DOCUMENT );
Session session = sessions.openSession();
Transaction transaction = session.beginTransaction();
// when merging the player with two associated courses
GolfPlayer ben = new GolfPlayer( 1L, "Ben", 0.1, new GolfCourse( 1L, "Bepple Peach" ), new GolfCourse( 2L, "Ant Sandrews" ) );
session.merge( ben );
transaction.commit();
session.close();
// then expect one update to the association collection
verify( mockClient.getCollection( "Associations" ), times( 1 ) ).update( any( DBObject.class ), any( DBObject.class ), anyBoolean(), anyBoolean(), eq( WriteConcern.MAJORITY ) );
}