From 481d501a5a832a66b938946fbda65c879ea9d872 Mon Sep 17 00:00:00 2001 From: vasraz Date: Thu, 1 Dec 2022 17:59:50 +0000 Subject: Fix broken test coverage Signed-off-by: Vasyl Razinkov Change-Id: I005c1e2bd4a064118c652eff77fbe2e737995270 Issue-ID: SDC-4285 --- jtosca/pom.xml | 11 ---- pom.xml | 71 ++++++++++++++++------ sdc-tosca/pom.xml | 30 --------- .../onap/sdc/tosca/parser/impl/QueryProcessor.java | 51 ++++++++-------- .../parser/elements/queries/EntityQueryTest.java | 2 - 5 files changed, 79 insertions(+), 86 deletions(-) diff --git a/jtosca/pom.xml b/jtosca/pom.xml index 041b8bb..1242668 100644 --- a/jtosca/pom.xml +++ b/jtosca/pom.xml @@ -75,17 +75,6 @@ checkstyle.suppressions.file - - - org.apache.maven.plugins - maven-surefire-plugin - - ${argLine} -Xmx2048m - - */* - - - com.github.sylvainlaurent.maven yaml-json-validator-maven-plugin diff --git a/pom.xml b/pom.xml index fb337db..1e69a01 100644 --- a/pom.xml +++ b/pom.xml @@ -43,16 +43,19 @@ releases + pom.xml,src/test + ${project.reporting.outputDirectory}/jacoco-ut/jacoco.xml + **/scripts/**/* + app/**/*.js,server-mock/**/*.js,src/**/*.js,src/main/**/*.java + ${project.build.directory}/code-coverage/lcov.info java - - ${project.reporting.outputDirectory}/jacoco-ut/jacoco.xml - - ${project.build.sourceEncoding} + ${project.basedir}/node/node ${project.basedir} + ${project.version} + ${project.build.sourceEncoding} . - **/scripts/**/* + ${project.build.directory}/surefire-reports **/test/**/*,**/tests/**/* - app/**/*.js,server-mock/**/*.js,src/**/*.js,src/main/**/*.java 1.18.20 @@ -60,6 +63,8 @@ ${mockito.version} 1.8.2 5.8.2 + + 0.8.8 @@ -89,6 +94,14 @@ + + + org.jacoco + org.jacoco.agent + runtime + ${jacoco.version} + test + org.slf4j slf4j-api @@ -148,6 +161,11 @@ + + org.jacoco + jacoco-maven-plugin + ${jacoco.version} + org.apache.maven.plugins maven-compiler-plugin @@ -204,22 +222,35 @@ checkstyle-suppressions.xml checkstyle.suppressions.file + true + org.jacoco jacoco-maven-plugin - 0.8.8 + false - - prepare-agent + default-instrument + + instrument + + + + default-restore-instrumented-classes - prepare-agent + restore-instrumented-classes + + + + default-report + + report - ${sonar.jacoco.reportPath} + ${project.build.directory}/jacoco.exec @@ -243,17 +274,21 @@ org.apache.maven.plugins maven-surefire-plugin + + + org.apache.maven.surefire + surefire-junit-platform + 2.22.2 + + - ${argLine} -Xmx2048m + false + + ${project.build.directory}/jacoco.exec + - - org.sonarsource.scanner.maven - sonar-maven-plugin - 3.7.0.1746 - - com.github.sylvainlaurent.maven yaml-json-validator-maven-plugin diff --git a/sdc-tosca/pom.xml b/sdc-tosca/pom.xml index 8bd4018..da94217 100644 --- a/sdc-tosca/pom.xml +++ b/sdc-tosca/pom.xml @@ -93,36 +93,6 @@ - - org.jacoco - jacoco-maven-plugin - 0.8.6 - - - - prepare-agent - - prepare-agent - - - ${sonar.jacoco.reportPath} - - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - - ${argLine} -Xmx2048m - - **/ToscaParser***Test.class - - - - com.github.sylvainlaurent.maven yaml-json-validator-maven-plugin diff --git a/sdc-tosca/src/main/java/org/onap/sdc/tosca/parser/impl/QueryProcessor.java b/sdc-tosca/src/main/java/org/onap/sdc/tosca/parser/impl/QueryProcessor.java index 5bbd2aa..bd34afe 100644 --- a/sdc-tosca/src/main/java/org/onap/sdc/tosca/parser/impl/QueryProcessor.java +++ b/sdc-tosca/src/main/java/org/onap/sdc/tosca/parser/impl/QueryProcessor.java @@ -7,9 +7,9 @@ * 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. @@ -20,7 +20,7 @@ package org.onap.sdc.tosca.parser.impl; -import java.util.Collections; +import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -38,6 +38,7 @@ import org.slf4j.LoggerFactory; * Performs search for entity templates inside node template according to query criteria */ class QueryProcessor { + private static final Logger logger = LoggerFactory.getLogger(QueryProcessor.class.getName()); private final EntityQuery entityQuery; @@ -53,7 +54,7 @@ class QueryProcessor { } List doQuery() { - final List entityDetailsList = Collections.emptyList(); + final List entityDetailsList = new ArrayList<>(); if (isServiceSearch()) { //search for entities inside the service if (logger.isDebugEnabled()) { @@ -75,15 +76,15 @@ class QueryProcessor { // and search for instances of the same type //if the queried topology template is "SERVICE", search for all instances of templates in the service List internalTopologyTemplates = foundTopologyTemplates.stream() - .filter(nt->nt.getSubMappingToscaTemplate() != null) - .map(nt->getInternalTopologyTemplates(nt.getSubMappingToscaTemplate().getNodeTemplates(), true)) - .flatMap(List::stream) - .collect(Collectors.toList()); + .filter(nt -> nt.getSubMappingToscaTemplate() != null) + .map(nt -> getInternalTopologyTemplates(nt.getSubMappingToscaTemplate().getNodeTemplates(), true)) + .flatMap(List::stream) + .collect(Collectors.toList()); foundTopologyTemplates.addAll(internalTopologyTemplates); } if (logger.isDebugEnabled()) { logger.debug("Found topology templates {} matching following query criteria: {}", - foundTopologyTemplates, topologyTemplateQuery); + foundTopologyTemplates, topologyTemplateQuery); } //go over all node templates found according to query criteria and recursive flag and // search for the requested entities. @@ -95,16 +96,16 @@ class QueryProcessor { private Map convertListToMap(List nodeTemplateList) { // we use map to avoid duplicate search through same node templates return nodeTemplateList.stream() - .collect(Collectors.toMap(NodeTemplate::getName, nt->nt, (nt1, nt2)->nt1)); + .collect(Collectors.toMap(NodeTemplate::getName, nt -> nt, (nt1, nt2) -> nt1)); } private List searchEntitiesInsideTopologyTemplates(List foundTopologyTemplates) { return convertListToMap(foundTopologyTemplates) - .values() - .stream() - .map(entityQuery::getEntitiesFromTopologyTemplate) - .flatMap(List::stream) - .collect(Collectors.toList()); + .values() + .stream() + .map(entityQuery::getEntitiesFromTopologyTemplate) + .flatMap(List::stream) + .collect(Collectors.toList()); } private boolean isServiceSearch() { @@ -119,15 +120,15 @@ class QueryProcessor { .flatMap(List::stream) .collect(Collectors.toList()); } - return Collections.emptyList(); + return new ArrayList<>(); } private List getTopologyTemplatesByQuery(NodeTemplate current, boolean isRecursive) { - final List topologyTemplateList = Collections.emptyList(); + final List topologyTemplateList = new ArrayList<>(); boolean isTopologyTemplateFound = isRecursive ? - SdcTypes.isComplex(current.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_TYPE)) - : topologyTemplateQuery.isMatchingSearchCriteria(current); + SdcTypes.isComplex(current.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_TYPE)) + : topologyTemplateQuery.isMatchingSearchCriteria(current); if (isTopologyTemplateFound) { topologyTemplateList.add(current); if (!isRecursive) { @@ -136,13 +137,13 @@ class QueryProcessor { } } if (SdcTypes.isComplex(current.getMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_TYPE)) && - current.getSubMappingToscaTemplate() != null) { - //search the node template inside a given topology template + current.getSubMappingToscaTemplate() != null) { + //search the node template inside a given topology template topologyTemplateList.addAll(current.getSubMappingToscaTemplate().getNodeTemplates() - .stream() - .map(nt->getTopologyTemplatesByQuery(nt, isRecursive)) - .flatMap(List::stream) - .collect(Collectors.toList())); + .stream() + .map(nt -> getTopologyTemplatesByQuery(nt, isRecursive)) + .flatMap(List::stream) + .collect(Collectors.toList())); } return topologyTemplateList; } diff --git a/sdc-tosca/src/test/java/org/onap/sdc/tosca/parser/elements/queries/EntityQueryTest.java b/sdc-tosca/src/test/java/org/onap/sdc/tosca/parser/elements/queries/EntityQueryTest.java index afa1c64..c12dcf7 100644 --- a/sdc-tosca/src/test/java/org/onap/sdc/tosca/parser/elements/queries/EntityQueryTest.java +++ b/sdc-tosca/src/test/java/org/onap/sdc/tosca/parser/elements/queries/EntityQueryTest.java @@ -128,7 +128,6 @@ public class EntityQueryTest { .uUID("7890") .build(); when(metadata.getValue(eq(SdcPropertyNames.PROPERTY_NAME_UUID))).thenReturn("123"); - when(metadata.getValue(eq(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID))).thenReturn("12345"); assertFalse(entityQuery.isSearchCriteriaMatched(metadata, "")); } @@ -176,7 +175,6 @@ public class EntityQueryTest { .customizationUUID("345") .build(); when(metadata.getValue(eq(SdcPropertyNames.PROPERTY_NAME_UUID))).thenReturn("12345"); - when(metadata.getValue(eq(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID))).thenReturn("3456"); assertFalse(entityQuery.isSearchCriteriaMatched(metadata, "a.groups.b")); } -- cgit 1.2.3-korg