<artifactId>powermock-core</artifactId>
<version>1.6.6</version>
</dependency>
+ <dependency>
+ <groupId>org.projectlombok</groupId>
+ <artifactId>lombok</artifactId>
+ <version>1.16.8</version>
+ </dependency>
</dependencies>
<build>
<plugins>
package org.onap.sfc.entity;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import lombok.Data;
-import java.util.ArrayList;
import java.util.List;
@JsonIgnoreProperties(ignoreUnknown = true)
+@Data
public class MsbRegisterEntity {
private String serviceName;
private String version;
private String protocol;
private String visualRange;
private List<NodeEntity> nodes;
-
- public String getServiceName() {
- return serviceName;
- }
-
- public void setServiceName(String serviceName) {
- this.serviceName = serviceName;
- }
-
- public String getVersion() {
- return version;
- }
-
- public void setVersion(String version) {
- this.version = version;
- }
-
- public String getUrl() {
- return url;
- }
-
- public void setUrl(String url) {
- this.url = url;
- }
-
- public String getProtocol() {
- return protocol;
- }
-
- public void setProtocol(String protocol) {
- this.protocol = protocol;
- }
-
- public String getVisualRange() {
- return visualRange;
- }
-
- public void setVisualRange(String visualRange) {
- this.visualRange = visualRange;
- }
-
- public List<NodeEntity> getNodes() {
- return nodes;
- }
-
- public void setNodes(List<NodeEntity> nodes) {
- this.nodes = nodes;
- }
}
package org.onap.sfc.entity;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import lombok.Data;
@JsonIgnoreProperties(ignoreUnknown = true)
+@Data
public class NodeEntity {
private String ip;
private String port;
private String ttl;
-
- public String getIp() {
- return ip;
- }
-
- public void setIp(String ip) {
- this.ip = ip;
- }
-
- public String getPort() {
- return port;
- }
-
- public void setPort(String port) {
- this.port = port;
- }
-
- public String getTtl() {
- return ttl;
- }
-
- public void setTtl(String ttl) {
- this.ttl = ttl;
- }
}
*/
package org.onap.sfc.entity;
+import lombok.Data;
+
+@Data
public class Result {
private String id;
this.id = uuid;
}
- public String getId() {
- return id;
- }
-
- public void setId(String id) {
- this.id = id;
- }
-
}
package org.onap.sfc.entity;
+import lombok.Data;
+
+@Data
public class SdnControllerInfo {
String url;
String userName;
String password;
-
- public String getUrl() {
- return url;
- }
-
- public void setUrl(String url) {
- this.url = url;
- }
-
- public String getUserName() {
- return userName;
- }
-
- public void setUserName(String userName) {
- this.userName = userName;
- }
-
- public String getPassword() {
- return password;
- }
-
- public void setPassword(String password) {
- this.password = password;
- }
}
import com.google.gson.annotations.SerializedName;
+import lombok.Data;
+@Data
public class PortInfo {
private String encapsulation;
private String ip;
private String mac;
@SerializedName("port-name")
private String portName;
-
- public String getEncapsulation() {
- return encapsulation;
- }
-
-
- public String getPortName() {
- return portName;
- }
-
- public void setPortName(String portName) {
- this.portName = portName;
- }
-
- public void setEncapsulation(String encapsulation) {
- this.encapsulation = encapsulation;
- }
-
- public String getIp() {
- return ip;
- }
-
- public void setIp(String ip) {
- this.ip = ip;
- }
-
- public String getMac() {
- return mac;
- }
-
- public void setMac(String mac) {
- this.mac = mac;
- }
}
package org.onap.sfc.entity.portpair;
import com.google.gson.annotations.SerializedName;
+import lombok.Data;
+@Data
public class ServiceFunctionParameter {
@SerializedName("service-function-parameter")
private String serviceFunctionParamter;
@SerializedName("service-function-parameter-value")
private String getServiceFunctionParamterValue;
-
- public String getServiceFunctionParamter() {
- return serviceFunctionParamter;
- }
-
- public void setServiceFunctionParamter(String serviceFunctionParamter) {
- this.serviceFunctionParamter = serviceFunctionParamter;
- }
-
- public String getGetServiceFunctionParamterValue() {
- return getServiceFunctionParamterValue;
- }
-
- public void setGetServiceFunctionParamterValue(String getServiceFunctionParamterValue) {
- this.getServiceFunctionParamterValue = getServiceFunctionParamterValue;
- }
}
*/
package org.onap.sfc.resources;
+import lombok.Setter;
import org.onap.sfc.utils.SfcDriverUtil;
import org.onap.sfc.entity.MsbRegisterEntity;
import org.onap.sfc.service.ConfigInfo;
public class MsbServiceRegister implements Runnable {
private final Logger LOGGER = LoggerFactory.getLogger(MsbServiceRegister.class);
MsbRegisterEntity entity;
+
+ @Setter
+ private int sleepSeconds = 30000;
+
+ @Setter
+ private int retry = 20;
+
public MsbServiceRegister()
{
initInfo();
public void run() {
boolean flag = false;
int retryTimes=0;
- while (!flag && retryTimes<20)
+ while (!flag && retryTimes< retry)
{
try {
LOGGER.info("Register Msb start:");
} catch (Exception e) {
LOGGER.error("Register Msb failed",e);
//e.printStackTrace();
- threadSleep(30000);
+ threadSleep(sleepSeconds);
+ retryTimes++;
}
}
import org.junit.Ignore;
import org.junit.Test;
import org.onap.sfc.entity.MsbRegisterEntity;
+import org.onap.sfc.service.ConfigInfo;
import org.onap.sfc.utils.SfcDriverUtil;
public class TestMsbRegister {
@Test
public void test_registerMsb()
{
+ SfcDriverConfig sfcDriverConfig = new SfcDriverConfig();
+ sfcDriverConfig.setServiceIp("127.0.0.1");
+ ConfigInfo.setConfig(sfcDriverConfig);
MsbRegisterEntity entity = SfcDriverUtil.getMsbRegisterInfo();
assert entity.getUrl().equals("/api/ztesdncdriver/v1");
}
--- /dev/null
+package org.onap.sfc.entity;
+
+import org.junit.Test;
+
+/**
+ * Copyright 2018 ZTE Corporation.
+ * <p>
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.
+ */
+public class ResultTest {
+ @Test
+ public void getId() throws Exception {
+ String uuid = "123";
+ Result result = new Result(uuid);
+ assert result.getId().equals(uuid);
+ }
+
+}
\ No newline at end of file
--- /dev/null
+package org.onap.sfc.resources;
+
+import org.junit.Test;
+import org.onap.sfc.SfcDriverConfig;
+import org.onap.sfc.service.ConfigInfo;
+
+/**
+ * Copyright 2018 ZTE Corporation.
+ * <p>
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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.
+ */
+public class MsbServiceRegisterTest {
+ @Test
+ public void run() throws Exception {
+ SfcDriverConfig sfcDriverConfig = new SfcDriverConfig();
+ sfcDriverConfig.setServiceIp("127.0.0.1");
+ sfcDriverConfig.setMsbServiceUrl("http://127.0.0.0:21180/microservices");
+ ConfigInfo.setConfig(sfcDriverConfig);
+ MsbServiceRegister msbServiceRegister = new MsbServiceRegister();
+ msbServiceRegister.setSleepSeconds(1);
+ msbServiceRegister.setRetry(1);
+ msbServiceRegister.run();
+ }
+
+}
\ No newline at end of file