/** * Clean up after execution by dropping used test db instance. * * @throws Exception */ @PreDestroy void dropTestDB() throws Exception { operations.dropCollection(BlogPost.class); } }
/** * Clean up resources on shutdown */ @PreDestroy public void cleanUpWhenShuttingDown() { // Disable profiling setProfilingLevel(0); if (operations.collectionExists(SYSTEM_PROFILE_DB)) { operations.dropCollection(SYSTEM_PROFILE_DB); } }
@After public void cleanUp() { mongoTemplate.dropCollection(COLLECTION_NAME); }
@After public void cleanUp() { mongoTemplate.dropCollection(COLLECTION_NAME); }
/** * The method clears and deletes all logs. * * @since 1.7 */ @Override public void clearAll() { //drop vs remove => https://stackoverflow.com/q/12147783 mongoOperations.dropCollection(GraphQLEventDocument.class); }
@Override public void resetImageStore() throws IOException { // empty mongo collections fullImageMongoTemplate.dropCollection("imageFull"); previewImageMongoTemplate.dropCollection("imagePreview"); thumbnailImageMongoTemplate.dropCollection("imageThumbnail"); imageInfoMongoTemplate.dropCollection("imageInfo"); }
/** * The method clears and deletes all logs. */ @Override public void clearAll() { //drop vs remove => https://stackoverflow.com/q/12147783 mongoOperations.dropCollection(RestEventDocument.class); }
/** * The method clears and deletes all logs. */ @Override public void clearAll() { //drop vs remove => https://stackoverflow.com/q/12147783 mongoOperations.dropCollection(SoapEventDocument.class); }
/** * Drops collections with specified name. * @param collectionName */ protected void dropCollection(String collectionName) { if (mongoTemplate.collectionExists(collectionName)) { mongoTemplate.dropCollection(collectionName); } }
@Override public void afterPropertiesSet() throws Exception { if (this.dropCollection) { log.debug("Dropping database collection: {}", this.collectionName); this.mongoTemplate.dropCollection(this.collectionName); } if (!this.mongoTemplate.collectionExists(this.collectionName)) { log.debug("Creating database collection: {}", this.collectionName); this.mongoTemplate.createCollection(this.collectionName); } }
@Bean public CommandLineRunner initData(MongoOperations mongo) { return (String... args) -> { mongo.dropCollection(City.class); mongo.createCollection(City.class); getCities().forEach(mongo::save); }; }
@Override public void dropResources() { IndexOperations indexOperations = mongoTemplate.indexOps(collection); indexOperations.dropAllIndexes(); mongoTemplate.dropCollection(collection); } }
@After public void after() { mongoOperations.dropCollection(InventoryDocument.class); } }
@After public void after() { mongoOperations.dropCollection("soapResource"); } }
@After public void after() { mongoOperations.dropCollection("sessionToken"); }
@After public void after() { mongoOperations.dropCollection("soapMockResponse"); }
@After public void after() { mongoOperations.dropCollection("soapEvent"); }
@After public void after() { mongoOperations.dropCollection("restProject"); }
@Bean public CommandLineRunner initData(MongoOperations mongo) { return (String... args) -> { mongo.dropCollection(Car.class); mongo.createCollection(Car.class, CollectionOptions.empty().size(1000000).capped()); LocationGenerator gen = new LocationGenerator(40.740900, -73.988000); Flux.range(1, 100) .map(i -> new Car(i.longValue(), gen.location())) .doOnNext(mongo::save) .blockLast(Duration.ofSeconds(5)); }; }
public void run() { if (mongoOperations.collectionExists(Person.class)) { mongoOperations.dropCollection(Person.class); } mongoOperations.createCollection(Person.class); Person p = new Person("John", 39); Account a = new Account("1234-59873-893-1", Account.Type.SAVINGS, 123.45D); p.getAccounts().add(a); mongoOperations.insert(p); List<Person> results = mongoOperations.findAll(Person.class); System.out.println("Results: " + results); }