### Question:
EmbeddedOpenDJManager { public State getState() { return state; } EmbeddedOpenDJManager(Debug logger, String baseDirectory, OpenDJUpgrader upgrader); State getState(); State upgrade(); static final String OPENDJ_DIR; }### Answer:
@Test public void whenBaseDirectoryDoesNotExistItIsInNoEmbeddedInstanceState() { String baseDirectory = "/tmp/non-existent-base-directory"; EmbeddedOpenDJManager embeddedOpenDJManager = new EmbeddedOpenDJManager(logger, baseDirectory, upgrader); assertThat(embeddedOpenDJManager.getState()).isEqualTo(NO_EMBEDDED_INSTANCE); }
@Test public void whenOpenDJDirectoryDoesNotExistItIsInNoEmbeddedInstanceState() throws Exception { createBaseDirectory("empty-base-directory"); EmbeddedOpenDJManager embeddedOpenDJManager = new EmbeddedOpenDJManager(logger, baseDirectory, upgrader); assertThat(embeddedOpenDJManager.getState()).isEqualTo(NO_EMBEDDED_INSTANCE); }
@Test public void whenOpenDJDirectoryExistsAndDoesNotRequireUpgradeItIsInConfiguredState() throws Exception { EmbeddedOpenDJManager embeddedOpenDJManager = setupInstallOpenDJNotRequiringUpgrade(); assertThat(embeddedOpenDJManager.getState()).isEqualTo(CONFIGURED); }
@Test public void whenOpenDJDirectoryExistsAndRequireUpgradeItIsInUpgradeRequiredState() throws Exception { EmbeddedOpenDJManager embeddedOpenDJManager = setupInstallOpenDJRequiringUpgrade(); assertThat(embeddedOpenDJManager.getState()).isEqualTo(UPGRADE_REQUIRED); }