diff options
author | 2018-08-15 11:46:10 -0400 | |
---|---|---|
committer | 2018-08-16 11:09:15 -0400 | |
commit | 7a2c23b3ad83eab0eed5b990c70a1603447d5ee5 (patch) | |
tree | 24293333fd3cc566c1d77f9c9eedeb034dce9c6c /dcae-analytics/dcae-analytics-tca-model/src | |
parent | 9650bd18f6b88721628ebedac2575b44e1b0028e (diff) |
Standalone TCA with EELF Logger
Issue-ID: DCAEGEN2-633
Change-Id: I4da76b532021c0d6248455e7bd6e77f4614c35a7
Signed-off-by: Singla, Rajiv (rs153v) <rs153v@att.com>
Diffstat (limited to 'dcae-analytics/dcae-analytics-tca-model/src')
31 files changed, 1317 insertions, 0 deletions
diff --git a/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/TcaModel.java b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/TcaModel.java new file mode 100644 index 0000000..e4a1415 --- /dev/null +++ b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/TcaModel.java @@ -0,0 +1,30 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. 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. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.analytics.tca.model; + +import org.onap.dcae.analytics.model.AnalyticsModel; + +/** + * Marker interface for all TCA Models + * + * @author Rajiv Singla + */ +public interface TcaModel extends AnalyticsModel { +} diff --git a/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/facade/Aai.java b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/facade/Aai.java new file mode 100644 index 0000000..796587b --- /dev/null +++ b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/facade/Aai.java @@ -0,0 +1,40 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. 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. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.analytics.tca.model.facade; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +import org.onap.dcae.analytics.model.common.BaseDynamicPropertiesProvider; + +/** + * @author Rajiv Singla + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class Aai extends BaseDynamicPropertiesProvider implements TcaFacadeModel { + + private static final long serialVersionUID = 1L; + + private String genericVNFName; + + private String genericServerName; + +} diff --git a/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/facade/TcaAlert.java b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/facade/TcaAlert.java new file mode 100644 index 0000000..a6cc8e0 --- /dev/null +++ b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/facade/TcaAlert.java @@ -0,0 +1,49 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. 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. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.analytics.tca.model.facade; + +import lombok.Data; + +/** + * Alert message generated by TCA due to threshold violation + * + * @author Rajiv Singla + */ +@Data +public class TcaAlert implements TcaFacadeModel { + + private static final long serialVersionUID = 1L; + + private Aai aai; + private Long closedLoopAlarmEnd; + private Long closedLoopAlarmStart; + private String closedLoopControlName; + private String closedLoopEventClient; + private String closedLoopEventStatus; + private String from; + private String policyName; + private String policyScope; + private String policyVersion; + private String requestId; + private String target; + private String targetType; + private String version; + +} diff --git a/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/facade/TcaFacadeModel.java b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/facade/TcaFacadeModel.java new file mode 100644 index 0000000..321ee74 --- /dev/null +++ b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/facade/TcaFacadeModel.java @@ -0,0 +1,32 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. 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. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.analytics.tca.model.facade; + + +import org.onap.dcae.analytics.model.facade.AnalyticsFacadeModel; +import org.onap.dcae.analytics.tca.model.TcaModel; + +/** + * Marker Interface for all TCA Facade Models + * + * @author Rajiv Singla + */ +public interface TcaFacadeModel extends TcaModel, AnalyticsFacadeModel { +} diff --git a/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/policy/BaseTcaPolicyModel.java b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/policy/BaseTcaPolicyModel.java new file mode 100644 index 0000000..d000ae0 --- /dev/null +++ b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/policy/BaseTcaPolicyModel.java @@ -0,0 +1,35 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. 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. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.analytics.tca.model.policy; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +import org.onap.dcae.analytics.model.common.BaseDynamicPropertiesProvider; + +/** + * A Base TCA Policy Model which accumulates all dynamic properties in a dynamicProperties Map + * + * @author Rajiv Singla + */ +@Data +@EqualsAndHashCode(callSuper = true) +public abstract class BaseTcaPolicyModel extends BaseDynamicPropertiesProvider implements TcaPolicyModel { +} diff --git a/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/policy/ClosedLoopEventStatus.java b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/policy/ClosedLoopEventStatus.java new file mode 100644 index 0000000..a36b705 --- /dev/null +++ b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/policy/ClosedLoopEventStatus.java @@ -0,0 +1,34 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. 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. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.analytics.tca.model.policy; + + +/** + * TCA Policy Closed Loop Event Status + * + * @author Rajiv Singla + */ +public enum ClosedLoopEventStatus implements TcaPolicyModel { + + ONSET, + ABATED, + CONTINUE; + +} diff --git a/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/policy/ControlLoopSchemaType.java b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/policy/ControlLoopSchemaType.java new file mode 100644 index 0000000..914d88c --- /dev/null +++ b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/policy/ControlLoopSchemaType.java @@ -0,0 +1,31 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. 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. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.analytics.tca.model.policy; + + +/** + * Control Loop Schema Type + * + * @author Rajiv Singla + */ +public enum ControlLoopSchemaType implements TcaPolicyModel { + + VNF, VM; +} diff --git a/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/policy/Direction.java b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/policy/Direction.java new file mode 100644 index 0000000..2e3e5e6 --- /dev/null +++ b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/policy/Direction.java @@ -0,0 +1,73 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. 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. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.analytics.tca.model.policy; + +import java.math.BigDecimal; + +/** + * Enum for Threshold Direction + * + * @author Rajiv Singla + */ +public enum Direction implements TcaPolicyModel { + + EQUAL { + @Override + public Boolean operate(final BigDecimal value1, final BigDecimal value2) { + return value1.compareTo(value2) == 0; + } + }, + LESS { + @Override + public Boolean operate(final BigDecimal value1, final BigDecimal value2) { + return value1.compareTo(value2) < 0; + } + }, + LESS_OR_EQUAL { + @Override + public Boolean operate(final BigDecimal value1, final BigDecimal value2) { + return value1.compareTo(value2) <= 0; + } + }, + GREATER { + @Override + public Boolean operate(final BigDecimal value1, final BigDecimal value2) { + return value1.compareTo(value2) > 0; + } + }, + GREATER_OR_EQUAL { + @Override + public Boolean operate(final BigDecimal value1, final BigDecimal value2) { + return value1.compareTo(value2) >= 0; + } + }; + + /** + * Configure logic for a particular Direction + * + * @param value1 left operand for Direction operation + * @param value2 right operand for Direction operation + * + * @return result of operation for the direction logic + */ + public abstract Boolean operate(final BigDecimal value1, final BigDecimal value2); + + +} diff --git a/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/policy/MetricsPerEventName.java b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/policy/MetricsPerEventName.java new file mode 100644 index 0000000..024202a --- /dev/null +++ b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/policy/MetricsPerEventName.java @@ -0,0 +1,70 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. 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. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.analytics.tca.model.policy; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.List; + +/** + * TCA Metrics that need to applied to each Event Name + * + * @author Rajiv Singla + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class MetricsPerEventName extends BaseTcaPolicyModel { + + + private static final long serialVersionUID = 1L; + + /** + * Event Name to which TCA Policy needs to applied. + */ + private String eventName; + + /** + * Control Loop Schema Type + */ + private ControlLoopSchemaType controlLoopSchemaType; + + /** + * Policy Scope + */ + private String policyScope; + + /** + * Policy Name + */ + private String policyName; + + /** + * Policy Version + */ + private String policyVersion; + + /** + * Policy Thresholds + */ + private List<Threshold> thresholds; + + +} diff --git a/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/policy/TcaPolicy.java b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/policy/TcaPolicy.java new file mode 100644 index 0000000..0f453ef --- /dev/null +++ b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/policy/TcaPolicy.java @@ -0,0 +1,48 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. 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. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.analytics.tca.model.policy; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.List; + +/** + * TCA (Threshold Crossing Alert) Root + * + * @author Rajiv Singla + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class TcaPolicy extends BaseTcaPolicyModel { + + private static final long serialVersionUID = 1L; + + /** + * TCA Policy domain which is associated with TCA incoming CEF message domain + */ + private String domain; + + /** + * Contains TCA Policy metrics that needs to be applied to each Functional Role + */ + private List<MetricsPerEventName> metricsPerEventName; + +} diff --git a/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/policy/TcaPolicyModel.java b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/policy/TcaPolicyModel.java new file mode 100644 index 0000000..a6a2df1 --- /dev/null +++ b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/policy/TcaPolicyModel.java @@ -0,0 +1,34 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. 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. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.analytics.tca.model.policy; + + +import org.onap.dcae.analytics.model.policy.AnalyticsPolicyModel; +import org.onap.dcae.analytics.tca.model.TcaModel; + +/** + * Marker interface for all TCA Policy Models + * + * @author Rajiv Singla + */ +public interface TcaPolicyModel extends TcaModel, AnalyticsPolicyModel { + + +} diff --git a/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/policy/Threshold.java b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/policy/Threshold.java new file mode 100644 index 0000000..e3f7de0 --- /dev/null +++ b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/policy/Threshold.java @@ -0,0 +1,84 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. 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. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.analytics.tca.model.policy; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.math.BigDecimal; + +import org.onap.dcae.analytics.model.cef.EventSeverity; + +/** + * TCA Policy Threshold + * + * @author Rajiv Singla + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class Threshold extends BaseTcaPolicyModel { + + private static final long serialVersionUID = 1L; + + /** + * Closed Loop Control Name + */ + private String closedLoopControlName; + + + /** + * Closed Loop Event Status + */ + private ClosedLoopEventStatus closedLoopEventStatus; + + /** + * Threshold Version + */ + private String version; + + /** + * Path of the field inside Common Event Format which needs to be monitored by TCA App + * for threshold crossing + */ + private String fieldPath; + + /** + * Threshold Value + */ + private Long thresholdValue; + + /** + * Direction of threshold + */ + private Direction direction; + + /** + * Severity of Event based on CEF Convention + */ + private EventSeverity severity; + + + /** + * Actual Field value that caused the threshold violation. Note: Ignored for serialization / deserialization + */ + private BigDecimal actualFieldValue; + + +} diff --git a/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/restapi/TcaExecutionRequest.java b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/restapi/TcaExecutionRequest.java new file mode 100644 index 0000000..5da6985 --- /dev/null +++ b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/restapi/TcaExecutionRequest.java @@ -0,0 +1,42 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. 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. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.analytics.tca.model.restapi; + +import lombok.Data; + +import java.util.List; + +import org.onap.dcae.analytics.model.cef.EventListener; +import org.onap.dcae.analytics.tca.model.policy.TcaPolicy; + +/** + * @author Rajiv Singla + */ +@Data +public class TcaExecutionRequest implements TcaRestApiModel { + + private static final long serialVersionUID = 1L; + + private String requestId; + private String transactionId; + private TcaPolicy tcaPolicy; + private List<EventListener> eventListeners; + +} diff --git a/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/restapi/TcaExecutionResponse.java b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/restapi/TcaExecutionResponse.java new file mode 100644 index 0000000..e2995f6 --- /dev/null +++ b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/restapi/TcaExecutionResponse.java @@ -0,0 +1,40 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. 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. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.analytics.tca.model.restapi; + +import lombok.Data; + +import org.onap.dcae.analytics.tca.model.facade.TcaAlert; +import org.onap.dcae.analytics.tca.model.policy.MetricsPerEventName; + +/** + * @author Rajiv Singla + */ +@Data +public class TcaExecutionResponse implements TcaRestApiModel { + + private static final long serialVersionUID = 1L; + + private String requestId; + private String transactionId; + private MetricsPerEventName violatedMetricsPerEventName; + private TcaAlert tcaAlert; + +} diff --git a/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/restapi/TcaRestApiModel.java b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/restapi/TcaRestApiModel.java new file mode 100644 index 0000000..cdad2c8 --- /dev/null +++ b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/restapi/TcaRestApiModel.java @@ -0,0 +1,28 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. 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. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.analytics.tca.model.restapi; + +import org.onap.dcae.analytics.tca.model.TcaModel; + +/** + * @author Rajiv Singla + */ +public interface TcaRestApiModel extends TcaModel { +} diff --git a/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/TcaModelJsonConversion.java b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/TcaModelJsonConversion.java new file mode 100644 index 0000000..aaec970 --- /dev/null +++ b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/TcaModelJsonConversion.java @@ -0,0 +1,60 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. 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. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.analytics.tca.model.util.json; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; + +import java.util.Optional; +import java.util.function.Function; + +import org.onap.dcae.analytics.model.util.function.JsonToJavaObjectBiFunction; +import org.onap.dcae.analytics.tca.model.facade.TcaAlert; +import org.onap.dcae.analytics.tca.model.policy.TcaPolicy; + +/** + * @author Rajiv Singla + */ +public abstract class TcaModelJsonConversion { + + + public static final ObjectMapper TCA_OBJECT_MAPPER = new TcaObjectMapperSupplier().get(); + + // Type reference to convert tca policy string to tca policy object + private static final TypeReference<TcaPolicy> TCA_POLICY_TYPE_REF = new TypeReference<TcaPolicy>() { + }; + + // Type reference to convert tca alert string to tca alert + private static final TypeReference<TcaAlert> TCA_ALERT_TYPE_REF = new TypeReference<TcaAlert>() { + }; + + // Tca Policy JSON conversion function + public static final Function<String, Optional<TcaPolicy>> TCA_POLICY_JSON_FUNCTION = new + JsonToJavaObjectBiFunction<TcaPolicy>(TCA_OBJECT_MAPPER).curry(TCA_POLICY_TYPE_REF); + + // Tca Alert JSON conversion function + public static final Function<String, Optional<TcaAlert>> TCA_ALERT_JSON_FUNCTION = new + JsonToJavaObjectBiFunction<TcaAlert>(TCA_OBJECT_MAPPER).curry(TCA_ALERT_TYPE_REF); + + private TcaModelJsonConversion() { + // private constructor + } + +} diff --git a/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/TcaObjectMapperSupplier.java b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/TcaObjectMapperSupplier.java new file mode 100644 index 0000000..f17819e --- /dev/null +++ b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/TcaObjectMapperSupplier.java @@ -0,0 +1,38 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. 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. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.analytics.tca.model.util.json; + +import com.fasterxml.jackson.databind.ObjectMapper; + +import org.onap.dcae.analytics.model.util.json.BaseObjectMapperSupplier; +import org.onap.dcae.analytics.tca.model.util.json.module.TcaFacadeModelModule; +import org.onap.dcae.analytics.tca.model.util.json.module.TcaPolicyModule; + +/** + * @author Rajiv Singla + */ +public class TcaObjectMapperSupplier extends BaseObjectMapperSupplier { + + @Override + public void registerCustomModules(final ObjectMapper objectMapper) { + objectMapper.registerModule(new TcaFacadeModelModule()); + objectMapper.registerModule(new TcaPolicyModule()); + } +} diff --git a/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/mixin/facade/AaiMixin.java b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/mixin/facade/AaiMixin.java new file mode 100644 index 0000000..5eed3c0 --- /dev/null +++ b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/mixin/facade/AaiMixin.java @@ -0,0 +1,54 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. 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. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.analytics.tca.model.util.json.mixin.facade; + +import com.fasterxml.jackson.annotation.JsonGetter; +import com.fasterxml.jackson.annotation.JsonSetter; + +import org.onap.dcae.analytics.model.util.json.mixin.common.BaseDynamicPropertiesProviderMixin; + +/** + * @author Rajiv Singla + */ +public abstract class AaiMixin extends BaseDynamicPropertiesProviderMixin { + + private String genericVNFName; + private String genericServerName; + + @JsonGetter("generic-vnf.vnf-name") + public String getGenericVNFName() { + return genericVNFName; + } + + @JsonSetter("generic-vnf.vnf-name") + public void setGenericVNFName(String genericVNFName) { + this.genericVNFName = genericVNFName; + } + + @JsonGetter("vserver.vserver-name") + public String getGenericServerName() { + return genericServerName; + } + + @JsonSetter("vserver.vserver-name") + public void setGenericServerName(String genericServerName) { + this.genericServerName = genericServerName; + } +} diff --git a/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/mixin/facade/TcaAlertMixin.java b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/mixin/facade/TcaAlertMixin.java new file mode 100644 index 0000000..6841e02 --- /dev/null +++ b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/mixin/facade/TcaAlertMixin.java @@ -0,0 +1,40 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. 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. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.analytics.tca.model.util.json.mixin.facade; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import org.onap.dcae.analytics.model.util.json.mixin.JsonMixin; +import org.onap.dcae.analytics.tca.model.facade.Aai; + + +/** + * @author Rajiv Singla + */ +public abstract class TcaAlertMixin implements JsonMixin { + + @JsonProperty("target_type") + private String targetType; + @JsonProperty("AAI") + private Aai aai; + @JsonProperty("requestID") + private String requestId; + +} diff --git a/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/mixin/policy/BaseTcaPolicyModelMixin.java b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/mixin/policy/BaseTcaPolicyModelMixin.java new file mode 100644 index 0000000..8ab1180 --- /dev/null +++ b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/mixin/policy/BaseTcaPolicyModelMixin.java @@ -0,0 +1,29 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. 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. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.analytics.tca.model.util.json.mixin.policy; + + +import org.onap.dcae.analytics.model.util.json.mixin.common.BaseDynamicPropertiesProviderMixin; + +/** + * @author Rajiv Singla + */ +public abstract class BaseTcaPolicyModelMixin extends BaseDynamicPropertiesProviderMixin { +} diff --git a/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/mixin/policy/ClosedLoopEventStatusMixin.java b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/mixin/policy/ClosedLoopEventStatusMixin.java new file mode 100644 index 0000000..3eb2ffa --- /dev/null +++ b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/mixin/policy/ClosedLoopEventStatusMixin.java @@ -0,0 +1,29 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. 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. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.analytics.tca.model.util.json.mixin.policy; + + +import org.onap.dcae.analytics.model.util.json.mixin.JsonMixin; + +/** + * @author Rajiv Singla + */ +public abstract class ClosedLoopEventStatusMixin implements JsonMixin { +} diff --git a/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/mixin/policy/ControlLoopSchemaTypeMixin.java b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/mixin/policy/ControlLoopSchemaTypeMixin.java new file mode 100644 index 0000000..895629f --- /dev/null +++ b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/mixin/policy/ControlLoopSchemaTypeMixin.java @@ -0,0 +1,28 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. 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. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.analytics.tca.model.util.json.mixin.policy; + +import org.onap.dcae.analytics.model.util.json.mixin.JsonMixin; + +/** + * @author Rajiv Singla + */ +public abstract class ControlLoopSchemaTypeMixin implements JsonMixin { +} diff --git a/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/mixin/policy/DirectionMixin.java b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/mixin/policy/DirectionMixin.java new file mode 100644 index 0000000..34891ea --- /dev/null +++ b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/mixin/policy/DirectionMixin.java @@ -0,0 +1,28 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. 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. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.analytics.tca.model.util.json.mixin.policy; + +import org.onap.dcae.analytics.model.util.json.mixin.JsonMixin; + +/** + * @author Rajiv Singla + */ +public abstract class DirectionMixin implements JsonMixin { +} diff --git a/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/mixin/policy/MetricsPerEventNameMixin.java b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/mixin/policy/MetricsPerEventNameMixin.java new file mode 100644 index 0000000..5a41bfe --- /dev/null +++ b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/mixin/policy/MetricsPerEventNameMixin.java @@ -0,0 +1,26 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. 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. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.analytics.tca.model.util.json.mixin.policy; + +/** + * @author Rajiv Singla + */ +public abstract class MetricsPerEventNameMixin extends BaseTcaPolicyModelMixin { +} diff --git a/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/mixin/policy/TcaPolicyMixin.java b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/mixin/policy/TcaPolicyMixin.java new file mode 100644 index 0000000..aa0561e --- /dev/null +++ b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/mixin/policy/TcaPolicyMixin.java @@ -0,0 +1,27 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. 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. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.analytics.tca.model.util.json.mixin.policy; + +/** + * @author Rajiv Singla + */ +public abstract class TcaPolicyMixin extends BaseTcaPolicyModelMixin { + +} diff --git a/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/mixin/policy/ThresholdMixin.java b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/mixin/policy/ThresholdMixin.java new file mode 100644 index 0000000..f0cab59 --- /dev/null +++ b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/mixin/policy/ThresholdMixin.java @@ -0,0 +1,44 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. 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. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.analytics.tca.model.util.json.mixin.policy; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.math.BigDecimal; + +/** + * @author Rajiv Singla + */ +public abstract class ThresholdMixin extends BaseTcaPolicyModelMixin { + + @JsonIgnore + private BigDecimal actualFieldValue; + + @JsonIgnore + public BigDecimal getActualFieldValue() { + return actualFieldValue; + } + + @JsonProperty + public void setActualFieldValue(BigDecimal actualFieldValue) { + this.actualFieldValue = actualFieldValue; + } +} diff --git a/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/module/TcaFacadeModelModule.java b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/module/TcaFacadeModelModule.java new file mode 100644 index 0000000..7da75ce --- /dev/null +++ b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/module/TcaFacadeModelModule.java @@ -0,0 +1,43 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. 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. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.analytics.tca.model.util.json.module; + +import com.fasterxml.jackson.databind.module.SimpleModule; + +import org.onap.dcae.analytics.tca.model.facade.Aai; +import org.onap.dcae.analytics.tca.model.facade.TcaAlert; +import org.onap.dcae.analytics.tca.model.util.json.mixin.facade.AaiMixin; +import org.onap.dcae.analytics.tca.model.util.json.mixin.facade.TcaAlertMixin; + + +/** + * @author Rajiv Singla + */ +public class TcaFacadeModelModule extends SimpleModule { + + private static final long serialVersionUID = 1L; + + @Override + public void setupModule(final SetupContext setupContext) { + setupContext.setMixInAnnotations(TcaAlert.class, TcaAlertMixin.class); + setupContext.setMixInAnnotations(Aai.class, AaiMixin.class); + } + +} diff --git a/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/module/TcaPolicyModule.java b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/module/TcaPolicyModule.java new file mode 100644 index 0000000..33af18b --- /dev/null +++ b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/module/TcaPolicyModule.java @@ -0,0 +1,59 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. 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. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.analytics.tca.model.util.json.module; + +import com.fasterxml.jackson.databind.module.SimpleModule; + +import org.onap.dcae.analytics.tca.model.policy.BaseTcaPolicyModel; +import org.onap.dcae.analytics.tca.model.policy.ClosedLoopEventStatus; +import org.onap.dcae.analytics.tca.model.policy.ControlLoopSchemaType; +import org.onap.dcae.analytics.tca.model.policy.Direction; +import org.onap.dcae.analytics.tca.model.policy.MetricsPerEventName; +import org.onap.dcae.analytics.tca.model.policy.TcaPolicy; +import org.onap.dcae.analytics.tca.model.policy.Threshold; +import org.onap.dcae.analytics.tca.model.util.json.mixin.policy.BaseTcaPolicyModelMixin; +import org.onap.dcae.analytics.tca.model.util.json.mixin.policy.ClosedLoopEventStatusMixin; +import org.onap.dcae.analytics.tca.model.util.json.mixin.policy.ControlLoopSchemaTypeMixin; +import org.onap.dcae.analytics.tca.model.util.json.mixin.policy.DirectionMixin; +import org.onap.dcae.analytics.tca.model.util.json.mixin.policy.MetricsPerEventNameMixin; +import org.onap.dcae.analytics.tca.model.util.json.mixin.policy.TcaPolicyMixin; +import org.onap.dcae.analytics.tca.model.util.json.mixin.policy.ThresholdMixin; + + +/** + * @author Rajiv Singla + */ +public class TcaPolicyModule extends SimpleModule { + + private static final long serialVersionUID = 1L; + + + @Override + public void setupModule(final SetupContext setupContext) { + setupContext.setMixInAnnotations(BaseTcaPolicyModel.class, BaseTcaPolicyModelMixin.class); + setupContext.setMixInAnnotations(TcaPolicy.class, TcaPolicyMixin.class); + setupContext.setMixInAnnotations(ControlLoopSchemaType.class, ControlLoopSchemaTypeMixin.class); + setupContext.setMixInAnnotations(ClosedLoopEventStatus.class, ClosedLoopEventStatusMixin.class); + setupContext.setMixInAnnotations(MetricsPerEventName.class, MetricsPerEventNameMixin.class); + setupContext.setMixInAnnotations(Direction.class, DirectionMixin.class); + setupContext.setMixInAnnotations(Threshold.class, ThresholdMixin.class); + setupContext.setMixInAnnotations(TcaPolicy.class, TcaPolicyMixin.class); + } +} diff --git a/dcae-analytics/dcae-analytics-tca-model/src/test/java/org/onap/dcae/analytics/tca/model/BaseTcaModelTest.java b/dcae-analytics/dcae-analytics-tca-model/src/test/java/org/onap/dcae/analytics/tca/model/BaseTcaModelTest.java new file mode 100644 index 0000000..3d5add2 --- /dev/null +++ b/dcae-analytics/dcae-analytics-tca-model/src/test/java/org/onap/dcae/analytics/tca/model/BaseTcaModelTest.java @@ -0,0 +1,30 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. 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. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.analytics.tca.model; + +import org.onap.dcae.analytics.test.BaseAnalyticsUnitTest; + +/** + * @author Rajiv Singla + */ +public abstract class BaseTcaModelTest extends BaseAnalyticsUnitTest { + + +} diff --git a/dcae-analytics/dcae-analytics-tca-model/src/test/java/org/onap/dcae/analytics/tca/model/util/json/mixin/facade/TcaAlertMixinTest.java b/dcae-analytics/dcae-analytics-tca-model/src/test/java/org/onap/dcae/analytics/tca/model/util/json/mixin/facade/TcaAlertMixinTest.java new file mode 100644 index 0000000..a0ebc05 --- /dev/null +++ b/dcae-analytics/dcae-analytics-tca-model/src/test/java/org/onap/dcae/analytics/tca/model/util/json/mixin/facade/TcaAlertMixinTest.java @@ -0,0 +1,58 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. 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. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.analytics.tca.model.util.json.mixin.facade; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.onap.dcae.analytics.tca.model.BaseTcaModelTest; +import org.onap.dcae.analytics.tca.model.facade.TcaAlert; +import org.onap.dcae.analytics.tca.model.util.json.TcaModelJsonConversion; + +/** + * @author Rajiv Singla + */ +public class TcaAlertMixinTest extends BaseTcaModelTest { + + @Test + @DisplayName("Confirms TCA Alert JSON Conversions") + public void testTCAAlertConversion() throws Exception { + final TcaAlert tcaAlert = + assertJsonConversions(TestFileLocation.TCA_ALERT_JSON, TcaModelJsonConversion + .TCA_ALERT_JSON_FUNCTION, TcaModelJsonConversion.TCA_OBJECT_MAPPER); + + assertThat(tcaAlert).isNotNull(); + assertThat(tcaAlert.getAai().getGenericVNFName()).isEqualTo("vpp-test(?)"); + + assertThat(tcaAlert.getTargetType()).isEqualTo("VNF"); + assertThat(tcaAlert.getRequestId()).isEqualTo("0138afac-b032-4e4b-bd30-88260f444888"); + + assertThat(tcaAlert.getClosedLoopControlName()) + .isEqualTo("CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8"); + + assertThat(tcaAlert.getVersion()).isEqualTo("1.0.2"); + + assertThat(tcaAlert.getClosedLoopAlarmStart()).isEqualTo(1478189220547L); + + assertThat(tcaAlert.getClosedLoopEventStatus()).isEqualTo("ONSET"); + + } +} diff --git a/dcae-analytics/dcae-analytics-tca-model/src/test/java/org/onap/dcae/analytics/tca/model/util/json/mixin/policy/TcaPolicyMixinTest.java b/dcae-analytics/dcae-analytics-tca-model/src/test/java/org/onap/dcae/analytics/tca/model/util/json/mixin/policy/TcaPolicyMixinTest.java new file mode 100644 index 0000000..5592f3b --- /dev/null +++ b/dcae-analytics/dcae-analytics-tca-model/src/test/java/org/onap/dcae/analytics/tca/model/util/json/mixin/policy/TcaPolicyMixinTest.java @@ -0,0 +1,54 @@ +/* + * ================================================================================ + * Copyright (c) 2018 AT&T Intellectual Property. 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. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.analytics.tca.model.util.json.mixin.policy; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.onap.dcae.analytics.tca.model.BaseTcaModelTest; +import org.onap.dcae.analytics.tca.model.policy.TcaPolicy; +import org.onap.dcae.analytics.tca.model.util.json.TcaModelJsonConversion; + +/** + * @author Rajiv Singla + */ +class TcaPolicyMixinTest extends BaseTcaModelTest { + + @Test + @DisplayName("Test TCA Policy JSON Conversions") + void testTCAPolicyJsonConversions() throws Exception { + + final TcaPolicy tcaPolicy = + assertJsonConversions(TestFileLocation.TCA_POLICY_JSON, TcaModelJsonConversion + .TCA_POLICY_JSON_FUNCTION, TcaModelJsonConversion.TCA_OBJECT_MAPPER); + + assertThat(tcaPolicy).isNotNull(); + assertThat(tcaPolicy.getMetricsPerEventName().size()) + .as("TCA Policy Metrics Per Event Name must be 3").isEqualTo(3); + + assertThat(tcaPolicy.getMetricsPerEventName().get(0).getThresholds().size()) + .as("TCA Policy Thresholds for first event name must be 3").isEqualTo(3); + + // test tca policy serialization + testSerialization(tcaPolicy, getClass()); + } + +} |