提交 438949de 编写于 作者: wu-sheng's avatar wu-sheng 提交者: GitHub

Merge pull request #137 from ascrutae/zhangxin/enum-not-found

fix start error issue
...@@ -32,6 +32,8 @@ public class EsConfig { ...@@ -32,6 +32,8 @@ public class EsConfig {
} }
public enum IndexInitMode { public enum IndexInitMode {
auto, forced, manual AUTO,
FORCED,
MANUAL
} }
} }
...@@ -17,12 +17,12 @@ public enum IndexCreator { ...@@ -17,12 +17,12 @@ public enum IndexCreator {
private Logger logger = LogManager.getFormatterLogger(IndexCreator.class); private Logger logger = LogManager.getFormatterLogger(IndexCreator.class);
public void create() { public void create() {
if (!EsConfig.IndexInitMode.manual.equals(EsConfig.Es.Index.Initialize.mode)) { if (!EsConfig.IndexInitMode.MANUAL.equals(EsConfig.Es.Index.Initialize.mode)) {
Set<AbstractIndex> indexSet = loadIndex(); Set<AbstractIndex> indexSet = loadIndex();
for (AbstractIndex index : indexSet) { for (AbstractIndex index : indexSet) {
boolean isExists = index.isExists(); boolean isExists = index.isExists();
if (isExists) { if (isExists) {
if (EsConfig.IndexInitMode.forced.equals(EsConfig.Es.Index.Initialize.mode)) { if (EsConfig.IndexInitMode.FORCED.equals(EsConfig.Es.Index.Initialize.mode)) {
index.deleteIndex(); index.deleteIndex();
index.createIndex(); index.createIndex();
} }
......
...@@ -65,7 +65,7 @@ public class IndexCreatorTestCase { ...@@ -65,7 +65,7 @@ public class IndexCreatorTestCase {
@Test @Test
public void testCreateOptionManual() throws Exception { public void testCreateOptionManual() throws Exception {
EsConfig.Es.Index.Initialize.mode = EsConfig.IndexInitMode.manual; EsConfig.Es.Index.Initialize.mode = EsConfig.IndexInitMode.MANUAL;
indexCreator.create(); indexCreator.create();
Mockito.verify(testIndex, Mockito.never()).createIndex(); Mockito.verify(testIndex, Mockito.never()).createIndex();
Mockito.verify(testIndex, Mockito.never()).deleteIndex(); Mockito.verify(testIndex, Mockito.never()).deleteIndex();
...@@ -73,7 +73,7 @@ public class IndexCreatorTestCase { ...@@ -73,7 +73,7 @@ public class IndexCreatorTestCase {
@Test @Test
public void testCreateOptionForcedIndexIsExists() throws Exception { public void testCreateOptionForcedIndexIsExists() throws Exception {
EsConfig.Es.Index.Initialize.mode = EsConfig.IndexInitMode.forced; EsConfig.Es.Index.Initialize.mode = EsConfig.IndexInitMode.FORCED;
when(testIndex.isExists()).thenReturn(true); when(testIndex.isExists()).thenReturn(true);
indexCreator.create(); indexCreator.create();
Mockito.verify(testIndex).createIndex(); Mockito.verify(testIndex).createIndex();
...@@ -82,7 +82,7 @@ public class IndexCreatorTestCase { ...@@ -82,7 +82,7 @@ public class IndexCreatorTestCase {
@Test @Test
public void testCreateOptionForcedIndexNotExists() throws Exception { public void testCreateOptionForcedIndexNotExists() throws Exception {
EsConfig.Es.Index.Initialize.mode = EsConfig.IndexInitMode.forced; EsConfig.Es.Index.Initialize.mode = EsConfig.IndexInitMode.FORCED;
when(testIndex.isExists()).thenReturn(false); when(testIndex.isExists()).thenReturn(false);
indexCreator.create(); indexCreator.create();
Mockito.verify(testIndex).createIndex(); Mockito.verify(testIndex).createIndex();
...@@ -91,7 +91,7 @@ public class IndexCreatorTestCase { ...@@ -91,7 +91,7 @@ public class IndexCreatorTestCase {
@Test @Test
public void testCreateOptionAutoIndexNotExists() throws Exception { public void testCreateOptionAutoIndexNotExists() throws Exception {
EsConfig.Es.Index.Initialize.mode = EsConfig.IndexInitMode.auto; EsConfig.Es.Index.Initialize.mode = EsConfig.IndexInitMode.AUTO;
when(testIndex.isExists()).thenReturn(false); when(testIndex.isExists()).thenReturn(false);
indexCreator.create(); indexCreator.create();
Mockito.verify(testIndex).createIndex(); Mockito.verify(testIndex).createIndex();
...@@ -100,7 +100,7 @@ public class IndexCreatorTestCase { ...@@ -100,7 +100,7 @@ public class IndexCreatorTestCase {
@Test @Test
public void testCreateOptionAutoIndexExists() throws Exception { public void testCreateOptionAutoIndexExists() throws Exception {
EsConfig.Es.Index.Initialize.mode = EsConfig.IndexInitMode.auto; EsConfig.Es.Index.Initialize.mode = EsConfig.IndexInitMode.AUTO;
when(testIndex.isExists()).thenReturn(true); when(testIndex.isExists()).thenReturn(true);
indexCreator.create(); indexCreator.create();
Mockito.verify(testIndex, Mockito.never()).createIndex(); Mockito.verify(testIndex, Mockito.never()).createIndex();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册