### Question:
MongoDBSchemaManager extends AbstractSchemaManager implements SchemaManager { protected void validate(List<TableInfo> tableInfos) { db = mongo.getDB(databaseName); if (db == null) { logger.error("Database " + databaseName + "does not exist"); throw new SchemaGenerationException("database " + databaseName + "does not exist", "mongoDb", databaseName); } else { for (TableInfo tableInfo : tableInfos) { if (tableInfo.getLobColumnInfo().isEmpty()) { if (!db.collectionExists(tableInfo.getTableName())) { logger.error("Collection " + tableInfo.getTableName() + "does not exist in db " + db.getName()); throw new SchemaGenerationException("Collection " + tableInfo.getTableName() + " does not exist in db " + db.getName(), "mongoDb", databaseName, tableInfo.getTableName()); } } else { checkMultipleLobs(tableInfo); if (!db.collectionExists(tableInfo.getTableName() + MongoDBUtils.FILES)) { logger.error("Collection " + tableInfo.getTableName() + MongoDBUtils.FILES + "does not exist in db " + db.getName()); throw new SchemaGenerationException("Collection " + tableInfo.getTableName() + " does not exist in db " + db.getName(), "mongoDb", databaseName, tableInfo.getTableName()); } if (!db.collectionExists(tableInfo.getTableName() + MongoDBUtils.CHUNKS)) { logger.error("Collection " + tableInfo.getTableName() + MongoDBUtils.CHUNKS + "does not exist in db " + db.getName()); throw new SchemaGenerationException("Collection " + tableInfo.getTableName() + " does not exist in db " + db.getName(), "mongoDb", databaseName, tableInfo.getTableName()); } } } } } MongoDBSchemaManager(String clientFactory, Map<String, Object> externalProperties,
            final KunderaMetadata kunderaMetadata); @Override /** * Export schema handles the handleOperation method. */ void exportSchema(final String persistenceUnit, List<TableInfo> schemas); void dropSchema(); @Override boolean validateEntity(Class clazz);  }### Answer:
@Test public void testValidate() { try { Map props = new HashMap(); props.put(PersistenceProperties.KUNDERA_DDL_AUTO_PREPARE, "validate"); emf = Persistence.createEntityManagerFactory(persistenceUnit, props); Assert.fail("Schema generation exception should have been thrown since schema doesn't exist"); } catch (Exception e) { Assert.assertNotNull(e); } }