package com.johnstarich.moviematcher.app;

import com.mongodb.Mongo;
import com.mongodb.MongoClient;
import de.flapdoodle.embed.mongo.MongodExecutable;
import de.flapdoodle.embed.mongo.MongodProcess;
import de.flapdoodle.embed.mongo.MongodStarter;
import de.flapdoodle.embed.mongo.config.MongodConfigBuilder;
import de.flapdoodle.embed.mongo.config.Net;
import de.flapdoodle.embed.mongo.distribution.Version;
import de.flapdoodle.embed.process.runtime.Network;
import junit.framework.TestCase;

/**
 * Created by johnstarich on 4/14/16.
 */
public abstract class AbstractMongoDBTest extends TestCase {
	/**
	 * EmbeddedMongo author's note:
	 * please store Starter or RuntimeConfig in a static final field
	 * if you want to use artifact store caching (or else disable caching)
	 */
	private static final MongodStarter starter = MongodStarter.getDefaultInstance();
	private static final int MONGO_PORT = 27017;
	private MongodExecutable _mongodExe;
	private MongodProcess _mongod;
	private MongoClient _mongo;

	@Override
	protected void setUp() throws Exception {
		_mongodExe = starter.prepare(new MongodConfigBuilder()
				.version(Version.Main.PRODUCTION)
				.net(new Net(MONGO_PORT, Network.localhostIsIPv6()))
				.build());
		_mongod = _mongodExe.start();

		super.setUp();

		_mongo = new MongoClient("localhost", MONGO_PORT);
	}

	@Override
	protected void tearDown() throws Exception {
		super.tearDown();

		_mongod.stop();
		_mongodExe.stop();
	}

	public Mongo getMongo() {
		return _mongo;
	}
}
@@ -94,16 +94,58 @@
 Client;%0A
+import de.flapdoodle.embed.mongo.Command;%0A
 import d
@@ -323,35 +323,72 @@
 .config.
-MongodConfigBuilder
+*;%0Aimport de.flapdoodle.embed.mongo.distribution.Version
 ;%0Aimport
@@ -408,29 +408,31 @@
 e.embed.
-mongo
+process
 .config.
 Net;%0Aimp
@@ -423,19 +423,30 @@
 .config.
-Net
+IRuntimeConfig
 ;%0Aimport
@@ -470,34 +470,38 @@
 bed.
-mongo.distribution.Version
+process.extract.UserTempNaming
 ;%0Aim
@@ -919,45 +919,8 @@
 rter
- = MongodStarter.getDefaultInstance()
 ;%0A%09p
@@ -1063,16 +1063,424 @@
 mongo;%0A%0A
+%09static %7B%0A%09%09Command command = Command.MongoD;%0A%0A%09%09IRuntimeConfig runtimeConfig = new RuntimeConfigBuilder()%0A%09%09%09.defaults(command)%0A%09%09%09.artifactStore(new ExtractedArtifactStoreBuilder()%0A%09%09%09%09.defaults(command)%0A%09%09%09%09.download(new DownloadConfigBuilder()%0A%09%09%09%09%09.defaultsForCommand(command).build())%0A%09%09%09%09.executableNaming(new UserTempNaming()))%0A%09%09%09.build();%0A%0A%09%09starter = MongodStarter.getInstance(runtimeConfig);%0A%09%7D%0A%0A
 %09@Overri

Fix constant firewall warning popups