### Question:
MongoDBServiceDatabase implements ServiceDatabase { @Override public void insert(ServiceObject item) throws ExistingResourceException, PersistentStoreFailureException { try { if (logger.isDebugEnabled()) { logger.debug("inserting: " + item.toDBObject()); } database.requestStart(); database.requestEnsureConnection(); DBObject db = item.toDBObject(); serviceCollection.insert(db, WriteConcern.SAFE); database.requestDone(); logger.info("inserted Service Endpoint record with ID: " + item.getEndpointID()); } catch (MongoException e) { if (e instanceof DuplicateKey) { throw new ExistingResourceException("Endpoint record with ID: " + item.getEndpointID() + " - already exists", e); } else { throw new PersistentStoreFailureException(e); } } } MongoDBServiceDatabase();  MongoDBServiceDatabase(String hostname, Integer port, String dbName,
			String colName); @Override void insert(ServiceObject item); @Override ServiceObject getServiceByUrl(String identifier); @Override ServiceObject getServiceByEndpointID(String identifier); @Override void deleteByEndpointID(String endpointID); @Override void update(ServiceObject sObj); @Override List<ServiceObject> query(String query); @Override List<ServiceObject> query(String query, Integer limit, Integer skip); @Override List<ServiceObject> query(String query, Integer skip); @Override JSONArray queryJSON(String query); @Override JSONArray queryJSON(String query, Integer limit, Integer skip); @Override JSONArray queryJSON(String query, Integer skip); @Override JSONArray queryJSONWithLimit(String s, Integer limit); @Override JSONArray queryDistinctJSON(String attributeName); @Override JSONArray paginatedQuery(String query, Integer pageSize, String id); @Override JSONArray paginatedQuery(String query, Integer pageSize, String id,
			String orderBy); @Override void deleteAll(); List<ServiceObject> findAll(); @Override void findAndDelete(String query); void dropCollection(); void dropDB(); void dropDB(String dbName); DB createOrGetDB(String name); @Override String getDBVersion(); @Override Long size(); @Deprecated JSONArray facetedQuery(Set<String> j); @Override JSONArray facetedQuery(Map<String, String> map); boolean isVersionNumber241OrGreater();  }### Answer:
@Test(expected = ExistingResourceException.class) public void testRedundantServiceEntries() throws JSONException, PersistentStoreFailureException, ExistingResourceException { JSONObject entry = new JSONObject(); entry.put(ServiceBasicAttributeNames.SERVICE_ENDPOINT_ID .getAttributeName(), "http: entry.put(ServiceBasicAttributeNames.SERVICE_TYPE.getAttributeName(), "some_service_1"); ServiceObject s1 = new ServiceObject(entry); db.insert(s1); JSONObject entry1 = new JSONObject(); entry1.put(ServiceBasicAttributeNames.SERVICE_ENDPOINT_ID .getAttributeName(), "http: entry1.put(ServiceBasicAttributeNames.SERVICE_TYPE.getAttributeName(), "some_service_2"); ServiceObject s2 = new ServiceObject(entry1); db.insert(s2); JSONObject entry2 = new JSONObject(); entry2.put(ServiceBasicAttributeNames.SERVICE_ENDPOINT_ID .getAttributeName(), "http: entry2.put(ServiceBasicAttributeNames.SERVICE_TYPE.getAttributeName(), "some_service_3"); ServiceObject s3 = new ServiceObject(entry2); db.insert(s3); }