summaryrefslogtreecommitdiffstats
path: root/rulemgt/src/test/java/org/openo
diff options
context:
space:
mode:
authorGuangrong Fu <fu.guangrong@zte.com.cn>2017-08-07 12:30:35 +0800
committerGuangrong Fu <fu.guangrong@zte.com.cn>2017-08-07 12:41:11 +0800
commit20a1514bf93035472d4f940f00a357106d4bec1f (patch)
tree53c8e874f204f4b5ac7e64cbfdf783dbd2e9e019 /rulemgt/src/test/java/org/openo
parent40f54b8acefce59ecbd9e9fde60e062373243982 (diff)
Change the groupid from openo to onap
Change the groupid and package paths to onap. Change-Id: I8432e9ac2c979bbc36e10e6a702c6f04fc41446a Issue-ID: HOLMES-7 Signed-off-by: Guangrong Fu <fu.guangrong@zte.com.cn>
Diffstat (limited to 'rulemgt/src/test/java/org/openo')
-rw-r--r--rulemgt/src/test/java/org/openo/holmes/rulemgt/RuleActiveAppTest.java36
-rw-r--r--rulemgt/src/test/java/org/openo/holmes/rulemgt/RuleAppConfigTest.java59
-rw-r--r--rulemgt/src/test/java/org/openo/holmes/rulemgt/bean/request/CorrelationCheckRule4EngineTest.java32
-rw-r--r--rulemgt/src/test/java/org/openo/holmes/rulemgt/bean/request/CorrelationDeployRule4EngineTest.java40
-rw-r--r--rulemgt/src/test/java/org/openo/holmes/rulemgt/bean/request/CorrelationRestRequestTest.java34
-rw-r--r--rulemgt/src/test/java/org/openo/holmes/rulemgt/bean/request/RuleCreateRequestTest.java58
-rw-r--r--rulemgt/src/test/java/org/openo/holmes/rulemgt/bean/request/RuleDeleteRequestTest.java33
-rw-r--r--rulemgt/src/test/java/org/openo/holmes/rulemgt/bean/request/RuleQueryConditionTest.java65
-rw-r--r--rulemgt/src/test/java/org/openo/holmes/rulemgt/bean/request/RuleUpdateRequestTest.java58
-rw-r--r--rulemgt/src/test/java/org/openo/holmes/rulemgt/bean/response/RuleAddAndUpdateResponseTest.java32
-rw-r--r--rulemgt/src/test/java/org/openo/holmes/rulemgt/bean/response/RuleQueryListResponseTest.java45
-rw-r--r--rulemgt/src/test/java/org/openo/holmes/rulemgt/bean/response/RuleResult4APITest.java99
-rw-r--r--rulemgt/src/test/java/org/openo/holmes/rulemgt/bolt/enginebolt/EngineServiceTest.java56
-rw-r--r--rulemgt/src/test/java/org/openo/holmes/rulemgt/bolt/enginebolt/EngineWrapperTest.java184
-rw-r--r--rulemgt/src/test/java/org/openo/holmes/rulemgt/db/CorrelationRuleQueryDaoTest.java162
-rw-r--r--rulemgt/src/test/java/org/openo/holmes/rulemgt/db/mapper/CorrelationRuleMapperTest.java52
-rw-r--r--rulemgt/src/test/java/org/openo/holmes/rulemgt/resources/RuleMgtResourcesTest.java182
-rw-r--r--rulemgt/src/test/java/org/openo/holmes/rulemgt/wrapper/RuleMgtWrapperTest.java412
18 files changed, 0 insertions, 1639 deletions
diff --git a/rulemgt/src/test/java/org/openo/holmes/rulemgt/RuleActiveAppTest.java b/rulemgt/src/test/java/org/openo/holmes/rulemgt/RuleActiveAppTest.java
deleted file mode 100644
index 4f35b94..0000000
--- a/rulemgt/src/test/java/org/openo/holmes/rulemgt/RuleActiveAppTest.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- * Copyright 2017 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.holmes.rulemgt;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.core.IsEqual.equalTo;
-
-import org.junit.Test;
-
-public class RuleActiveAppTest {
-
- @Test
- public void getName() throws Exception {
- RuleActiveApp app = new RuleActiveApp();
- assertThat(app.getName(), equalTo("Holmes Rule Management ActiveApp APP "));
- }
-
- public static void main(String[] args) throws Exception {
- String filePath = "C:\\correlation-rule.yml";
- new RuleActiveApp().run(new String[]{"server", filePath});
- }
-} \ No newline at end of file
diff --git a/rulemgt/src/test/java/org/openo/holmes/rulemgt/RuleAppConfigTest.java b/rulemgt/src/test/java/org/openo/holmes/rulemgt/RuleAppConfigTest.java
deleted file mode 100644
index d14e55e..0000000
--- a/rulemgt/src/test/java/org/openo/holmes/rulemgt/RuleAppConfigTest.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/**
- * Copyright 2017 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.holmes.rulemgt;
-
-import static org.hamcrest.core.IsEqual.equalTo;
-import static org.hamcrest.core.IsNull.notNullValue;
-import static org.junit.Assert.assertThat;
-
-import io.dropwizard.db.DataSourceFactory;
-import org.junit.Before;
-import org.junit.Test;
-
-public class RuleAppConfigTest {
-
- private RuleAppConfig ruleAppConfig;
-
- @Before
- public void setUp() {
- ruleAppConfig = new RuleAppConfig();
- }
-
- @Test
- public void getDataSourceFactory() throws Exception {
- assertThat(ruleAppConfig.getDataSourceFactory(), notNullValue());
- }
-
- @Test
- public void setDataSourceFactory() throws Exception {
- final DataSourceFactory factory = new DataSourceFactory();
- ruleAppConfig.setDataSourceFactory(factory);
- assertThat(ruleAppConfig.getDataSourceFactory(), equalTo(factory));
- }
-
- @Test
- public void getApidescription() throws Exception {
- assertThat(ruleAppConfig.getApidescription(), equalTo("Holmes rule management rest API"));
- }
-
- @Test
- public void setApidescription() throws Exception {
- final String value = "desc";
- ruleAppConfig.setApidescription(value);
- assertThat(ruleAppConfig.getApidescription(), equalTo(value));
- }
-} \ No newline at end of file
diff --git a/rulemgt/src/test/java/org/openo/holmes/rulemgt/bean/request/CorrelationCheckRule4EngineTest.java b/rulemgt/src/test/java/org/openo/holmes/rulemgt/bean/request/CorrelationCheckRule4EngineTest.java
deleted file mode 100644
index 59e020c..0000000
--- a/rulemgt/src/test/java/org/openo/holmes/rulemgt/bean/request/CorrelationCheckRule4EngineTest.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/**
- * Copyright 2017 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.holmes.rulemgt.bean.request;
-
-import static org.hamcrest.core.IsEqual.equalTo;
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-
-public class CorrelationCheckRule4EngineTest {
- @Test
- public void getterAndSetter4Content(){
- final String value = "content";
- CorrelationCheckRule4Engine correlationCheckRule4Engine = new CorrelationCheckRule4Engine();
- correlationCheckRule4Engine.setContent(value);
- assertThat(correlationCheckRule4Engine.getContent(), equalTo(value));
- }
-} \ No newline at end of file
diff --git a/rulemgt/src/test/java/org/openo/holmes/rulemgt/bean/request/CorrelationDeployRule4EngineTest.java b/rulemgt/src/test/java/org/openo/holmes/rulemgt/bean/request/CorrelationDeployRule4EngineTest.java
deleted file mode 100644
index 8a9b8ec..0000000
--- a/rulemgt/src/test/java/org/openo/holmes/rulemgt/bean/request/CorrelationDeployRule4EngineTest.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * Copyright 2017 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.holmes.rulemgt.bean.request;
-
-import static org.junit.Assert.*;
-import static org.hamcrest.core.IsEqual.equalTo;
-
-import org.junit.Test;
-
-public class CorrelationDeployRule4EngineTest {
- @Test
- public void getterAndSetter4Content(){
- final String value = "content";
- CorrelationDeployRule4Engine correlationDeployRule4Engine = new CorrelationDeployRule4Engine();
- correlationDeployRule4Engine.setContent(value);
- assertThat(correlationDeployRule4Engine.getContent(), equalTo(value));
- }
-
- @Test
- public void getterAndSetter4EngineId(){
- final String value = "engineId";
- CorrelationDeployRule4Engine correlationDeployRule4Engine = new CorrelationDeployRule4Engine();
- correlationDeployRule4Engine.setEngineId(value);
- assertThat(correlationDeployRule4Engine.getEngineId(), equalTo(value));
- }
-} \ No newline at end of file
diff --git a/rulemgt/src/test/java/org/openo/holmes/rulemgt/bean/request/CorrelationRestRequestTest.java b/rulemgt/src/test/java/org/openo/holmes/rulemgt/bean/request/CorrelationRestRequestTest.java
deleted file mode 100644
index 5f3c5c1..0000000
--- a/rulemgt/src/test/java/org/openo/holmes/rulemgt/bean/request/CorrelationRestRequestTest.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * Copyright 2017 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package org.openo.holmes.rulemgt.bean.request;
-
-import static org.hamcrest.core.IsEqual.equalTo;
-import static org.junit.Assert.assertThat;
-
-import org.junit.Test;
-
-public class CorrelationRestRequestTest {
-
- @Test
- public void getterAndSetter4RootURL() {
- final String rootURL = "rootURL";
- CorrelationRestRequest correlationRestRequest = new CorrelationRestRequest();
- correlationRestRequest.setRootURL(rootURL);
- assertThat(correlationRestRequest.getRootURL(), equalTo(rootURL));
- }
-} \ No newline at end of file
diff --git a/rulemgt/src/test/java/org/openo/holmes/rulemgt/bean/request/RuleCreateRequestTest.java b/rulemgt/src/test/java/org/openo/holmes/rulemgt/bean/request/RuleCreateRequestTest.java
deleted file mode 100644
index 3f5469d..0000000
--- a/rulemgt/src/test/java/org/openo/holmes/rulemgt/bean/request/RuleCreateRequestTest.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/**
- * Copyright 2017 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.holmes.rulemgt.bean.request;
-
-import static org.hamcrest.core.Is.is;
-import static org.hamcrest.core.IsEqual.equalTo;
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-
-public class RuleCreateRequestTest {
-
- @Test
- public void getterAndSetter4RuleName(){
- final String rulename = "rulename";
- RuleCreateRequest ruleCreateRequest = new RuleCreateRequest();
- ruleCreateRequest.setRuleName(rulename);
- assertThat(ruleCreateRequest.getRuleName(), equalTo(rulename));
- }
-
- @Test
- public void getterAndSetter4Description(){
- final String description = "desc";
- RuleCreateRequest ruleCreateRequest = new RuleCreateRequest();
- ruleCreateRequest.setDescription(description);
- assertThat(ruleCreateRequest.getDescription(), equalTo(description));
- }
-
- @Test
- public void getterAndSetter4Content(){
- final String contents = "contents";
- RuleCreateRequest ruleCreateRequest = new RuleCreateRequest();
- ruleCreateRequest.setContent(contents);
- assertThat(ruleCreateRequest.getContent(), equalTo(contents));
- }
-
- @Test
- public void getterAndSetter4Enabled(){
- final int enabled = 0;
- RuleCreateRequest ruleCreateRequest = new RuleCreateRequest();
- ruleCreateRequest.setEnabled(enabled);
- assertThat(ruleCreateRequest.getEnabled(), is(enabled));
- }
-} \ No newline at end of file
diff --git a/rulemgt/src/test/java/org/openo/holmes/rulemgt/bean/request/RuleDeleteRequestTest.java b/rulemgt/src/test/java/org/openo/holmes/rulemgt/bean/request/RuleDeleteRequestTest.java
deleted file mode 100644
index f9a09ff..0000000
--- a/rulemgt/src/test/java/org/openo/holmes/rulemgt/bean/request/RuleDeleteRequestTest.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/**
- * Copyright 2017 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.holmes.rulemgt.bean.request;
-
-import static org.hamcrest.core.IsEqual.equalTo;
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-
-
-public class RuleDeleteRequestTest {
- @Test
- public void getterAndSetter4RuleId(){
- final String ruleId = "ruleId";
- RuleDeleteRequest ruleDeleteRequest = new RuleDeleteRequest();
- ruleDeleteRequest.setRuleId(ruleId);
- assertThat(ruleDeleteRequest.getRuleId(), equalTo(ruleId));
- }
-} \ No newline at end of file
diff --git a/rulemgt/src/test/java/org/openo/holmes/rulemgt/bean/request/RuleQueryConditionTest.java b/rulemgt/src/test/java/org/openo/holmes/rulemgt/bean/request/RuleQueryConditionTest.java
deleted file mode 100644
index 8bb5b8b..0000000
--- a/rulemgt/src/test/java/org/openo/holmes/rulemgt/bean/request/RuleQueryConditionTest.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/**
- * Copyright 2017 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.holmes.rulemgt.bean.request;
-
-import static org.hamcrest.core.Is.is;
-import static org.hamcrest.core.IsEqual.equalTo;
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-
-public class RuleQueryConditionTest {
- @Test
- public void getterAndSetter4RuleId(){
- final String value = "ruleId";
- RuleQueryCondition ruleQueryCondition = new RuleQueryCondition();
- ruleQueryCondition.setRid(value);
- assertThat(ruleQueryCondition.getRid(), equalTo(value));
- }
-
- @Test
- public void getterAndSetter4RuleName(){
- final String value = "ruleName";
- RuleQueryCondition ruleQueryCondition = new RuleQueryCondition();
- ruleQueryCondition.setName(value);
- assertThat(ruleQueryCondition.getName(), equalTo(value));
- }
-
- @Test
- public void getterAndSetter4Creator(){
- final String value = "admin";
- RuleQueryCondition ruleQueryCondition = new RuleQueryCondition();
- ruleQueryCondition.setCreator(value);
- assertThat(ruleQueryCondition.getCreator(), equalTo(value));
- }
-
- @Test
- public void getterAndSetter4Modifier(){
- final String value = "admin";
- RuleQueryCondition ruleQueryCondition = new RuleQueryCondition();
- ruleQueryCondition.setModifier(value);
- assertThat(ruleQueryCondition.getModifier(), equalTo(value));
- }
-
- @Test
- public void getterAndSetter4Enabled(){
- final int value = 0;
- RuleQueryCondition ruleQueryCondition = new RuleQueryCondition();
- ruleQueryCondition.setEnabled(value);
- assertThat(ruleQueryCondition.getEnabled(), is(value));
- }
-} \ No newline at end of file
diff --git a/rulemgt/src/test/java/org/openo/holmes/rulemgt/bean/request/RuleUpdateRequestTest.java b/rulemgt/src/test/java/org/openo/holmes/rulemgt/bean/request/RuleUpdateRequestTest.java
deleted file mode 100644
index 4cd4744..0000000
--- a/rulemgt/src/test/java/org/openo/holmes/rulemgt/bean/request/RuleUpdateRequestTest.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/**
- * Copyright 2017 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.holmes.rulemgt.bean.request;
-
-import static org.hamcrest.core.Is.is;
-import static org.hamcrest.core.IsEqual.equalTo;
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-
-
-public class RuleUpdateRequestTest {
- @Test
- public void getterAndSetter4RuleId(){
- final String value = "ruleId";
- RuleUpdateRequest ruleUpdateRequest = new RuleUpdateRequest();
- ruleUpdateRequest.setRuleId(value);
- assertThat(ruleUpdateRequest.getRuleId(), equalTo(value));
- }
-
- @Test
- public void getterAndSetter4Description(){
- final String value = "desc";
- RuleUpdateRequest ruleUpdateRequest = new RuleUpdateRequest();
- ruleUpdateRequest.setDescription(value);
- assertThat(ruleUpdateRequest.getDescription(), equalTo(value));
- }
-
- @Test
- public void getterAndSetter4Content(){
- final String value = "content";
- RuleUpdateRequest ruleUpdateRequest = new RuleUpdateRequest();
- ruleUpdateRequest.setContent(value);
- assertThat(ruleUpdateRequest.getContent(), equalTo(value));
- }
-
- @Test
- public void getterAndSetter4Enabled(){
- final int value = 0;
- RuleUpdateRequest ruleUpdateRequest = new RuleUpdateRequest();
- ruleUpdateRequest.setEnabled(value);
- assertThat(ruleUpdateRequest.getEnabled(), is(value));
- }
-} \ No newline at end of file
diff --git a/rulemgt/src/test/java/org/openo/holmes/rulemgt/bean/response/RuleAddAndUpdateResponseTest.java b/rulemgt/src/test/java/org/openo/holmes/rulemgt/bean/response/RuleAddAndUpdateResponseTest.java
deleted file mode 100644
index 82731d6..0000000
--- a/rulemgt/src/test/java/org/openo/holmes/rulemgt/bean/response/RuleAddAndUpdateResponseTest.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/**
- * Copyright 2017 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.holmes.rulemgt.bean.response;
-
-import static org.junit.Assert.*;
-import static org.hamcrest.core.IsEqual.equalTo;
-
-import org.junit.Test;
-
-public class RuleAddAndUpdateResponseTest {
- @Test
- public void getterAndSetter4RuleId(){
- final String value = "ruleId";
- RuleAddAndUpdateResponse ruleAddAndUpdateResponse = new RuleAddAndUpdateResponse();
- ruleAddAndUpdateResponse.setRuleId(value);
- assertThat(ruleAddAndUpdateResponse.getRuleId(), equalTo(value));
- }
-} \ No newline at end of file
diff --git a/rulemgt/src/test/java/org/openo/holmes/rulemgt/bean/response/RuleQueryListResponseTest.java b/rulemgt/src/test/java/org/openo/holmes/rulemgt/bean/response/RuleQueryListResponseTest.java
deleted file mode 100644
index c6e0a7e..0000000
--- a/rulemgt/src/test/java/org/openo/holmes/rulemgt/bean/response/RuleQueryListResponseTest.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- * Copyright 2017 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.holmes.rulemgt.bean.response;
-
-import static org.hamcrest.core.Is.is;
-import static org.hamcrest.core.IsEqual.equalTo;
-import static org.junit.Assert.assertThat;
-
-import java.util.ArrayList;
-import java.util.List;
-import org.junit.Test;
-
-public class RuleQueryListResponseTest {
-
- @Test
- public void getterAndSetter4CorrelationRules(){
- final List<RuleResult4API> value = new ArrayList<>();
- RuleQueryListResponse ruleQueryListResponse = new RuleQueryListResponse();
- ruleQueryListResponse.setCorrelationRules(value);
- assertThat(ruleQueryListResponse.getCorrelationRules(), equalTo(value));
- }
-
- @Test
- public void getterAndSetter4TotalCount(){
- final int value = 0;
- RuleQueryListResponse ruleQueryListResponse = new RuleQueryListResponse();
- ruleQueryListResponse.setTotalCount(value);
- assertThat(ruleQueryListResponse.getTotalCount(), is(value));
- }
-
-} \ No newline at end of file
diff --git a/rulemgt/src/test/java/org/openo/holmes/rulemgt/bean/response/RuleResult4APITest.java b/rulemgt/src/test/java/org/openo/holmes/rulemgt/bean/response/RuleResult4APITest.java
deleted file mode 100644
index 3af245e..0000000
--- a/rulemgt/src/test/java/org/openo/holmes/rulemgt/bean/response/RuleResult4APITest.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/**
- * Copyright 2017 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.holmes.rulemgt.bean.response;
-
-import static org.hamcrest.core.Is.is;
-import static org.hamcrest.core.IsEqual.equalTo;
-import static org.junit.Assert.*;
-
-import java.util.Date;
-import org.junit.Test;
-
-public class RuleResult4APITest {
-
- @Test
- public void getterAndSetter4RuleId(){
- final String value = "ruleId";
- RuleResult4API ruleResult4API = new RuleResult4API();
- ruleResult4API.setRuleId(value);
- assertThat(ruleResult4API.getRuleId(), equalTo(value));
- }
-
- @Test
- public void getterAndSetter4RuleName(){
- final String value = "ruleName";
- RuleResult4API ruleResult4API = new RuleResult4API();
- ruleResult4API.setRuleName(value);
- assertThat(ruleResult4API.getRuleName(), equalTo(value));
- }
-
- @Test
- public void getterAndSetter4Description(){
- final String value = "desc";
- RuleResult4API ruleResult4API = new RuleResult4API();
- ruleResult4API.setDescription(value);
- assertThat(ruleResult4API.getDescription(), equalTo(value));
- }
-
- @Test
- public void getterAndSetter4Content(){
- final String value = "content";
- RuleResult4API ruleResult4API = new RuleResult4API();
- ruleResult4API.setContent(value);
- assertThat(ruleResult4API.getContent(), equalTo(value));
- }
-
- @Test
- public void getterAndSetter4CreateTime(){
- final Date value = new Date();
- RuleResult4API ruleResult4API = new RuleResult4API();
- ruleResult4API.setCreateTime(value);
- assertThat(ruleResult4API.getCreateTime(), equalTo(value));
- }
-
- @Test
- public void getterAndSetter4Creator(){
- final String value = "admin";
- RuleResult4API ruleResult4API = new RuleResult4API();
- ruleResult4API.setCreator(value);
- assertThat(ruleResult4API.getCreator(), equalTo(value));
- }
-
- @Test
- public void getterAndSetter4UpdateTime(){
- final Date value = new Date();
- RuleResult4API ruleResult4API = new RuleResult4API();
- ruleResult4API.setUpdateTime(value);
- assertThat(ruleResult4API.getUpdateTime(), equalTo(value));
- }
-
- @Test
- public void getterAndSetter4Modifier(){
- final String value = "admin";
- RuleResult4API ruleResult4API = new RuleResult4API();
- ruleResult4API.setModifier(value);
- assertThat(ruleResult4API.getModifier(), equalTo(value));
- }
-
- @Test
- public void getterAndSetter4Enabled(){
- final int value = 0;
- RuleResult4API ruleResult4API = new RuleResult4API();
- ruleResult4API.setEnabled(value);
- assertThat(ruleResult4API.getEnabled(), is(value));
- }
-} \ No newline at end of file
diff --git a/rulemgt/src/test/java/org/openo/holmes/rulemgt/bolt/enginebolt/EngineServiceTest.java b/rulemgt/src/test/java/org/openo/holmes/rulemgt/bolt/enginebolt/EngineServiceTest.java
deleted file mode 100644
index f4275eb..0000000
--- a/rulemgt/src/test/java/org/openo/holmes/rulemgt/bolt/enginebolt/EngineServiceTest.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/**
- * Copyright 2017 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package org.openo.holmes.rulemgt.bolt.enginebolt;
-
-
-import org.apache.http.HttpResponse;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.rules.ExpectedException;
-import org.openo.holmes.rulemgt.bean.request.CorrelationDeployRule4Engine;
-import org.powermock.api.easymock.PowerMock;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.junit4.rule.PowerMockRule;
-
-@PrepareForTest({HttpClients.class, CloseableHttpClient.class})
-public class EngineServiceTest {
-
- @Rule
- public ExpectedException thrown = ExpectedException.none();
- @Rule
- public PowerMockRule powerMockRule = new PowerMockRule();
- private EngineService engineService;
- private HttpResponse httpResponseMock;
- private CloseableHttpClient closeableHttpClient;
- private CorrelationDeployRule4Engine correlationDeployRule4Engine;
- private CloseableHttpResponse closeableHttpResponseMock;
-
- @Before
- public void setUp() {
- engineService = new EngineService();
- closeableHttpClient = PowerMock.createMock(CloseableHttpClient.class);
- httpResponseMock = PowerMock.createMock(HttpResponse.class);
- closeableHttpResponseMock = PowerMock.createMock(CloseableHttpResponse.class);
- correlationDeployRule4Engine = new CorrelationDeployRule4Engine();
- correlationDeployRule4Engine.setContent("{\"package\":\"test\"}");
- correlationDeployRule4Engine.setEngineId("engine_id");
- }
-} \ No newline at end of file
diff --git a/rulemgt/src/test/java/org/openo/holmes/rulemgt/bolt/enginebolt/EngineWrapperTest.java b/rulemgt/src/test/java/org/openo/holmes/rulemgt/bolt/enginebolt/EngineWrapperTest.java
deleted file mode 100644
index 38afa47..0000000
--- a/rulemgt/src/test/java/org/openo/holmes/rulemgt/bolt/enginebolt/EngineWrapperTest.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/**
- * Copyright 2017 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.holmes.rulemgt.bolt.enginebolt;
-
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.equalTo;
-
-import javax.ws.rs.core.Response;
-import org.apache.http.StatusLine;
-import org.easymock.EasyMock;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.openo.holmes.common.exception.CorrelationException;
-import org.openo.holmes.common.utils.I18nProxy;
-import org.openo.holmes.rulemgt.bean.request.CorrelationCheckRule4Engine;
-import org.openo.holmes.rulemgt.bean.request.CorrelationDeployRule4Engine;
-import org.powermock.api.easymock.PowerMock;
-import org.powermock.reflect.Whitebox;
-
-public class EngineWrapperTest {
-
- @Rule
- public ExpectedException thrown = ExpectedException.none();
- private EngineWrapper engineWrapper = new EngineWrapper();
- private EngineService engineServiceMock;
- private Response response;
- private StatusLine statusLineMock;
-
- @Before
- public void setUp() throws Exception {
- engineServiceMock = PowerMock.createMock(EngineService.class);
- response = PowerMock.createMock(Response.class);
- statusLineMock = PowerMock.createMock(StatusLine.class);
- Whitebox.setInternalState(engineWrapper, "engineService", engineServiceMock);
- }
-
- @Test
- public void deployEngine_invoke_rule_deploy_exception() throws Exception {
- thrown.expect(CorrelationException.class);
- thrown.expectMessage(I18nProxy.RULE_MANAGEMENT_CALL_DEPLOY_RULE_REST_FAILED);
-
- EasyMock.expect(engineServiceMock.deploy(EasyMock.anyObject(CorrelationDeployRule4Engine.class))).andThrow(
- new RuntimeException(""));
- PowerMock.replayAll();
-
- engineWrapper.deployEngine(new CorrelationDeployRule4Engine());
-
- PowerMock.verifyAll();
- }
-
- @Test
- public void deployEngine_http_status_not_ok() throws Exception {
- thrown.expect(CorrelationException.class);
- thrown.expectMessage(I18nProxy.ENGINE_DEPLOY_RULE_FAILED);
-
- EasyMock.expect(engineServiceMock.deploy(EasyMock.anyObject(CorrelationDeployRule4Engine.class)))
- .andReturn(response);
- EasyMock.expect(response.getStatus()).andReturn(400);
- PowerMock.replayAll();
-
- engineWrapper.deployEngine(new CorrelationDeployRule4Engine());
-
- PowerMock.verifyAll();
- }
-
- @Test
- public void deployEngine_parse_content_exception() throws Exception {
- String content = "";
-
- thrown.expect(CorrelationException.class);
- thrown.expectMessage(I18nProxy.RULE_MANAGEMENT_PARSE_DEPLOY_RESULT_ERROR);
- EasyMock.expect(engineServiceMock.deploy(EasyMock.anyObject(CorrelationDeployRule4Engine.class)))
- .andReturn(response);
- EasyMock.expect(response.getStatus()).andReturn(200);
- EasyMock.expect(response.readEntity(String.class)).andReturn(content);
- PowerMock.replayAll();
-
- engineWrapper.deployEngine(new CorrelationDeployRule4Engine());
-
- PowerMock.verifyAll();
- }
-
- @Test
- public void deployEngine_success() throws Exception {
- String content = "{\"package\":\"test\"}";
- EasyMock.expect(engineServiceMock.deploy(EasyMock.anyObject(CorrelationDeployRule4Engine.class)))
- .andReturn(response);
- EasyMock.expect(response.getStatus()).andReturn(200);
- EasyMock.expect(response.readEntity(String.class)).andReturn(content);
- PowerMock.replayAll();
-
- String result = engineWrapper.deployEngine(new CorrelationDeployRule4Engine());
-
- assertThat(result, equalTo("test"));
-
- }
-
- @Test
- public void deleteRuleFromEngine_invoke_rule_delete_exception() throws Exception {
- thrown.expect(CorrelationException.class);
- thrown.expectMessage(I18nProxy.RULE_MANAGEMENT_CALL_DELETE_RULE_REST_FAILED);
-
- EasyMock.expect(engineServiceMock.delete(EasyMock.anyObject(String.class))).andThrow(
- new RuntimeException(""));
- PowerMock.replayAll();
-
- engineWrapper.deleteRuleFromEngine("");
-
- PowerMock.verifyAll();
- }
-
- @Test
- public void deleteRuleFromEngine_http_status_not_ok() throws Exception {
- thrown.expect(CorrelationException.class);
- thrown.expectMessage(I18nProxy.RULE_MANAGEMENT_DELETE_RULE_FAILED);
-
- EasyMock.expect(engineServiceMock.delete(EasyMock.anyObject(String.class)))
- .andReturn(response);
- EasyMock.expect(response.getStatus()).andReturn(400);
-
- PowerMock.replayAll();
-
- engineWrapper.deleteRuleFromEngine("");
-
- PowerMock.verifyAll();
- }
-
- @Test
- public void deleteRuleFromEngine_success() throws Exception {
- EasyMock.expect(engineServiceMock.delete(EasyMock.anyObject(String.class)))
- .andReturn(response);
- EasyMock.expect(response.getStatus()).andReturn(200);
-
- PowerMock.replayAll();
-
- boolean result = engineWrapper.deleteRuleFromEngine("");
-
- assertThat(result, equalTo(true));
- }
-
- @Test
- public void checkRuleFromEngine_rule_delete_exception() throws Exception {
- thrown.expect(CorrelationException.class);
- thrown.expectMessage(I18nProxy.RULE_MANAGEMENT_CALL_CHECK_RULE_REST_FAILED);
-
- EasyMock.expect(engineServiceMock.check(EasyMock.anyObject(CorrelationCheckRule4Engine.class))).andThrow(
- new RuntimeException(""));
- PowerMock.replayAll();
-
- engineWrapper.checkRuleFromEngine(new CorrelationCheckRule4Engine());
-
- PowerMock.verifyAll();
- }
-
- @Test
- public void checkRuleFromEngine_success() throws Exception {
- EasyMock.expect(engineServiceMock.check(EasyMock.anyObject(CorrelationCheckRule4Engine.class)))
- .andReturn(response);
- EasyMock.expect(response.getStatus()).andReturn(200);
-
- PowerMock.replayAll();
-
- boolean result = engineWrapper.checkRuleFromEngine(new CorrelationCheckRule4Engine());
-
- assertThat(result, equalTo(true));
- }
-} \ No newline at end of file
diff --git a/rulemgt/src/test/java/org/openo/holmes/rulemgt/db/CorrelationRuleQueryDaoTest.java b/rulemgt/src/test/java/org/openo/holmes/rulemgt/db/CorrelationRuleQueryDaoTest.java
deleted file mode 100644
index f241484..0000000
--- a/rulemgt/src/test/java/org/openo/holmes/rulemgt/db/CorrelationRuleQueryDaoTest.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/**
- * Copyright 2017 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.holmes.rulemgt.db;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import org.easymock.EasyMock;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.openo.holmes.common.api.entity.CorrelationRule;
-import org.openo.holmes.common.exception.CorrelationException;
-import org.openo.holmes.common.utils.DbDaoUtil;
-import org.openo.holmes.common.utils.I18nProxy;
-import org.openo.holmes.rulemgt.bean.request.RuleQueryCondition;
-import org.powermock.api.easymock.PowerMock;
-import org.powermock.modules.junit4.rule.PowerMockRule;
-import org.powermock.reflect.Whitebox;
-import org.skife.jdbi.v2.Handle;
-import org.skife.jdbi.v2.Query;
-
-
-public class CorrelationRuleQueryDaoTest {
-
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
- @Rule
- public PowerMockRule powerMockRule = new PowerMockRule();
- private DbDaoUtil dbDaoUtil;
-
- private Handle handle;
-
- private Query query;
-
- private CorrelationRuleQueryDao correlationRuleQueryDao;
- private RuleQueryCondition ruleQueryCondition;
-
- @Before
- public void setUp() throws Exception {
- correlationRuleQueryDao = new CorrelationRuleQueryDao();
-
- dbDaoUtil = PowerMock.createMock(DbDaoUtil.class);
- handle = PowerMock.createMock(Handle.class);
- query = PowerMock.createMock(Query.class);
-
- Whitebox.setInternalState(correlationRuleQueryDao, "dbDaoUtil", dbDaoUtil);
-
- ruleQueryCondition = createRuleQueryCondition();
- }
-
-
- @Test
- public void getCorrelationRulesByCondition_db_exception() throws Exception {
-
- thrown.expect(CorrelationException.class);
- thrown.expectMessage(I18nProxy.RULE_MANAGEMENT_QUERY_RULE_FAILED);
-
- EasyMock.expect(dbDaoUtil.getHandle()).andReturn(handle);
- EasyMock.expect(handle.createQuery(EasyMock.anyObject(String.class))).andReturn(query);
- EasyMock.expect(query.list()).andThrow(new RuntimeException()).anyTimes();
- dbDaoUtil.close(handle);
- EasyMock.expectLastCall();
-
- PowerMock.replayAll();
-
- correlationRuleQueryDao.getCorrelationRulesByCondition(ruleQueryCondition);
-
- PowerMock.verifyAll();
- }
-
- @Test
- public void getCorrelationRulesByCondition_normal() throws Exception {
- EasyMock.expect(dbDaoUtil.getHandle()).andReturn(handle);
- EasyMock.expect(handle.createQuery(EasyMock.anyObject(String.class))).andReturn(query);
- EasyMock.expect(query.list()).andReturn(createQueryResult()).anyTimes();
- dbDaoUtil.close(handle);
- EasyMock.expectLastCall();
-
- PowerMock.replayAll();
-
- List<CorrelationRule> result = correlationRuleQueryDao.getCorrelationRulesByCondition(ruleQueryCondition);
- assertThat(result.size(), is(1));
-
- PowerMock.verifyAll();
- }
-
- @Test
- public void getCorrelationRulesByCondition_get_where_sql_exception() throws Exception {
- thrown.expect(CorrelationException.class);
- thrown.expectMessage(I18nProxy.RULE_MANAGEMENT_CREATE_QUERY_SQL_FAILED);
-
- EasyMock.expect(dbDaoUtil.getHandle()).andReturn(handle);
- EasyMock.expect(handle.createQuery(EasyMock.anyObject(String.class))).andReturn(query);
- EasyMock.expect(query.list()).andReturn(createQueryResult()).anyTimes();
- dbDaoUtil.close(handle);
- EasyMock.expectLastCall();
-
- PowerMock.replayAll();
-
- correlationRuleQueryDao.getCorrelationRulesByCondition(null);
-
- PowerMock.verifyAll();
- }
-
- private List<Map<String, Object>> createQueryResult() {
- List<Map<String, Object>> list = new ArrayList<>();
- Map<String, Object> value = new HashMap<>();
- value.put("name", "Rule-001");
- value.put("rid", "rule_" + System.currentTimeMillis());
- value.put("description", "desc");
- value.put("enable", 0);
- value.put("templateID", 1);
- value.put("engineId", "engine-001");
- value.put("engineType", "engineType-001");
- value.put("creator", "admin");
- value.put("createTime", new Date());
- value.put("updator", "admin");
- value.put("updateTime", new Date());
- value.put("params", new Properties());
- value.put("domain", "Domain");
- value.put("isManual", 0);
- value.put("vendor", "Vendor");
- value.put("content", "Contents");
- value.put("package", "package");
- list.add(value);
- return list;
- }
-
- private RuleQueryCondition createRuleQueryCondition() {
- RuleQueryCondition ruleQueryCondition = new RuleQueryCondition();
- ruleQueryCondition.setRid("rule_" + System.currentTimeMillis());
- ruleQueryCondition.setName("Rule-001");
- ruleQueryCondition.setEnabled(0);
- ruleQueryCondition.setCreator("admin");
- ruleQueryCondition.setModifier("admin");
- return ruleQueryCondition;
- }
-
-}
diff --git a/rulemgt/src/test/java/org/openo/holmes/rulemgt/db/mapper/CorrelationRuleMapperTest.java b/rulemgt/src/test/java/org/openo/holmes/rulemgt/db/mapper/CorrelationRuleMapperTest.java
deleted file mode 100644
index 65a53dd..0000000
--- a/rulemgt/src/test/java/org/openo/holmes/rulemgt/db/mapper/CorrelationRuleMapperTest.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
- * Copyright 2017 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.holmes.rulemgt.db.mapper;
-
-import static org.easymock.EasyMock.expect;
-
-import java.sql.Date;
-import java.sql.ResultSet;
-import java.util.Properties;
-import org.junit.Test;
-import org.powermock.api.easymock.PowerMock;
-
-public class CorrelationRuleMapperTest {
-
- @Test
- public void map() throws Exception {
- CorrelationRuleMapper mapper = new CorrelationRuleMapper();
- ResultSet resultSet = PowerMock.createMock(ResultSet.class);
- expect(resultSet.getString("name")).andReturn("");
- expect(resultSet.getString("rid")).andReturn("");
- expect(resultSet.getString("description")).andReturn("");
- expect(resultSet.getInt("enable")).andReturn(0);
- expect(resultSet.getInt("templateID")).andReturn(1);
- expect(resultSet.getString("engineID")).andReturn("");
- expect(resultSet.getString("engineType")).andReturn("");
- expect(resultSet.getString("creator")).andReturn("");
- expect(resultSet.getDate("createTime")).andReturn(new Date(System.currentTimeMillis()));
- expect(resultSet.getString("updator")).andReturn("");
- expect(resultSet.getDate("updateTime")).andReturn(new Date(System.currentTimeMillis()));
- expect(resultSet.getObject("params")).andReturn(new Properties());
- expect(resultSet.getString("content")).andReturn("");
- expect(resultSet.getString("vendor")).andReturn("");
- expect(resultSet.getString("package")).andReturn("");
- PowerMock.replay(resultSet);
- mapper.map(0, resultSet, null);
- PowerMock.verify(resultSet);
- }
-} \ No newline at end of file
diff --git a/rulemgt/src/test/java/org/openo/holmes/rulemgt/resources/RuleMgtResourcesTest.java b/rulemgt/src/test/java/org/openo/holmes/rulemgt/resources/RuleMgtResourcesTest.java
deleted file mode 100644
index 16a547b..0000000
--- a/rulemgt/src/test/java/org/openo/holmes/rulemgt/resources/RuleMgtResourcesTest.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/**
- * Copyright 2017 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.holmes.rulemgt.resources;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.WebApplicationException;
-import org.easymock.EasyMock;
-import org.eclipse.jetty.server.Request;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.openo.holmes.common.exception.CorrelationException;
-import org.openo.holmes.rulemgt.bean.request.RuleCreateRequest;
-import org.openo.holmes.rulemgt.bean.request.RuleDeleteRequest;
-import org.openo.holmes.rulemgt.bean.request.RuleQueryCondition;
-import org.openo.holmes.rulemgt.bean.request.RuleUpdateRequest;
-import org.openo.holmes.rulemgt.bean.response.RuleAddAndUpdateResponse;
-import org.openo.holmes.rulemgt.bean.response.RuleQueryListResponse;
-import org.openo.holmes.rulemgt.wrapper.RuleMgtWrapper;
-import org.powermock.api.easymock.PowerMock;
-import org.powermock.reflect.Whitebox;
-
-public class RuleMgtResourcesTest {
-
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
- private HttpServletRequest request = PowerMock.createMock(HttpServletRequest.class);
-
- private RuleMgtWrapper ruleMgtWrapper = PowerMock.createMock(RuleMgtWrapper.class);
-
- private RuleMgtResources ruleMgtResources = new RuleMgtResources();
-
- private Request requestMock = PowerMock.createMock(Request.class);
-
- @Before
- public void setUp() throws Exception {
- Whitebox.setInternalState(ruleMgtResources, "ruleMgtWrapper", ruleMgtWrapper);
- PowerMock.resetAll();
- }
-
- @Test
- public void addCorrelationRule_correlation_exception() throws Exception {
- thrown.expect(WebApplicationException.class);
-
- final RuleCreateRequest ruleCreateRequest = new RuleCreateRequest();
- EasyMock.expect(ruleMgtWrapper.addCorrelationRule("admin", ruleCreateRequest))
- .andThrow(new CorrelationException(EasyMock.anyObject(String.class)));
- EasyMock.expect(request.getHeader("language-option")).andReturn("en_US");
- EasyMock.expect(request.getHeader("username")).andReturn("admin");
- PowerMock.replayAll();
- ruleMgtResources.addCorrelationRule(request, ruleCreateRequest);
- PowerMock.verifyAll();
- }
-
- @Test
- public void addCorrelationRule_normal() throws Exception {
- StringBuilder stringBuilder = new StringBuilder("http://localhost");
- final RuleCreateRequest ruleCreateRequest = new RuleCreateRequest();
- EasyMock.expect(ruleMgtWrapper.addCorrelationRule("admin",
- ruleCreateRequest)).andReturn(new RuleAddAndUpdateResponse());
- EasyMock.expect(request.getHeader("language-option")).andReturn("en_US");
- EasyMock.expect(request.getHeader("username")).andReturn("admin");
- PowerMock.replayAll();
- ruleMgtResources.addCorrelationRule(request, ruleCreateRequest);
- PowerMock.verifyAll();
- }
-
- @Test
- public void updateCorrelationRule_correlation_exception() throws Exception {
- thrown.expect(WebApplicationException.class);
-
- final RuleUpdateRequest ruleUpdateRequest = new RuleUpdateRequest();
- EasyMock.expect(ruleMgtWrapper.updateCorrelationRule("admin", ruleUpdateRequest))
- .andThrow(new CorrelationException(EasyMock.anyObject(String.class)));
- EasyMock.expect(request.getHeader("language-option")).andReturn("en_US");
- EasyMock.expect(request.getHeader("username")).andReturn("admin");
- PowerMock.replayAll();
- ruleMgtResources.updateCorrelationRule(request, ruleUpdateRequest);
- PowerMock.verifyAll();
- }
-
- @Test
- public void updateCorrelationRule_normal() throws Exception {
- final RuleUpdateRequest ruleUpdateRequest = new RuleUpdateRequest();
- EasyMock.expect(ruleMgtWrapper.updateCorrelationRule("admin",
- ruleUpdateRequest)).andReturn(new RuleAddAndUpdateResponse());
- EasyMock.expect(request.getHeader("language-option")).andReturn("en_US");
- EasyMock.expect(request.getHeader("username")).andReturn("admin");
- PowerMock.replayAll();
- ruleMgtResources.updateCorrelationRule(request, ruleUpdateRequest);
- PowerMock.verifyAll();
- }
-
- @Test
- public void deleteCorrelationRule_correlation_exception() throws Exception {
- thrown.expect(WebApplicationException.class);
-
- final RuleDeleteRequest ruleDeleteRequest = new RuleDeleteRequest();
- ruleMgtWrapper.deleteCorrelationRule(ruleDeleteRequest);
- EasyMock.expectLastCall().andThrow(new CorrelationException(EasyMock.anyObject(String.class)));
- EasyMock.expect(request.getHeader("language-option")).andReturn("en_US");
- PowerMock.replayAll();
- ruleMgtResources.deleteCorrelationRule(request, ruleDeleteRequest);
- PowerMock.verifyAll();
- }
-
- @Test
- public void deleteCorrelationRule_normal() throws Exception {
- final RuleDeleteRequest ruleDeleteRequest = new RuleDeleteRequest();
- ruleMgtWrapper.deleteCorrelationRule(ruleDeleteRequest);
- EasyMock.expectLastCall();
- EasyMock.expect(request.getHeader("language-option")).andReturn("en_US");
- PowerMock.replayAll();
- ruleMgtResources.deleteCorrelationRule(request, ruleDeleteRequest);
- PowerMock.verifyAll();
- }
-
- @Test
- public void getCorrelationRules_data_format_exception() throws Exception {
- thrown.expect(WebApplicationException.class);
-
- final String requestStr = "{\"ruleid\":\"rule_001\",\"rulename\":\"Rule-001\","
- + "\"enabled\":0,\"creator\":\"admin\"}";
- EasyMock.expect(ruleMgtWrapper.getCorrelationRuleByCondition(EasyMock.anyObject(RuleQueryCondition.class)))
- .andThrow(new CorrelationException(EasyMock.anyObject(String.class)));
- EasyMock.expect(request.getHeader("language-option")).andReturn("en_US").times(2);
- PowerMock.replayAll();
- ruleMgtResources.getCorrelationRules(request, requestStr);
- PowerMock.verifyAll();
- }
-
- @Test
- public void getCorrelationRules_param_translate_exception() {
- thrown.expect(WebApplicationException.class);
-
- String queryRequest = "this is error param";
- EasyMock.expect(request.getHeader("language-option")).andReturn("en_US").times(2);
-
- PowerMock.replayAll();
- ruleMgtResources.getCorrelationRules(request, queryRequest);
- PowerMock.verifyAll();
-
- }
-
- @Test
- public void getCorrelationRules_normal_request_string_null() throws Exception {
- EasyMock.expect(ruleMgtWrapper.getCorrelationRuleByCondition(EasyMock.anyObject(RuleQueryCondition.class)))
- .andReturn(new RuleQueryListResponse());
- EasyMock.expect(request.getHeader("language-option")).andReturn("en_US").times(2);
- PowerMock.replayAll();
- ruleMgtResources.getCorrelationRules(request, null);
- PowerMock.verifyAll();
- }
-
- @Test
- public void getCorrelationRules_normal_request_string_enabled_missing() throws Exception {
- final String requestStr = "{\"ruleid\":\"rule_001\",\"rulename\":\"Rule-001\","
- + "\"creator\":\"admin\"}";
- EasyMock.expect(ruleMgtWrapper.getCorrelationRuleByCondition(EasyMock.anyObject(RuleQueryCondition.class)))
- .andReturn(new RuleQueryListResponse());
- EasyMock.expect(request.getHeader("language-option")).andReturn("en_US").times(2);
- PowerMock.replayAll();
- ruleMgtResources.getCorrelationRules(request, requestStr);
- PowerMock.verifyAll();
- }
-} \ No newline at end of file
diff --git a/rulemgt/src/test/java/org/openo/holmes/rulemgt/wrapper/RuleMgtWrapperTest.java b/rulemgt/src/test/java/org/openo/holmes/rulemgt/wrapper/RuleMgtWrapperTest.java
deleted file mode 100644
index f6d0544..0000000
--- a/rulemgt/src/test/java/org/openo/holmes/rulemgt/wrapper/RuleMgtWrapperTest.java
+++ /dev/null
@@ -1,412 +0,0 @@
-/**
- * Copyright 2017 ZTE Corporation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.openo.holmes.rulemgt.wrapper;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.is;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import org.easymock.EasyMock;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.junit.runner.RunWith;
-import org.openo.holmes.common.api.entity.CorrelationRule;
-import org.openo.holmes.common.exception.CorrelationException;
-import org.openo.holmes.common.utils.DbDaoUtil;
-import org.openo.holmes.common.utils.I18nProxy;
-import org.openo.holmes.rulemgt.bean.request.CorrelationCheckRule4Engine;
-import org.openo.holmes.rulemgt.bean.request.CorrelationDeployRule4Engine;
-import org.openo.holmes.rulemgt.bean.request.RuleCreateRequest;
-import org.openo.holmes.rulemgt.bean.request.RuleDeleteRequest;
-import org.openo.holmes.rulemgt.bean.request.RuleQueryCondition;
-import org.openo.holmes.rulemgt.bean.request.RuleUpdateRequest;
-import org.openo.holmes.rulemgt.bean.response.RuleAddAndUpdateResponse;
-import org.openo.holmes.rulemgt.bean.response.RuleQueryListResponse;
-import org.openo.holmes.rulemgt.bolt.enginebolt.EngineWrapper;
-import org.openo.holmes.rulemgt.db.CorrelationRuleDao;
-import org.openo.holmes.rulemgt.db.CorrelationRuleQueryDao;
-import org.powermock.api.easymock.PowerMock;
-import org.powermock.modules.junit4.rule.PowerMockRule;
-import org.powermock.reflect.Whitebox;
-
-public class RuleMgtWrapperTest {
-
- @Rule
- public ExpectedException thrown = ExpectedException.none();
- @Rule
- public PowerMockRule powerMockRule = new PowerMockRule();
-
- private RuleMgtWrapper ruleMgtWrapper;
-
- private EngineWrapper engineWrapperMock;
-
- private DbDaoUtil dbDaoUtilMock;
-
- private CorrelationRuleQueryDao correlationRuleQueryDaoMock;
-
- private CorrelationRuleDao correlationRuleDaoMock;
-
- private static final String USER_NAME = "admin";
-
- @Before
- public void setUp() throws Exception {
-
- ruleMgtWrapper = new RuleMgtWrapper();
-
- engineWrapperMock = PowerMock.createMock(EngineWrapper.class);
- correlationRuleQueryDaoMock = PowerMock.createMock(CorrelationRuleQueryDao.class);
- dbDaoUtilMock = PowerMock.createMock(DbDaoUtil.class);
- correlationRuleDaoMock = PowerMock.createMock(CorrelationRuleDao.class);
-
- Whitebox.setInternalState(ruleMgtWrapper, "daoUtil", dbDaoUtilMock);
- Whitebox.setInternalState(ruleMgtWrapper, "correlationRuleQueryDao", correlationRuleQueryDaoMock);
- Whitebox.setInternalState(ruleMgtWrapper, "engineWarpper", engineWrapperMock);
- Whitebox.setInternalState(ruleMgtWrapper, "correlationRuleDao", correlationRuleDaoMock);
-
- PowerMock.resetAll();
- }
-
- @Test
- public void initDaoUtil_normal() {
- ruleMgtWrapper.initDaoUtil();
- }
-
- @Test
- public void addCorrelationRule_name_is_null() throws Exception {
- thrown.expect(CorrelationException.class);
- thrown.expectMessage(I18nProxy.RULE_MANAGEMENT_RULE_NAME_CANNOT_BE_EMPTY);
-
- ruleMgtWrapper.addCorrelationRule(USER_NAME, createRuleCreateRequest(null, "This is a rule for testing.",
- "Mocked contents.", 0));
- }
-
- @Test
- public void addCorrelationRule_request_null() throws Exception {
- thrown.expect(CorrelationException.class);
- thrown.expectMessage((I18nProxy.RULE_MANAGEMENT_REQUEST_OBJECT_IS_EMPTY));
-
- ruleMgtWrapper.addCorrelationRule(USER_NAME, null);
- }
-
- @Test
- public void addCorrelationRule_name_is_empty() throws Exception {
- thrown.expect(CorrelationException.class);
- thrown.expectMessage(I18nProxy.RULE_MANAGEMENT_RULE_NAME_CANNOT_BE_EMPTY);
-
- ruleMgtWrapper.addCorrelationRule("admin", createRuleCreateRequest("", "This is a rule for testing.",
- "Mocked contents.", 0));
- }
-
- @Test
- public void addCorrelationRule_content_is_empty() throws Exception {
- thrown.expect(CorrelationException.class);
- thrown.expectMessage(I18nProxy.RULE_MANAGEMENT_CONTENT_CANNOT_BE_EMPTY);
-
- ruleMgtWrapper.addCorrelationRule("admin", createRuleCreateRequest("test", "This is a rule for testing.",
- "", 0));
- }
-
- @Test
- public void addCorrelationRule_enabled_is_off_limit() throws Exception {
- thrown.expect(CorrelationException.class);
- thrown.expectMessage(I18nProxy.RULE_MANAGEMENT_PARAMETER_ENABLED_ERROR);
-
- ruleMgtWrapper.addCorrelationRule("admin", createRuleCreateRequest("test", "This is a rule for testing.",
- "Mocked contents.", 3));
- }
-
- @Test
- public void addCorrelationRule_duplicated_rule() throws Exception {
-
- final String ruleName = "Rule-001";
-
- RuleCreateRequest ruleCreateRequest = createRuleCreateRequest(ruleName, "This is a rule for testing.",
- "Mocked contents.", 0);
- CorrelationRule correlationRule = convertCreateRequest2CorrelationRule(ruleCreateRequest);
-
- thrown.expect(CorrelationException.class);
- thrown.expectMessage(I18nProxy.RULE_MANAGEMENT_REPEAT_RULE_NAME);
-
- EasyMock.expect(correlationRuleDaoMock.queryRuleByRuleName(ruleName)).andReturn(correlationRule);
- PowerMock.replayAll();
-
- ruleMgtWrapper.addCorrelationRule("admin", ruleCreateRequest);
-
- PowerMock.verifyAll();
- }
-
- @Test
- public void addCorrelationRule_normal() throws Exception {
- final String ruleName = "Rule-001";
-
- RuleCreateRequest ruleCreateRequest = createRuleCreateRequest(ruleName, "This is a rule for testing.",
- "Mocked contents.", 1);
-
- CorrelationRule correlationRuleRet = new CorrelationRule();
- correlationRuleRet.setRid("rule_" + System.currentTimeMillis());
-
- EasyMock.expect(correlationRuleDaoMock.queryRuleByRuleName(ruleName)).andReturn(null);
- EasyMock.expect(engineWrapperMock.checkRuleFromEngine(EasyMock.anyObject(CorrelationCheckRule4Engine.class)))
- .andReturn(true);
- EasyMock.expect(engineWrapperMock.deployEngine(EasyMock.anyObject(CorrelationDeployRule4Engine.class)))
- .andReturn("package-001");
- EasyMock.expect(correlationRuleDaoMock.saveRule(EasyMock.anyObject(CorrelationRule.class)))
- .andReturn(correlationRuleRet);
-
- PowerMock.replayAll();
-
- RuleAddAndUpdateResponse response = ruleMgtWrapper.addCorrelationRule("admin", ruleCreateRequest);
- assertThat(response.getRuleId(), equalTo(correlationRuleRet.getRid()));
-
- PowerMock.verifyAll();
- }
-
- @Test
- public void updateCorrelationRule_param_null() throws Exception {
- thrown.expect(CorrelationException.class);
- thrown.expectMessage(I18nProxy.RULE_MANAGEMENT_REQUEST_OBJECT_IS_EMPTY);
-
- ruleMgtWrapper.updateCorrelationRule(USER_NAME, null);
- }
-
- @Test
- public void updateCorrelationRule_normal() throws Exception {
- CorrelationRule oldCorrelationRule = new CorrelationRule();
- oldCorrelationRule.setRid("rule_1");
- oldCorrelationRule.setName("name");
- oldCorrelationRule.setDescription("des1");
- oldCorrelationRule.setContent("content");
- oldCorrelationRule.setPackageName("testName");
- oldCorrelationRule.setEnabled(1);
- RuleUpdateRequest ruleUpdateRequest = createRuleUpdateRequest("rule_1", "des2", "contetnt2", 1);
-
- EasyMock.expect(correlationRuleDaoMock.queryRuleByRid("rule_1")).andReturn(oldCorrelationRule);
- EasyMock.expect(engineWrapperMock.deleteRuleFromEngine("testName")).andReturn(true);
- correlationRuleDaoMock.updateRule(EasyMock.anyObject(CorrelationRule.class));
- EasyMock.expectLastCall();
- EasyMock.expect(engineWrapperMock.checkRuleFromEngine(EasyMock.anyObject(CorrelationCheckRule4Engine.class)))
- .andReturn(true);
- EasyMock.expect(engineWrapperMock.deployEngine(EasyMock.anyObject(CorrelationDeployRule4Engine.class)))
- .andReturn("packageName1");
- PowerMock.replayAll();
-
- ruleMgtWrapper.updateCorrelationRule(USER_NAME, ruleUpdateRequest);
-
- PowerMock.verifyAll();
-
- assertThat(oldCorrelationRule.getRid(), equalTo(ruleUpdateRequest.getRuleId()));
- }
-
- @Test
- public void updateCorrelationRule_param_no_change() throws Exception {
- CorrelationRule oldCorrelationRule = new CorrelationRule();
- oldCorrelationRule.setRid("rule_1");
- oldCorrelationRule.setName("name");
- oldCorrelationRule.setDescription("des1");
- oldCorrelationRule.setContent("content");
- oldCorrelationRule.setPackageName("testName");
- oldCorrelationRule.setEnabled(1);
- RuleUpdateRequest ruleUpdateRequest = createRuleUpdateRequest("rule_1", "des1", "content", 1);
-
- EasyMock.expect(correlationRuleDaoMock.queryRuleByRid("rule_1")).andReturn(oldCorrelationRule);
-
- PowerMock.replayAll();
-
- ruleMgtWrapper.updateCorrelationRule(USER_NAME, ruleUpdateRequest);
-
- PowerMock.verifyAll();
-
- assertThat(oldCorrelationRule.getRid(), equalTo(ruleUpdateRequest.getRuleId()));
- }
-
- @Test
- public void updateCorrelationRule_rule_not_exist() throws Exception {
- thrown.expect(CorrelationException.class);
- thrown.expectMessage(I18nProxy.RULE_MANAGEMENT_RULE_NOT_EXIST_DATABASE);
-
- EasyMock.expect(correlationRuleDaoMock.queryRuleByRid(EasyMock.anyObject(String.class))).andReturn(null);
-
- PowerMock.replayAll();
-
- ruleMgtWrapper.updateCorrelationRule(USER_NAME, new RuleUpdateRequest());
-
- PowerMock.verifyAll();
- }
-
- @Test
- public void deleteCorrelationRule_request_null() throws Exception {
- thrown.expect(CorrelationException.class);
- thrown.expectMessage((I18nProxy.RULE_MANAGEMENT_REQUEST_OBJECT_IS_EMPTY));
-
- ruleMgtWrapper.deleteCorrelationRule(null);
- }
-
- @Test
- public void deleteCorrelationRule_rule_not_exit() throws Exception {
- thrown.expect(CorrelationException.class);
- thrown.expectMessage((I18nProxy.RULE_MANAGEMENT_RULE_NOT_EXIST_DATABASE));
-
- RuleDeleteRequest ruleDeleteRequest = createRuleDeleteRequest("rule_" + System.currentTimeMillis());
-
- EasyMock.expect(dbDaoUtilMock.getJdbiDaoByOnDemand(CorrelationRuleDao.class)).andReturn(
- correlationRuleDaoMock).anyTimes();
- EasyMock.expect(correlationRuleDaoMock.queryRuleByRid(ruleDeleteRequest.getRuleId()))
- .andReturn(null);
-
- PowerMock.replayAll();
-
- ruleMgtWrapper.deleteCorrelationRule(ruleDeleteRequest);
-
- PowerMock.verifyAll();
- }
-
- @Test
- public void deleteCorrelationRule_normal() throws Exception {
- RuleDeleteRequest ruleDeleteRequest = createRuleDeleteRequest("rule_" + System.currentTimeMillis());
- CorrelationRule correlationRule = new CorrelationRule();
- correlationRule.setEnabled(1);
- EasyMock.expect(correlationRuleDaoMock.queryRuleByRid(ruleDeleteRequest.getRuleId()))
- .andReturn(correlationRule);
- EasyMock.expect(engineWrapperMock.deleteRuleFromEngine(EasyMock.anyObject(String.class))).andReturn(true);
- correlationRuleDaoMock.deleteRule(EasyMock.anyObject(CorrelationRule.class));
- EasyMock.expectLastCall();
- PowerMock.replayAll();
-
- ruleMgtWrapper.deleteCorrelationRule(ruleDeleteRequest);
-
- PowerMock.verifyAll();
- }
-
- @Test
- public void getCorrelationRuleByCondition_data_format_exception() throws Exception {
- thrown.expect(CorrelationException.class);
- thrown.expectMessage((I18nProxy.RULE_MANAGEMENT_CREATE_QUERY_SQL_FAILED));
-
- EasyMock.expect(correlationRuleQueryDaoMock.getCorrelationRulesByCondition(EasyMock.anyObject(
- RuleQueryCondition.class)))
- .andThrow(new CorrelationException(I18nProxy.RULE_MANAGEMENT_CREATE_QUERY_SQL_FAILED));
-
- PowerMock.replay(correlationRuleQueryDaoMock, CorrelationRuleQueryDao.class);
-
- ruleMgtWrapper.getCorrelationRuleByCondition(new RuleQueryCondition());
-
- PowerMock.verify(correlationRuleQueryDaoMock, CorrelationRuleQueryDao.class);
- }
-
- @Test
- public void getCorrelationRuleByCondition_db_exception() throws Exception {
- thrown.expect(CorrelationException.class);
- thrown.expectMessage((I18nProxy.RULE_MANAGEMENT_QUERY_RULE_FAILED));
-
- EasyMock.expect(correlationRuleQueryDaoMock.getCorrelationRulesByCondition(EasyMock.anyObject(
- RuleQueryCondition.class)))
- .andThrow(new CorrelationException(I18nProxy.RULE_MANAGEMENT_QUERY_RULE_FAILED));
-
- PowerMock.replay(correlationRuleQueryDaoMock, CorrelationRuleQueryDao.class);
-
- ruleMgtWrapper.getCorrelationRuleByCondition(new RuleQueryCondition());
-
- PowerMock.verify(correlationRuleQueryDaoMock, CorrelationRuleQueryDao.class);
- }
-
- @Test
- public void getCorrelationRuleByCondition_normal() throws Exception {
- List<CorrelationRule> correlationRuleList = new ArrayList<CorrelationRule>(10);
- for (int i = 0; i < 10; ++i) {
- CorrelationRule correlationRule = new CorrelationRule();
- correlationRule.setContent("content" + i);
- correlationRule.setName("name" + i);
- correlationRule.setRid("rule_" + i);
- correlationRule.setEngineType("engineType" + (i % 2 + 1));
- correlationRule.setEngineID("engineId" + i);
- correlationRule.setCreateTime(new Date());
- correlationRule.setCreator(USER_NAME);
- correlationRule.setDescription("description" + i);
- correlationRule.setPackageName("package" + i);
- correlationRuleList.add(correlationRule);
- }
-
- EasyMock.expect(correlationRuleQueryDaoMock.getCorrelationRulesByCondition(EasyMock.anyObject(
- RuleQueryCondition.class))).andReturn(correlationRuleList);
-
- PowerMock.replay(correlationRuleQueryDaoMock, CorrelationRuleQueryDao.class);
-
- RuleQueryListResponse response = ruleMgtWrapper.getCorrelationRuleByCondition(new RuleQueryCondition());
-
- PowerMock.verify(correlationRuleQueryDaoMock, CorrelationRuleQueryDao.class);
-
- assertThat(response.getTotalCount(), is(10));
-
- for (int i = 0; i < 10; ++i) {
- assertThat(response.getCorrelationRules().get(i).getRuleId(),
- equalTo(correlationRuleList.get(i).getRid()));
- }
- }
-
- private RuleCreateRequest createRuleCreateRequest(String ruleName, String description, String content,
- int enabled) {
- RuleCreateRequest rcr;
- rcr = new RuleCreateRequest();
- rcr.setRuleName(ruleName);
- rcr.setDescription(description);
- rcr.setContent(content);
- rcr.setEnabled(enabled);
- return rcr;
- }
-
- private RuleUpdateRequest createRuleUpdateRequest(String ruleId, String description, String content, int enabled) {
- RuleUpdateRequest ruleUpdateRequest = new RuleUpdateRequest();
- ruleUpdateRequest.setRuleId(ruleId);
- ruleUpdateRequest.setDescription(description);
- ruleUpdateRequest.setContent(content);
- ruleUpdateRequest.setEnabled(enabled);
- return ruleUpdateRequest;
- }
-
- private RuleDeleteRequest createRuleDeleteRequest(String ruleId) {
- RuleDeleteRequest ruleDeleteRequest = new RuleDeleteRequest();
- ruleDeleteRequest.setRuleId(ruleId);
- return ruleDeleteRequest;
- }
-
- private CorrelationRule convertCreateRequest2CorrelationRule(RuleCreateRequest ruleCreateRequest) {
- CorrelationRule correlationRule = new CorrelationRule();
- correlationRule.setContent(ruleCreateRequest.getContent());
- correlationRule.setDescription(ruleCreateRequest.getDescription());
- correlationRule.setName(ruleCreateRequest.getRuleName());
- correlationRule.setCreator(USER_NAME);
- correlationRule.setModifier(USER_NAME);
- correlationRule.setEnabled(ruleCreateRequest.getEnabled());
- return correlationRule;
- }
-
- private CorrelationRule convertUpdateRequest2CorrelationRule(RuleUpdateRequest ruleUpdateRequest) {
- CorrelationRule correlationRule = new CorrelationRule();
- correlationRule.setRid(ruleUpdateRequest.getRuleId());
- correlationRule.setContent(ruleUpdateRequest.getContent());
- correlationRule.setDescription(ruleUpdateRequest.getDescription());
- correlationRule.setEnabled(ruleUpdateRequest.getEnabled());
- correlationRule.setUpdateTime(new Date());
- correlationRule.setModifier(USER_NAME);
- return correlationRule;
- }
-} \ No newline at end of file