From: Congcong Peng Date: Wed, 28 Mar 2018 01:19:18 +0000 (+0800) Subject: Add service node entity class X-Git-Tag: 1.2.0~27 X-Git-Url: https://gerrit.onap.org/r/gitweb?p=holmes%2Fcommon.git;a=commitdiff_plain;h=refs%2Fchanges%2F37%2F39337%2F1 Add service node entity class Issue-ID: HOLMES-106 Change-Id: I02cdc6de4302a6168d0cd0c1bc15826720c8ad99 Signed-off-by: Congcong Peng --- diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/api/entity/CorrelationRule.java b/holmes-actions/src/main/java/org/onap/holmes/common/api/entity/CorrelationRule.java index 0343dfa..d7965c5 100644 --- a/holmes-actions/src/main/java/org/onap/holmes/common/api/entity/CorrelationRule.java +++ b/holmes-actions/src/main/java/org/onap/holmes/common/api/entity/CorrelationRule.java @@ -57,4 +57,6 @@ public class CorrelationRule { private String packageName; @SerializedName(value = "controlloopname") private String closedControlLoopName; + @SerializedName(value = "engineinstance") + private String engineInstance; } diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/api/entity/ServiceEntity.java b/holmes-actions/src/main/java/org/onap/holmes/common/api/entity/ServiceEntity.java new file mode 100644 index 0000000..0244f84 --- /dev/null +++ b/holmes-actions/src/main/java/org/onap/holmes/common/api/entity/ServiceEntity.java @@ -0,0 +1,51 @@ +/** + * 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.onap.holmes.common.api.entity; + + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class ServiceEntity { + + private String serviceName; + private String version; + private String url; + private String protocol; + private String visualRange; + private List nodes; + + private String lb_policy; + private String publish_port; + private String namespace; + private String network_plane_type; + private String host; + private String path; + private Boolean enable_ssl; + private List metadata; + private List labels; + private String status; + private Boolean is_manual; + + +} diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/api/entity/ServiceNode4Query.java b/holmes-actions/src/main/java/org/onap/holmes/common/api/entity/ServiceNode4Query.java new file mode 100644 index 0000000..205126d --- /dev/null +++ b/holmes-actions/src/main/java/org/onap/holmes/common/api/entity/ServiceNode4Query.java @@ -0,0 +1,35 @@ +/** + * 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.onap.holmes.common.api.entity; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class ServiceNode4Query { + + private String ip; + private String port; + private String checkType; + private String checkUrl; + private String ha_role; + private String nodeId; + private String status; + +} diff --git a/holmes-actions/src/main/java/org/onap/holmes/common/utils/CorrelationRuleMapper.java b/holmes-actions/src/main/java/org/onap/holmes/common/utils/CorrelationRuleMapper.java index aba5060..a0fbd93 100644 --- a/holmes-actions/src/main/java/org/onap/holmes/common/utils/CorrelationRuleMapper.java +++ b/holmes-actions/src/main/java/org/onap/holmes/common/utils/CorrelationRuleMapper.java @@ -44,6 +44,7 @@ public class CorrelationRuleMapper implements ResultSetMapper { correlationRule.setVendor(resultSet.getString("vendor")); correlationRule.setPackageName(resultSet.getString("package")); correlationRule.setClosedControlLoopName(resultSet.getString("ctrlloop")); + correlationRule.setEngineInstance((resultSet.getString("engineinstance"))); return correlationRule; } diff --git a/holmes-actions/src/test/java/org/onap/holmes/common/api/entity/CorrelationRuleTest.java b/holmes-actions/src/test/java/org/onap/holmes/common/api/entity/CorrelationRuleTest.java index e00f961..1a25a35 100644 --- a/holmes-actions/src/test/java/org/onap/holmes/common/api/entity/CorrelationRuleTest.java +++ b/holmes-actions/src/test/java/org/onap/holmes/common/api/entity/CorrelationRuleTest.java @@ -143,4 +143,11 @@ public class CorrelationRuleTest { correlationRule.setPackageName(packageName); assertThat(correlationRule.getPackageName(), equalTo(packageName)); } + + @Test + public void getterAndSetter4EngineInstance(){ + final String engineInstance = "engineInstance"; + correlationRule.setEngineInstance(engineInstance); + assertThat(correlationRule.getEngineInstance(), equalTo(engineInstance)); + } } diff --git a/holmes-actions/src/test/java/org/onap/holmes/common/api/entity/ServiceEntityTest.java b/holmes-actions/src/test/java/org/onap/holmes/common/api/entity/ServiceEntityTest.java new file mode 100644 index 0000000..7119f84 --- /dev/null +++ b/holmes-actions/src/test/java/org/onap/holmes/common/api/entity/ServiceEntityTest.java @@ -0,0 +1,162 @@ +/** + * 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.onap.holmes.common.api.entity; + + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import java.util.ArrayList; +import java.util.List; + +import static org.hamcrest.core.IsEqual.equalTo; +import static org.junit.Assert.assertThat; + +public class ServiceEntityTest { + private ServiceEntity serviceEntity; + + @Before + public void before() throws Exception{ + serviceEntity = new ServiceEntity(); + } + @After + public void after() throws Exception{}; + + @Test + public void getterAndSetter4ServiceName() throws Exception{ + final String serviceName = "serviceName"; + serviceEntity.setServiceName(serviceName); + assertThat(serviceEntity.getServiceName(), equalTo(serviceName)); + } + + @Test + public void getterAndSetter4Version() throws Exception{ + final String version = "version"; + serviceEntity.setVersion(version); + assertThat(serviceEntity.getVersion(), equalTo(version)); + } + + @Test + public void getterAndSetter4Url() throws Exception{ + final String url = "url"; + serviceEntity.setUrl(url); + assertThat(serviceEntity.getUrl(), equalTo(url)); + } + + @Test + public void getterAndSetter4Protocol() throws Exception{ + final String protocol = "protocol"; + serviceEntity.setProtocol(protocol); + assertThat(serviceEntity.getProtocol(), equalTo(protocol)); + } + + @Test + public void getterAndSetter4VisualRange() throws Exception{ + final String visualRange = "visualRange"; + serviceEntity.setVisualRange(visualRange); + assertThat(serviceEntity.getVisualRange(), equalTo(visualRange)); + } + + + + + @Test + public void getterAndSetter4Lb_policy() throws Exception{ + final String lb_policy = "lb_policy"; + serviceEntity.setLb_policy(lb_policy); + assertThat(serviceEntity.getLb_policy(), equalTo(lb_policy)); + } + + @Test + public void getterAndSetter4Publish_port() throws Exception{ + final String publish_port = "publish_port"; + serviceEntity.setPublish_port(publish_port); + assertThat(serviceEntity.getPublish_port(), equalTo(publish_port)); + } + + @Test + public void getterAndSetter4Namespace() throws Exception{ + final String namespace = "namespace"; + serviceEntity.setNamespace(namespace); + assertThat(serviceEntity.getNamespace(), equalTo(namespace)); + } + + @Test + public void getterAndSetter4Network_plane_type() throws Exception{ + final String network_plane_type = "network_plane_type"; + serviceEntity.setNetwork_plane_type(network_plane_type); + assertThat(serviceEntity.getNetwork_plane_type(), equalTo(network_plane_type)); + } + + @Test + public void getterAndSetter4Host() throws Exception{ + final String host = "host"; + serviceEntity.setHost(host); + assertThat(serviceEntity.getHost(), equalTo(host)); + } + + @Test + public void getterAndSetter4Path() throws Exception{ + final String path = "path"; + serviceEntity.setPath(path); + assertThat(serviceEntity.getPath(), equalTo(path)); + } + + @Test + public void getterAndSetterEnable_ssl() throws Exception{ + final Boolean enable_ssl = true; + serviceEntity.setEnable_ssl(enable_ssl); + assertThat(serviceEntity.getEnable_ssl(), equalTo(enable_ssl)); + } + + @Test + public void getterAndSetter4Metadata() throws Exception{ + final List metadata = new ArrayList(); + metadata.add("hello"); + serviceEntity.setMetadata(metadata); + assertThat(serviceEntity.getMetadata(), equalTo(metadata)); + } + + + @Test + public void getterAndSetter4Labels() throws Exception{ + final List lables = new ArrayList(); + lables.add("aha"); + serviceEntity.setLabels(lables); + assertThat(serviceEntity.getLabels(), equalTo(lables)); + } + + @Test + public void getterAndSetter4Status() throws Exception{ + final String status = "status"; + serviceEntity.setStatus(status); + assertThat(serviceEntity.getStatus(), equalTo(status)); + } + + + @Test + public void getterAndSetter4Is_manual() throws Exception{ + final Boolean status = true; + serviceEntity.setIs_manual(status); + assertThat(serviceEntity.getIs_manual(), equalTo(status)); + } + + + + +} diff --git a/holmes-actions/src/test/java/org/onap/holmes/common/api/entity/ServiceNode4QueryTest.java b/holmes-actions/src/test/java/org/onap/holmes/common/api/entity/ServiceNode4QueryTest.java new file mode 100644 index 0000000..03966c3 --- /dev/null +++ b/holmes-actions/src/test/java/org/onap/holmes/common/api/entity/ServiceNode4QueryTest.java @@ -0,0 +1,87 @@ +/** + * 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.onap.holmes.common.api.entity; + + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import static org.hamcrest.core.IsEqual.equalTo; +import static org.junit.Assert.assertThat; + +public class ServiceNode4QueryTest { + private ServiceNode4Query serviceNode4Query; + + @Before + public void before()throws Exception{ + serviceNode4Query = new ServiceNode4Query(); + } + @After + public void after()throws Exception{} + + @Test + public void getterAndSetter4Ip() throws Exception{ + final String ip = "ip"; + serviceNode4Query.setIp(ip); + assertThat(serviceNode4Query.getIp(), equalTo(ip)); + } + + @Test + public void getterAndSetter4Port() throws Exception{ + final String port = "port"; + serviceNode4Query.setPort(port); + assertThat(serviceNode4Query.getPort(), equalTo(port)); + } + + @Test + public void getterAndSetter4CheckType() throws Exception{ + final String checkType = "checkType"; + serviceNode4Query.setCheckType(checkType); + assertThat(serviceNode4Query.getCheckType(), equalTo(checkType)); + } + + @Test + public void getterAndSetter4checkUrl() throws Exception{ + final String checkUrl = "checkUrl"; + serviceNode4Query.setCheckUrl(checkUrl); + assertThat(serviceNode4Query.getCheckUrl(), equalTo(checkUrl)); + } + + @Test + public void getterAndSetter4hHa_role() throws Exception{ + final String ha_role = "ha_role"; + serviceNode4Query.setHa_role(ha_role); + assertThat(serviceNode4Query.getHa_role(), equalTo(ha_role)); + } + + @Test + public void getterAndSetter4NodeId() throws Exception{ + final String nodeId = "nodeId"; + serviceNode4Query.setNodeId(nodeId); + assertThat(serviceNode4Query.getNodeId(), equalTo(nodeId)); + } + + @Test + public void getterAndSetter4Status() throws Exception{ + final String status = "status"; + serviceNode4Query.setStatus(status); + assertThat(serviceNode4Query.getStatus(), equalTo(status)); + } + + +} diff --git a/holmes-actions/src/test/java/org/onap/holmes/common/utils/CorrelationRuleMapperTest.java b/holmes-actions/src/test/java/org/onap/holmes/common/utils/CorrelationRuleMapperTest.java index 7f9c246..c18c828 100644 --- a/holmes-actions/src/test/java/org/onap/holmes/common/utils/CorrelationRuleMapperTest.java +++ b/holmes-actions/src/test/java/org/onap/holmes/common/utils/CorrelationRuleMapperTest.java @@ -47,6 +47,7 @@ public class CorrelationRuleMapperTest { expect(resultSet.getString("vendor")).andReturn(""); expect(resultSet.getString("package")).andReturn(""); expect(resultSet.getString("ctrlloop")).andReturn(""); + expect(resultSet.getString("engineinstance")).andReturn(""); PowerMock.replay(resultSet); mapper.map(0, resultSet, null); PowerMock.verify(resultSet);