import org.onap.usecaseui.server.util.DmaapSubscriber;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.autoconfigure.data.jpa.JpaRepositoriesAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.web.client.RestTemplate;
@SpringBootApplication
+@EnableAutoConfiguration(exclude={JpaRepositoriesAutoConfiguration.class})
@ComponentScan(basePackages = "org.onap.usecaseui.server")
public class UsecaseuiServerApplication {
+++ /dev/null
-/*
- * Copyright (C) 2017 CMCC, Inc. and others. All rights reserved.
- *
- * 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.usecaseui.server.bo;
-
-import org.onap.usecaseui.server.bean.PerformanceHeader;
-import org.onap.usecaseui.server.bean.PerformanceInformation;
-import org.onap.usecaseui.server.util.Page;
-
-import java.io.Serializable;
-import java.util.List;
-
-public class PerformanceBo implements Serializable {
-
- private PerformanceHeader performanceHeader;
-
- private List<PerformanceInformation> performanceInformation;
-
-
- public PerformanceBo() {
- }
-
- public PerformanceBo(PerformanceHeader performanceHeader, List<PerformanceInformation> performanceInformation) {
- this.performanceHeader = performanceHeader;
- this.performanceInformation = performanceInformation;
- }
-
- public PerformanceHeader getPerformanceHeader() {
- return performanceHeader;
- }
-
- public void setPerformanceHeader(PerformanceHeader performanceHeader) {
- this.performanceHeader = performanceHeader;
- }
-
- public List<PerformanceInformation> getPerformanceInformation() {
- return performanceInformation;
- }
-
- public void setPerformanceInformation(List<PerformanceInformation> performanceInformation) {
- this.performanceInformation = performanceInformation;
- }
-}
\r
import org.springframework.beans.factory.annotation.Autowired;\r
import org.springframework.context.annotation.Bean;\r
-import org.springframework.orm.hibernate4.LocalSessionFactoryBean;\r
+import org.springframework.context.annotation.Configuration;\r
+import org.springframework.orm.hibernate5.LocalSessionFactoryBean;\r
import org.springframework.orm.jpa.JpaTransactionManager;\r
import org.springframework.transaction.PlatformTransactionManager;\r
\r
\r
-@org.springframework.context.annotation.Configuration\r
+@Configuration\r
public class HibernateConfiguration\r
{\r
@Autowired\r
}
}
- private List<String> getDMaaPData(String topic) {
+ public List<String> getDMaaPData(String topic) {
Client client = ClientBuilder.newClient(new ClientConfig());
WebTarget webTarget = client.target(url + "/" + topic + "/" + consumerGroup + "/" + consumer);
Response response = webTarget.queryParam("timeout", timeout).request().get();
return response.readEntity(List.class);
}
- private void initConfig() {
+ public void initConfig() {
InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("dmaap.properties");
Properties p = new Properties();
try {
}
}
- private void alarmProcess(Map<String, Object> eventMap) {
+ public void alarmProcess(Map<String, Object> eventMap) {
AlarmsHeader alarm_header = new AlarmsHeader();
alarm_header.setId(UuiCommonUtil.getUUID());
List<AlarmsInformation> alarm_informations = new ArrayList<>();
}
}
- private void performanceProcess(Map<String, Object> maps) {
+ public void performanceProcess(Map<String, Object> maps) {
PerformanceHeader performance_header = new PerformanceHeader();
performance_header.setId(UuiCommonUtil.getUUID());
List<PerformanceInformation> performance_informations = new ArrayList<>();
});
}
- private String getTime(String time){
+ public String getTime(String time){
String result=time;
if(time.length()>=13){
result=time.substring(0, 13);
}
public static RequestBody extractBody(HttpServletRequest request) throws IOException {
- ServletInputStream inStream = null;
- try {
- inStream = request.getInputStream();
- BufferedReader reader = new BufferedReader(new InputStreamReader(inStream));
- logger.info("The request body content is: "+IOUtils.read(reader));
- return RequestBody.create(MediaType.parse("application/json"), IOUtils.read(reader));
- }finally {
- if (inStream != null) {
- inStream.close();
- }
+ BufferedReader br = null;
+ StringBuilder sb = new StringBuilder("");
+ try {
+ br = request.getReader();
+ String str;
+ while ((str = br.readLine()) != null)
+ {
+ sb.append(str);
+ }
+ br.close();
+ logger.info("The request body content is: "+sb.toString());
+ return RequestBody.create(MediaType.parse("application/json"),sb.toString());
+ }catch(Exception e){
+ logger.info("RestfulServices occur exection,this content is: "+e.getMessage());
+ return RequestBody.create(MediaType.parse("application/json"),sb.toString());
+ }finally {
+ if (null != br) {
+ br.close();
+ }
+ }
}
- }
}
--- /dev/null
+/*
+ * Copyright (C) 2018 CMCC, Inc. and others. All rights reserved.
+ *
+ * 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.usecaseui.server.util;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.junit.Test;
+
+import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.databind.JsonMappingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
+public class DmaapSubscriberTest {
+
+ DmaapSubscriber dmaap = new DmaapSubscriber();
+ private String topic="events/unauthenticated.SEC_FAULT_OUTPUT";
+
+/* @Test
+ public void subscribeTest(){
+ dmaap.subscribe(topic);
+ }
+
+ @Test
+ public void getDMaaPDataTest(){
+ dmaap.getDMaaPData(topic);
+ }*/
+
+ @Test
+ public void initConfigTest(){
+ dmaap.initConfig();
+ }
+
+ @Test
+ public void alarmProcessTest() throws JsonParseException, JsonMappingException, IOException{
+ List<String> list = new ArrayList<>();
+ ObjectMapper objMapper = new ObjectMapper();
+ list.add("{\"event\":{\"commonEventHeader\":{\"sourceId\":\"vnf_test_3\",\"startEpochMicrosec\":1516784364869,\"eventId\":\"ab305d54-85b4-a31b-7db2-fb6b9e546015\",\"sequence\":0,\"domain\":\"fault\",\"lastEpochMicrosec\":1516784364869,\"eventName\":\"Fault_MultiCloud_VMFailureCleared\",\"sourceName\":\"vSBC\",\"priority\":\"High\",\"version\":3.0,\"reportingEntityName\":\"vnf_test_3_rname\"},\"faultFields\":{\"eventSeverity\":\"CRITICAL\",\"alarmCondition\":\"Guest_Os_Failure\",\"faultFieldsVersion\":2.0,\"specificProblem\":\"Fault_MultiCloud_VMFailure\",\"alarmInterfaceA\":\"aaaa\",\"alarmAdditionalInformation\":[{\"name\":\"objectType\",\"value\":\"VIM\"},{\"name\":\"eventTime\",\"value\":\"2017-10-31 09:51:15\"}],\"eventSourceType\":\"other\",\"vfStatus\":\"Active\"}}}");
+ Map<String, Object> eventMaps = (Map<String, Object>) objMapper.readValue(list.get(0), Map.class).get("event");
+ dmaap.alarmProcess(eventMaps);
+
+ }
+
+ @Test
+ public void performanceProcessTest() throws JsonParseException, JsonMappingException, IOException{
+ List<String> list = new ArrayList<>();
+ ObjectMapper objMapper = new ObjectMapper();
+ list.add("{\"VESversion\":\"v5\",\"event\":{\"commonEventHeader\":{\"startEpochMicrosec\":0,\"sourceId\":\"shentao_test_vnf5\",\"eventId\":\"uui_test_vnf5\",\"nfcNamingCode\":\"\",\"reportingEntityId\":\"uui_test_vnf5\",\"internalHeaderFields\":{\"collectorTimeStamp\":\"Thu, 03 22 2018 02:30:09 GMT\"},\"eventType\":\"applicationVnf\",\"priority\":\"Normal\",\"version\":1.1,\"reportingEntityName\":\"ZTE-CMBJ-BJ,SubNetwork=100001,ManagedElement=100040_40,MmeFunction=1,EpRpDynS6aMme=2\",\"sequence\":498594,\"domain\":\"measurementsForVfScaling\",\"lastEpochMicrosec\":10363234321004,\"eventName\":\"Mfvs_MMEEpRpDynS6aMme\",\"sourceName\":\"1101ZTHX1E6M2QI4FZVTOXU\",\"nfNamingCode\":\"\"},\"measurementsForVfScalingFields\":{\"measurementInterval\":15,\"measurementsForVfScalingVersion\":2.1,\"additionalMeasurements\":[{\"name\":\"MME\",\"arrayOfFields\":[{\"name\":\"MM.UpdateLocationAnsFail\",\"value\":\"0.1\"},{\"name\":\"MM.UpdateLocationAnsFail.1xxx\",\"value\":\"0.2\"},{\"name\":\"MM.UpdateLocationAnsFail.3xxx\",\"value\":\"0.3\"}]}]}}}");
+ Map<String, Object> eventMaps = (Map<String, Object>) objMapper.readValue(list.get(0), Map.class).get("event");
+ dmaap.performanceProcess(eventMaps);
+ }
+}