<parent>
<groupId>org.onap.aai.aai-common</groupId>
<artifactId>aai-parent</artifactId>
- <version>1.15.4</version>
+ <version>1.15.5</version>
</parent>
<groupId>org.onap.aai.graphadmin</groupId>
<artifactId>aai-graphadmin</artifactId>
- <version>1.15.4-SNAPSHOT</version>
+ <version>1.15.5-SNAPSHOT</version>
<properties>
<docker.push.registry>localhost:5000</docker.push.registry>
<aai.docker.version>1.0.0</aai.docker.version>
<aai.schema.service.version>1.12.7</aai.schema.service.version>
- <aai.common.version>1.15.4</aai.common.version>
+ <aai.common.version>1.15.5</aai.common.version>
<aai.build.directory>${project.build.directory}/${project.artifactId}-${project.version}-build/
</aai.build.directory>
<aai.docker.namespace>onap</aai.docker.namespace>
</exclusion>
</exclusions>
</dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-security</artifactId>
+ </dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.onap.aai.aailog.logs.AaiDebugLog;
-import org.onap.aai.restclient.PropertyPasswordConfiguration;
import org.onap.aai.dbmap.AAIGraph;
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.logging.ErrorLogHelper;
try {
SpringApplication app = new SpringApplication(GraphAdminApp.class);
app.setRegisterShutdownHook(true);
- app.addInitializers(new PropertyPasswordConfiguration());
env = app.run(args).getEnvironment();
}
* ============LICENSE_START=======================================================
* org.onap.aai
* ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2025 Deutsche Telekom. 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.
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.aai.config;
-import org.eclipse.jetty.util.security.Password;
+import java.util.List;
+
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.context.annotation.Configuration;
+
+import lombok.Data;
+
+@Data
+@Configuration
+@ConfigurationProperties(prefix = "aai.basic-auth")
+public class AuthProperties {
+
+ boolean enabled = true;
-public class JettyPasswordDecoder implements PasswordDecoder {
+ List<User> users;
- @Override
- public String decode(String input) {
- if (input.startsWith("OBF:")) {
- return Password.deobfuscate(input);
- }
- return Password.deobfuscate("OBF:" + input);
- }
+ @Data
+ public static class User {
+ private String username;
+ private String password;
+ }
}
+++ /dev/null
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-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.aai.config;
-
-public interface PasswordDecoder {
-
- String decode(String input);
-}
+++ /dev/null
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Modification Copyright © 2019 IBM
- * ================================================================================
- * 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.aai.config;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.Properties;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.apache.commons.io.IOUtils;
-import org.springframework.context.ApplicationContextInitializer;
-import org.springframework.context.ConfigurableApplicationContext;
-import org.springframework.core.env.*;
-
-public class PropertyPasswordConfiguration implements ApplicationContextInitializer<ConfigurableApplicationContext> {
-
- private static final Pattern decodePasswordPattern = Pattern.compile("password\\((.*?)\\)");
- private PasswordDecoder passwordDecoder = new JettyPasswordDecoder();
- private static final Logger logger = LoggerFactory.getLogger(PropertyPasswordConfiguration.class.getName());
-
- @Override
- public void initialize(ConfigurableApplicationContext applicationContext) {
- ConfigurableEnvironment environment = applicationContext.getEnvironment();
- String certPath = environment.getProperty("server.certs.location");
- File passwordFile = null;
- File passphrasesFile = null;
- Map<String, Object> sslProps = new LinkedHashMap<>();
-
- // Override the passwords from application.properties if we find AAF certman files
- if (certPath != null) {
- passwordFile = new File(certPath + ".password");
- try (InputStream passwordStream = new FileInputStream(passwordFile)) {
-
- String keystorePassword = null;
-
- keystorePassword = IOUtils.toString(passwordStream);
- if (keystorePassword != null) {
- keystorePassword = keystorePassword.trim();
- }
- sslProps.put("server.ssl.key-store-password", keystorePassword);
- sslProps.put("schema.service.ssl.key-store-password", keystorePassword);
- } catch (IOException e) {
- logger.warn("Not using AAF Certman password file, e=" + e.getMessage());
- }
- passphrasesFile = new File(certPath + ".passphrases");
- try (InputStream passphrasesStream = new FileInputStream(passphrasesFile)) {
-
- String truststorePassword = null;
- Properties passphrasesProps = new Properties();
- passphrasesProps.load(passphrasesStream);
- truststorePassword = passphrasesProps.getProperty("cadi_truststore_password");
- if (truststorePassword != null) {
- truststorePassword = truststorePassword.trim();
- }
- sslProps.put("server.ssl.trust-store-password", truststorePassword);
- sslProps.put("schema.service.ssl.trust-store-password", truststorePassword);
- } catch (IOException e) {
- logger.warn("Not using AAF Certman passphrases file, e=" + e.getMessage());
- }
- }
- for (PropertySource<?> propertySource : environment.getPropertySources()) {
- Map<String, Object> propertyOverrides = new LinkedHashMap<>();
- decodePasswords(propertySource, propertyOverrides);
- if (!propertyOverrides.isEmpty()) {
- PropertySource<?> decodedProperties = new MapPropertySource("decoded "+ propertySource.getName(), propertyOverrides);
- environment.getPropertySources().addBefore(propertySource.getName(), decodedProperties);
- }
-
- }
- if (!sslProps.isEmpty()) {
- logger.info("Using AAF Certman files");
- PropertySource<?> additionalProperties = new MapPropertySource("additionalProperties", sslProps);
- environment.getPropertySources().addFirst(additionalProperties);
- }
- }
-
- private void decodePasswords(PropertySource<?> source, Map<String, Object> propertyOverrides) {
- if (source instanceof EnumerablePropertySource) {
- EnumerablePropertySource<?> enumerablePropertySource = (EnumerablePropertySource<?>) source;
- for (String key : enumerablePropertySource.getPropertyNames()) {
- Object rawValue = source.getProperty(key);
- if (rawValue instanceof String) {
- String decodedValue = decodePasswordsInString((String) rawValue);
- propertyOverrides.put(key, decodedValue);
- }
- }
- }
- }
-
- private String decodePasswordsInString(String input) {
- if (input == null) {
- return null;
- }
- StringBuffer output = new StringBuffer();
- Matcher matcher = decodePasswordPattern.matcher(input);
- while (matcher.find()) {
- String replacement = passwordDecoder.decode(matcher.group(1));
- matcher.appendReplacement(output, replacement);
- }
- matcher.appendTail(output);
- return output.toString();
- }
-
-}
--- /dev/null
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright © 2025 Deutsche Telekom. 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.aai.config;
+
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.security.config.annotation.web.builders.HttpSecurity;
+import org.springframework.security.core.userdetails.User;
+import org.springframework.security.core.userdetails.UserDetails;
+import org.springframework.security.provisioning.InMemoryUserDetailsManager;
+import org.springframework.security.web.SecurityFilterChain;
+import org.springframework.util.AntPathMatcher;
+
+@Configuration
+@ConditionalOnProperty(name = "aai.basic-auth.enabled", havingValue = "true", matchIfMissing = true)
+public class SecurityConfig {
+
+ @Bean
+ SecurityFilterChain filterChain(HttpSecurity httpSecurity) throws Exception{
+ httpSecurity.csrf(csrf -> csrf.disable())
+ .authorizeHttpRequests(requests -> requests
+ .antMatchers("/util/echo", "/actuator/**")
+ .permitAll()
+ .anyRequest()
+ .authenticated())
+ .httpBasic();
+
+ return httpSecurity.build();
+ }
+
+ @Bean
+ InMemoryUserDetailsManager userDetailsService(AuthProperties userProperties) {
+ UserDetails[] users = userProperties.getUsers().stream()
+ .map(user -> User.withDefaultPasswordEncoder()
+ .username(user.getUsername())
+ .password(user.getPassword())
+ .roles("someRole")
+ .build())
+ .toArray(UserDetails[]::new);
+
+ return new InMemoryUserDetailsManager(users);
+ }
+}
import org.onap.aai.introspection.exceptions.AAIUnknownObjectException;
import org.onap.aai.logging.ErrorLogHelper;
import org.onap.aai.logging.LogFormatTools;
-import org.onap.aai.restclient.PropertyPasswordConfiguration;
import org.onap.aai.setup.SchemaVersions;
import org.onap.aai.util.AAIConfig;
import org.onap.aai.util.AAIConstants;
LOGGER.info("One-Armed Edge Hash Count: " + getOneArmedEdgeHashCount());
// Add more logging if needed for other nodes like Duplicate Groups, Delete Candidates, etc.
LOGGER.info("===== End of Data Grooming Summary =====");
-
+
} catch (Exception ex) {
LOGGER.debug("Exception while grooming data " + LogFormatTools.getStackTop(ex));
}
System.setProperty("aai.service.name", DataGrooming.class.getSimpleName());
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
- PropertyPasswordConfiguration initializer = new PropertyPasswordConfiguration();
- initializer.initialize(ctx);
try {
ctx.scan(
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
-import org.onap.aai.restclient.PropertyPasswordConfiguration;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.apache.commons.configuration2.PropertiesConfiguration;
import org.apache.tinkerpop.gremlin.structure.io.IoCore;
System.setProperty("aai.service.name", DataSnapshot4HistInit.class.getSimpleName());
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
- PropertyPasswordConfiguration initializer = new PropertyPasswordConfiguration();
- initializer.initialize(ctx);
try {
ctx.scan(
"org.onap.aai.config",
import java.io.InputStream;
import java.io.InputStreamReader;
import java.text.SimpleDateFormat;
-import java.util.*;
+import java.util.Arrays;
+import java.util.Date;
import org.onap.aai.aailog.logs.AaiScheduledTaskAuditLog;
import org.onap.aai.exceptions.AAIException;
import org.json.JSONObject;
import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.apache.commons.configuration2.PropertiesConfiguration;
import org.janusgraph.core.JanusGraph;
import org.janusgraph.core.JanusGraphFactory;
-import org.onap.aai.restclient.PropertyPasswordConfiguration;
import org.onap.aai.dbmap.AAIGraphConfig;
import org.onap.aai.edges.EdgeIngestor;
import org.onap.aai.exceptions.AAIException;
}
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
- PropertyPasswordConfiguration initializer = new PropertyPasswordConfiguration();
- initializer.initialize(ctx);
try {
ctx.scan(
"org.onap.aai.config",
import org.apache.tinkerpop.gremlin.structure.*;
import org.janusgraph.core.JanusGraph;
import org.janusgraph.core.JanusGraphFactory;
-import org.onap.aai.restclient.PropertyPasswordConfiguration;
import org.onap.aai.dbmap.AAIGraph;
import org.onap.aai.dbmap.AAIGraphConfig;
import org.onap.aai.edges.enums.AAIDirection;
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
- PropertyPasswordConfiguration initializer = new PropertyPasswordConfiguration();
- initializer.initialize(ctx);
try {
ctx.scan(
"org.onap.aai.config",
import org.apache.tinkerpop.gremlin.process.traversal.step.util.Tree;
import org.apache.tinkerpop.gremlin.structure.Element;
import org.apache.tinkerpop.gremlin.structure.Vertex;
-import org.onap.aai.restclient.PropertyPasswordConfiguration;
import org.onap.aai.db.props.AAIProperties;
import org.onap.aai.dbmap.InMemoryGraph;
import org.onap.aai.edges.EdgeIngestor;
}
public static void main(String[] args) throws AAIException {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
- PropertyPasswordConfiguration initializer = new PropertyPasswordConfiguration();
- initializer.initialize(ctx);
try {
ctx.scan(
"org.onap.aai.config",
*/
package org.onap.aai.dbgen.schemamod;
-import org.onap.aai.restclient.PropertyPasswordConfiguration;
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.introspection.Loader;
import org.onap.aai.introspection.LoaderFactory;
MDC.put("logFilenameAppender", SchemaMod.class.getSimpleName());
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
- PropertyPasswordConfiguration initializer = new PropertyPasswordConfiguration();
- initializer.initialize(ctx);
try {
ctx.scan(
"org.onap.aai.config",
*/
package org.onap.aai.dbgen.schemamod;
-import org.onap.aai.restclient.PropertyPasswordConfiguration;
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.introspection.Loader;
import org.onap.aai.introspection.LoaderFactory;
import org.slf4j.MDC;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
-
public class SchemaMod4Hist {
private final LoaderFactory loaderFactory;
public static void main(String[] args) throws AAIException {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
- PropertyPasswordConfiguration initializer = new PropertyPasswordConfiguration();
- initializer.initialize(ctx);
try {
ctx.scan(
"org.onap.aai.config",
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
+
import org.apache.tinkerpop.gremlin.structure.Graph;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.janusgraph.core.schema.ConsistencyModifier;
private final Cardinality cardinality;
private final long commitBlockSize;
private final Logger logger;
-
- public SchemaModInternalBatch(TransactionalGraphEngine engine, Logger logger, String propName,
+
+ public SchemaModInternalBatch(TransactionalGraphEngine engine, Logger logger, String propName,
String type, String indexType, boolean preserveData, boolean consistencyLock, long commitBlockSize) {
this.engine = engine;
this.propName = propName;
this.commitBlockSize = commitBlockSize;
this.logger = logger;
}
-
-
+
+
private Class<?> determineClass(String type) {
final Class<?> result;
if (type.equals("String")) {
logAndPrint(logger, emsg);
throw new RuntimeException(emsg);
}
-
+
return result;
}
-
+
private Cardinality determineCardinality(String type) {
if (type.equals("Set<String>")) {
return Cardinality.SET;
return Cardinality.SINGLE;
}
}
-
+
public void execute() {
JanusGraphManagement graphMgt = null;
String retiredName = "";
long timeStart = System.nanoTime();
int batchCt = 0;
int totalCount = 0;
-
+
ArrayList<HashMap<String,Object>> allVerts = new ArrayList<HashMap<String,Object>>();
HashMap<String,Object> batchVHash = new HashMap<String,Object>();
-
+
try {
// Make sure this property is in the DB.
graphMgt = engine.asAdmin().getManagementSystem();
logAndPrint(logger, emsg);
System.exit(1);
}
-
- // Collect the data that needs to be processed and
- // store as hashes of vertex-id's and the original property value
+
+ // Collect the data that needs to be processed and
+ // store as hashes of vertex-id's and the original property value
long timeA = System.nanoTime();
int msgEveryXCount = 1000;
Graph grTmp1 = engine.startTransaction();
logAndPrint(logger, "Collecting the data for batch # " + batchKey );
batchVCount = 0;
batchVHash = new HashMap<String,Object>();
- }
+ }
if( msgCount > msgEveryXCount ) {
msgCount = 0;
- logAndPrint(logger, " Initial processing running... total so far = " + totalCount );
+ logAndPrint(logger, " Initial processing running... total so far = " + totalCount );
}
}
-
+
if( batchVCount > 0 ) {
// Add the last partial set if there is one.
allVerts.add(batchKey, batchVHash);
}
logAndPrint(logger, "Found " + totalCount + " nodes that will be affected. ");
-
+
batchCt = batchKey +1;
-
+
if( totalCount == 0 ) {
logAndPrint(logger, "INFO -- No data found to process. ");
System.exit(1);
}
-
+
logAndPrint(logger, "INFO -- Total of " + totalCount +
- " nodes to process. Will use " + batchCt +
+ " nodes to process. Will use " + batchCt +
" batches. " );
-
+
long timeB = System.nanoTime();
long diffTime = timeB - timeA;
long minCount = TimeUnit.NANOSECONDS.toMinutes(diffTime);
long secCount = TimeUnit.NANOSECONDS.toSeconds(diffTime) - (60 * minCount);
logAndPrint(logger, " -- To collect all nodes took: " +
minCount + " minutes, " + secCount + " seconds " );
-
+
if (indexType.equals("uniqueIndex")) {
// Make sure the data in the property being changed can have a
// unique-index put on it.
logAndPrint(logger, "-- Finished/Passed UniquePropertyCheck. ");
logAndPrint(logger, "There are " + totalCount + " nodes that have this property. ");
}
-
+
// ---- If we made it to here - we must be OK with making this change
-
+
// Rename this property to a backup name (old name with a dateString and
// "-RETIRED" appended)
long timeE = System.nanoTime();
FormatDate fd = new FormatDate("MMddHHmm", "GMT");
- String dteStr= fd.getDateTime();
+ String dteStr= fd.getDateTime();
retiredName = propName + "-" + dteStr + "-RETIRED";
- graphMgt.changeName(origPropKey, retiredName);
- logAndPrint(logger, " -- Temporary property name will be: [" + retiredName + "]. ");
-
+ graphMgt.changeName(origPropKey, retiredName);
+ logAndPrint(logger, " -- Temporary property name will be: [" + retiredName + "]. ");
+
// Create a new property using the original property name and the
// targetDataType
PropertyKey freshPropKey = graphMgt.makePropertyKey(propName).dataType(type)
logAndPrint(logger, " -- Consistency Lock is being set on the index ");
graphMgt.setConsistency(indexG, ConsistencyModifier.LOCK);
}
-
+
logAndPrint(logger, "Committing schema changes with graphMgt.commit()");
graphMgt.commit();
success = true;
-
+
long timeF = System.nanoTime();
diffTime = timeF - timeE;
minCount = TimeUnit.NANOSECONDS.toMinutes(diffTime);
secCount = TimeUnit.NANOSECONDS.toSeconds(diffTime) - (60 * minCount);
logAndPrint(logger, " -- Temporary property Name Change took: " +
minCount + " minutes, " + secCount + " seconds " );
-
+
} catch (Exception ex) {
logAndPrint(logger, "Threw a regular Exception: ");
logAndPrint(logger, ex.getMessage());
}
}
}
-
-
+
+
// For each node that has this property, update the new from the old
// and then remove the old property from that node
// Note - do it in batches since there can be a LOT of updates.
for( int batNo=0; batNo < batchCt; batNo++ ) {
try {
logAndPrint(logger, "BEGIN -- Batch # " + batNo );
- processUpdateForBatch( allVerts.get(batNo), retiredName );
+ processUpdateForBatch( allVerts.get(batNo), retiredName );
logAndPrint(logger, "Completed Batch # " + batNo );
} catch (Exception e) {
String emsg = "ERROR -- Batch # " + batNo +
- " failed to process. Please clean up manually. " +
- " data in [" + retiredName +
- "] will have to be moved to the original property.";
+ " failed to process. Please clean up manually. " +
+ " data in [" + retiredName +
+ "] will have to be moved to the original property.";
logAndPrint(logger, emsg);
emsgList.add(emsg);
}
- }
+ }
long timeF = System.nanoTime();
long diffTime = timeF - timeE;
long minCount = TimeUnit.NANOSECONDS.toMinutes(diffTime);
long secCount = TimeUnit.NANOSECONDS.toSeconds(diffTime) - (60 * minCount);
logAndPrint(logger, " -- Time to process all batches: " +
minCount + " minutes, " + secCount + " seconds " );
-
+
logAndPrint(logger, "\nINFO -- Total of " + totalCount +
" nodes processed using: " + batchCt + " batches. " );
-
+
if( !emsgList.isEmpty() ) {
Iterator <String> eItr = emsgList.iterator();
logAndPrint(logger, ">>> These will need to be taken care of: ");
logAndPrint(logger, (String)eItr.next());
}
}
-
+
long timeEnd = System.nanoTime();
diffTime = timeEnd - timeStart;
minCount = TimeUnit.NANOSECONDS.toMinutes(diffTime);
secCount = TimeUnit.NANOSECONDS.toSeconds(diffTime) - (60 * minCount);
logAndPrint(logger, " -- Total Processing time was: " +
minCount + " minutes, " + secCount + " seconds " );
-
+
}// End of Execute()
-
-
- private void processUpdateForBatch( HashMap<String,Object> vertHash,
+
+
+ private void processUpdateForBatch( HashMap<String,Object> vertHash,
String retiredName ) throws Exception {
-
+
Iterator<Map.Entry<String, Object>> vertHashItr = vertHash.entrySet().iterator();
int vtxCount = 0;
Boolean success = false;
- Graph grTmpBat = engine.startTransaction();
- try {
+ Graph grTmpBat = engine.startTransaction();
+ try {
while( vertHashItr.hasNext() ){
- Map.Entry<String, Object> entry = vertHashItr.next();
+ Map.Entry<String, Object> entry = vertHashItr.next();
String tmpVid = entry.getKey();
Vertex tmpVtx = null;
-
+
Iterator<Vertex> oneVItr = grTmpBat.traversal().V(tmpVid);
while( oneVItr.hasNext() ) {
// should never find more than one...
}
tmpVtx.property(retiredName).remove();
logAndPrint(logger, "INFO -- update item: (vid= "
- + tmpVid + ", val=[" + origVal + "])");
+ + tmpVid + ", val=[" + origVal + "])");
vtxCount++;
}
}
logAndPrint(logger, "ERROR -- rolling back node updates for this batch.");
engine.rollback();
}
- }
+ }
}
if( ! success ) {
throw new Exception ("ERROR - could not process this batch -- see the log for details.");
}
-
- }// end of processUpdateForBatch()
-
+
+ }// end of processUpdateForBatch()
+
private Boolean doUniquenessCheck( ArrayList<HashMap<String,Object>> allVerts,
String propertyName ){
- // Note - property can be found in more than one nodetype
- // our uniqueness constraints are always across the entire db - so this
+ // Note - property can be found in more than one nodetype
+ // our uniqueness constraints are always across the entire db - so this
// tool looks across all nodeTypes that the property is found in.
long timeStart = System.nanoTime();
int batchCt = allVerts.size();
HashMap <String,Object> bigSingleHash = new HashMap <String,Object> ();
-
+
for( int batNo=0; batNo < batchCt; batNo++ ) {
bigSingleHash.putAll(allVerts.get(batNo));
}
-
+
ArrayList <Object> dupeValues = new ArrayList<Object> ();
int dupeCount = 0;
-
+
Iterator bItr = bigSingleHash.entrySet().iterator();
while( bItr.hasNext() ) {
Map.Entry pair = (Map.Entry)bItr.next();
dupeCount++;
}
}
-
+
long timeEnd = System.nanoTime();
long diffTime = timeEnd - timeStart;
long minCount = TimeUnit.NANOSECONDS.toMinutes(diffTime);
long secCount = TimeUnit.NANOSECONDS.toSeconds(diffTime) - (60 * minCount);
logAndPrint(logger, " -- Total Uniqueness Check took: " +
minCount + " minutes, " + secCount + " seconds " );
-
+
if( dupeValues.isEmpty() ){
logAndPrint(logger, "\n ------------ No Duplicates Found -------- \n");
}
else {
- logAndPrint(logger, "\n -------------- Found " + dupeCount +
+ logAndPrint(logger, "\n -------------- Found " + dupeCount +
" cases of duplicate values for property [" + propertyName + "\n\n");
logAndPrint(logger, "\n --- These values are in the db twice or more: ");
Iterator <?> dupeValItr = dupeValues.iterator();
logAndPrint(logger, " value = [" + dupeValItr.next() + "]");
}
}
-
+
if( dupeCount > 0 ) {
return true;
}else {
return false;
}
-
+
}// end of doUniquenessCheck()
-
-
+
+
/**
* Log and print.
System.out.println(msg);
logger.debug(msg);
}
-
+
}
*/
package org.onap.aai.historytruncate;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.text.SimpleDateFormat;
-import java.util.*;
+import java.util.Date;
import org.onap.aai.aailog.logs.AaiScheduledTaskAuditLog;
import org.onap.aai.exceptions.AAIException;
import org.springframework.stereotype.Component;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+
@Component
@PropertySource("file:${server.local.startpath}/etc/appprops/datatoolscrons.properties")
public class HistoryTruncateTasks {
+++ /dev/null
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-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.aai.interceptors.pre;
-
-import org.onap.aai.Profiles;
-import org.onap.aai.exceptions.AAIException;
-import org.onap.aai.interceptors.AAIContainerFilter;
-import org.onap.aai.logging.ErrorLogHelper;
-import org.onap.aai.service.AuthorizationService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Profile;
-
-import javax.annotation.Priority;
-import javax.ws.rs.container.ContainerRequestContext;
-import javax.ws.rs.container.ContainerRequestFilter;
-import javax.ws.rs.container.PreMatching;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.ext.Provider;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Optional;
-
-@Provider
-@Profile(Profiles.ONE_WAY_SSL)
-@PreMatching
-@Priority(AAIRequestFilterPriority.AUTHORIZATION)
-public class OneWaySslAuthorization extends AAIContainerFilter implements ContainerRequestFilter {
-
- @Autowired
- private AuthorizationService authorizationService;
-
- @Override
- public void filter(ContainerRequestContext containerRequestContext) throws IOException
- {
-
- if(containerRequestContext.getUriInfo().getRequestUri().getPath().matches("^.*/util/echo$")){
- return;
- }
-
- String basicAuth = containerRequestContext.getHeaderString("Authorization");
- List<MediaType> acceptHeaderValues = containerRequestContext.getAcceptableMediaTypes();
-
- if(basicAuth == null || !basicAuth.startsWith("Basic ")){
- Optional<Response> responseOptional = errorResponse("AAI_3300", acceptHeaderValues);
- containerRequestContext.abortWith(responseOptional.get());
- return;
- }
-
- basicAuth = basicAuth.replaceAll("Basic ", "");
-
- if(!authorizationService.checkIfUserAuthorized(basicAuth)){
- Optional<Response> responseOptional = errorResponse("AAI_3300", acceptHeaderValues);
- containerRequestContext.abortWith(responseOptional.get());
- return;
- }
-
- }
-
- private Optional<Response> errorResponse(String errorCode, List<MediaType> acceptHeaderValues) {
- AAIException aaie = new AAIException(errorCode);
- return Optional.of(Response.status(aaie.getErrorObject().getHTTPResponseCode())
- .entity(ErrorLogHelper.getRESTAPIErrorResponse(acceptHeaderValues, aaie, new ArrayList<>()))
- .build());
-
- }
-}
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.introspection.LoaderFactory;
import org.onap.aai.logging.ErrorLogHelper;
-import org.onap.aai.restclient.PropertyPasswordConfiguration;
import org.onap.aai.serialization.db.EdgeSerializer;
import org.onap.aai.setup.SchemaVersions;
import org.onap.aai.util.ExceptionTranslator;
public static void main(String[] args) throws AAIException {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
- PropertyPasswordConfiguration initializer = new PropertyPasswordConfiguration();
- initializer.initialize(ctx);
try {
ctx.scan(
"org.onap.aai.config",
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.onap.aai.edges.EdgeIngestor;
import org.onap.aai.introspection.LoaderFactory;
-import org.onap.aai.migration.*;
+import org.onap.aai.migration.MigrationDangerRating;
+import org.onap.aai.migration.MigrationPriority;
+import org.onap.aai.migration.Migrator;
+import org.onap.aai.migration.Status;
import org.onap.aai.serialization.db.EdgeSerializer;
import org.onap.aai.serialization.engines.TransactionalGraphEngine;
import org.onap.aai.setup.SchemaVersions;
import org.onap.aai.db.props.AAIProperties;
import org.onap.aai.edges.EdgeIngestor;
import org.onap.aai.introspection.LoaderFactory;
-import org.onap.aai.migration.*;
+import org.onap.aai.migration.MigrationDangerRating;
+import org.onap.aai.migration.MigrationPriority;
+import org.onap.aai.migration.Migrator;
+import org.onap.aai.migration.Status;
import org.onap.aai.serialization.db.EdgeSerializer;
import org.onap.aai.serialization.engines.TransactionalGraphEngine;
import org.onap.aai.setup.SchemaVersions;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.onap.aai.edges.EdgeIngestor;
import org.onap.aai.introspection.LoaderFactory;
-import org.onap.aai.migration.*;
+import org.onap.aai.migration.MigrationDangerRating;
+import org.onap.aai.migration.MigrationPriority;
+import org.onap.aai.migration.Migrator;
+import org.onap.aai.migration.Status;
import org.onap.aai.db.props.AAIProperties;
import org.onap.aai.serialization.db.EdgeSerializer;
import org.onap.aai.serialization.engines.TransactionalGraphEngine;
import org.onap.aai.edges.EdgeIngestor;
import org.onap.aai.introspection.Introspector;
import org.onap.aai.introspection.LoaderFactory;
-import org.onap.aai.migration.*;
+import org.onap.aai.migration.MigrationDangerRating;
+import org.onap.aai.migration.MigrationPriority;
+import org.onap.aai.migration.Migrator;
+import org.onap.aai.migration.Status;
import org.onap.aai.db.props.AAIProperties;
import org.onap.aai.serialization.db.EdgeSerializer;
import org.onap.aai.serialization.engines.TransactionalGraphEngine;
import org.onap.aai.edges.EdgeIngestor;
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.introspection.LoaderFactory;
-import org.onap.aai.migration.*;
+import org.onap.aai.migration.MigrationDangerRating;
+import org.onap.aai.migration.MigrationPriority;
+import org.onap.aai.migration.Migrator;
+import org.onap.aai.migration.Status;
import org.onap.aai.edges.enums.EdgeType;
import org.onap.aai.serialization.db.EdgeSerializer;
import org.onap.aai.serialization.engines.TransactionalGraphEngine;
import org.onap.aai.introspection.LoaderFactory;
import org.onap.aai.introspection.ModelType;
import org.onap.aai.serialization.db.EdgeSerializer;
-import org.onap.aai.migration.*;
+import org.onap.aai.migration.MigrationDangerRating;
+import org.onap.aai.migration.MigrationPriority;
+import org.onap.aai.migration.Migrator;
+import org.onap.aai.migration.Status;
import org.onap.aai.serialization.engines.TransactionalGraphEngine;
import org.onap.aai.setup.SchemaVersion;
import org.onap.aai.setup.SchemaVersions;
import java.time.temporal.ChronoUnit;
-import java.util.*;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Optional;
+import java.util.Set;
/**
* Remove old aai-uri index per
import org.onap.aai.db.props.AAIProperties;
import org.onap.aai.edges.EdgeIngestor;
import org.onap.aai.introspection.LoaderFactory;
-import org.onap.aai.migration.*;
+import org.onap.aai.migration.EdgeSwingMigrator;
+import org.onap.aai.migration.MigrationDangerRating;
+import org.onap.aai.migration.MigrationPriority;
+import org.onap.aai.migration.Status;
import org.onap.aai.serialization.db.EdgeSerializer;
import org.onap.aai.serialization.engines.TransactionalGraphEngine;
import org.onap.aai.setup.SchemaVersions;
import java.nio.charset.UnsupportedCharsetException;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
-import org.apache.tinkerpop.gremlin.structure.*;
+import org.apache.tinkerpop.gremlin.structure.Direction;
+import org.apache.tinkerpop.gremlin.structure.Edge;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.javatuples.Pair;
import org.onap.aai.db.props.AAIProperties;
import org.onap.aai.edges.EdgeIngestor;
import org.onap.aai.edges.enums.EdgeProperty;
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.introspection.LoaderFactory;
-import org.onap.aai.migration.*;
+import org.onap.aai.migration.EdgeSwingMigrator;
+import org.onap.aai.migration.MigrationDangerRating;
+import org.onap.aai.migration.MigrationPriority;
+import org.onap.aai.migration.Status;
import org.onap.aai.introspection.Introspector;
import org.onap.aai.serialization.db.EdgeSerializer;
import org.onap.aai.serialization.engines.TransactionalGraphEngine;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
import org.apache.tinkerpop.gremlin.process.traversal.P;
-import org.apache.tinkerpop.gremlin.structure.*;
+import org.apache.tinkerpop.gremlin.structure.Direction;
+import org.apache.tinkerpop.gremlin.structure.Edge;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.javatuples.Pair;
import org.onap.aai.db.props.AAIProperties;
import org.onap.aai.edges.EdgeIngestor;
import org.onap.aai.edges.enums.EdgeProperty;
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.introspection.LoaderFactory;
-import org.onap.aai.migration.*;
+import org.onap.aai.migration.EdgeSwingMigrator;
+import org.onap.aai.migration.MigrationDangerRating;
+import org.onap.aai.migration.MigrationPriority;
+import org.onap.aai.migration.Status;
import org.onap.aai.serialization.engines.TransactionalGraphEngine;
import org.springframework.web.util.UriUtils;
private static List<Introspector> dmaapDeleteList = new ArrayList<Introspector>();
private static int pserversUpdatedCount = 0;
private static int pserversDeletedCount = 0;
-
-
+
+
private static String[] rctSourceOfTruth = new String[]{"AAIRctFeed", "RCT"};
private static String[] roSourceOfTruth = new String[]{"AAI-EXTENSIONS", "RO"};
@Override
public void run() {
-
+
int dupCount = 0;
nodeTypeToUri = loader.getAllObjects().entrySet().stream().filter(e -> e.getValue().getGenericURI().contains("{")).collect(
Collectors.toMap(
List<Vertex> rctList = graphTraversalSource().V().has("aai-node-type", "pserver").has("source-of-truth", P.within(rctSourceOfTruth)).toList();
List<Vertex> roList = graphTraversalSource().V().has("aai-node-type", "pserver").has("source-of-truth", P.within(roSourceOfTruth)).toList();
-
+
logger.info("Total number of RCT sourced pservers in A&AI :" +rctList.size());
logger.info("Total number of RO sourced pservers in A&AI :" +roList.size());
-
+
for(int i=0;i<rctList.size();i++){
Vertex currRct = rctList.get(i);
Object currRctFqdn = null;
Iterator<Vertex> pIntListItr = pIntList.iterator();
while(pIntListItr.hasNext()){
Vertex pInt = pIntListItr.next();
-
+
removeROPIntMap.put(pInt.property("interface-name").value().toString(), pInt);
}
Set<String> interfaceNameSet = removeROPIntMap.keySet();
}
}
}
- }
+ }
}
-
+
private void dropMatchingROLagInterfaces(Vertex ro, Vertex rct) {
Map<String, Vertex> removeROLagIntMap = new HashMap<String, Vertex>();
List<Vertex> lagIntList = graphTraversalSource().V(ro).in("tosca.relationships.network.BindsTo").has("aai-node-type","lag-interface").toList();
Iterator<Vertex> lagIntListItr = lagIntList.iterator();
while(lagIntListItr.hasNext()){
Vertex lagInt = lagIntListItr.next();
-
+
removeROLagIntMap.put(lagInt.property("interface-name").value().toString(), lagInt);
}
Set<String> interfaceNameSet = removeROLagIntMap.keySet();
}
}
}
- }
+ }
}
-
+
public void dropComplexEdge(Vertex ro){
List<Vertex> locatedInEdgeVertexList = graphTraversalSource().V(ro).has("aai-node-type", "pserver").out("org.onap.relationships.inventory.LocatedIn").has("aai-node-type","complex").toList();
if (locatedInEdgeVertexList != null && !locatedInEdgeVertexList.isEmpty()){
import org.springframework.stereotype.Service;
import java.net.ConnectException;
import java.net.SocketTimeoutException;
-import java.util.*;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
@Service
public class ApertureService {
return baseUrl;
}
- @Override
- protected String getTruststorePath() {
- return truststorePath;
- }
-
- @Override
- protected char[] getTruststorePassword() {
- return truststorePassword.toCharArray();
- }
-
@Override
protected HttpComponentsClientHttpRequestFactory getHttpRequestFactory() throws Exception {
HttpComponentsClientHttpRequestFactory requestFactory = super.getHttpRequestFactory();
return baseUrl;
}
- @Override
- protected String getKeystorePath() {
- return keystorePath;
- }
-
- @Override
- protected String getTruststorePath() {
- return truststorePath;
- }
-
- @Override
- protected char[] getKeystorePassword() {
- return keystorePassword.toCharArray();
- }
-
- @Override
- protected char[] getTruststorePassword() {
- return truststorePassword.toCharArray();
- }
-
protected HttpComponentsClientHttpRequestFactory getHttpRequestFactory() throws Exception {
HttpComponentsClientHttpRequestFactory requestFactory = super.getHttpRequestFactory();
requestFactory.setConnectionRequestTimeout(timeout);
import org.onap.aai.dbmap.AAIGraph;
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.logging.ErrorLogHelper;
-import org.onap.aai.restclient.PropertyPasswordConfiguration;
import org.onap.aai.util.AAIConfig;
import org.onap.aai.util.ExceptionTranslator;
import org.onap.aai.util.GraphAdminDBUtils;
private static Logger LOGGER;
private static boolean historyEnabled;
private static final String SCHEMA_INITIALIZED = "schema-initialized";
-
+
/**
* The main method.
*
boolean addDefaultCR = true;
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
- PropertyPasswordConfiguration initializer = new PropertyPasswordConfiguration();
- initializer.initialize(ctx);
try {
ctx.scan(
"org.onap.aai.config",
}
try {
Vertex newVertex = graph.addVertex(SCHEMA_INITIALIZED , false);
- LOGGER.info("Created a new vertex with property '{}' set to '{}'", SCHEMA_INITIALIZED ,
+ LOGGER.info("Created a new vertex with property '{}' set to '{}'", SCHEMA_INITIALIZED ,
newVertex.property(SCHEMA_INITIALIZED ).value());
} catch (Exception e) {
LOGGER.error("Error creating a new vertex: {}", e.getMessage(), e);
graphMgtForClosing.commit();
}
-}
\ No newline at end of file
+}
import org.slf4j.LoggerFactory;
import org.janusgraph.core.JanusGraph;
import org.janusgraph.core.schema.JanusGraphManagement;
-import org.onap.aai.restclient.PropertyPasswordConfiguration;
import org.onap.aai.dbgen.SchemaGenerator4Hist;
import org.onap.aai.dbmap.AAIGraph;
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.logging.ErrorLogHelper;
-import org.onap.aai.util.*;
+import org.onap.aai.util.AAIConfig;
+import org.onap.aai.util.ExceptionTranslator;
+import org.onap.aai.util.GraphAdminDBUtils;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
-
public class GenTester4Hist {
private static Logger LOGGER;
boolean addDefaultCR = false; // For History, we do not add the default CloudRegion
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
- PropertyPasswordConfiguration initializer = new PropertyPasswordConfiguration();
- initializer.initialize(ctx);
try {
ctx.scan(
"org.onap.aai.config",
+++ /dev/null
-/**
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-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.aai.service;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.eclipse.jetty.util.security.Password;
-import org.onap.aai.Profiles;
-import org.onap.aai.util.AAIConstants;
-import org.springframework.context.annotation.Profile;
-import org.springframework.stereotype.Service;
-
-import javax.annotation.PostConstruct;
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-import java.util.Base64;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.stream.Stream;
-
-@Profile(Profiles.ONE_WAY_SSL)
-@Service
-public class AuthorizationService {
-
- private static final Logger logger = LoggerFactory.getLogger(AuthorizationService.class);
-
- private final Map<String, String> authorizedUsers = new HashMap<>();
-
- private static final Base64.Encoder ENCODER = Base64.getEncoder();
-
- @PostConstruct
- public void init(){
-
- String basicAuthFile = getBasicAuthFilePath();
-
- try(Stream<String> stream = Files.lines(Paths.get(basicAuthFile))){
- stream.filter(line -> !line.startsWith("#")).forEach(str -> {
- byte [] bytes = null;
-
- String usernamePassword = null;
- String accessType = null;
-
- try {
- String [] userAccessType = str.split(",");
-
- if(userAccessType == null || userAccessType.length != 2){
- throw new RuntimeException("Please check the realm.properties file as it is not conforming to the basic auth");
- }
-
- usernamePassword = userAccessType[0];
- accessType = userAccessType[1];
-
- String[] usernamePasswordArray = usernamePassword.split(":");
-
- if(usernamePasswordArray == null || usernamePasswordArray.length != 3){
- throw new RuntimeException("This username / pwd is not a valid entry in realm.properties");
- }
-
- String username = usernamePasswordArray[0];
- String password = null;
-
- if(str.contains("OBF:")){
- password = usernamePasswordArray[1] + ":" + usernamePasswordArray[2];
- password = Password.deobfuscate(password);
- }
-
- bytes = ENCODER.encode((username + ":" + password).getBytes("UTF-8"));
-
- authorizedUsers.put(new String(bytes), accessType);
-
- } catch (UnsupportedEncodingException e)
- {
- logger.error("Unable to support the encoding of the file" + basicAuthFile);
- }
-
- authorizedUsers.put(new String(ENCODER.encode(bytes)), accessType);
- });
- } catch (IOException e) {
- logger.error("IO Exception occurred during the reading of realm.properties", e);
- }
- }
-
- public boolean checkIfUserAuthorized(String authorization){
- return authorizedUsers.containsKey(authorization) && "admin".equals(authorizedUsers.get(authorization));
- }
-
- public String getBasicAuthFilePath(){
- return AAIConstants.AAI_HOME_ETC_AUTH + AAIConstants.AAI_FILESEP + "realm.properties";
- }
-}
import com.beust.jcommander.JCommander;
import com.beust.jcommander.Parameter;
-import org.onap.aai.restclient.PropertyPasswordConfiguration;
import org.onap.aai.dbmap.AAIGraph;
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.introspection.LoaderFactory;
import org.onap.aai.setup.SchemaVersions;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.UUID;
public class SendDeleteMigrationNotificationsMain {
String requestId = UUID.randomUUID().toString();
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
- PropertyPasswordConfiguration initializer = new PropertyPasswordConfiguration();
- initializer.initialize(ctx);
try {
ctx.scan(
"org.onap.aai.config",
import com.beust.jcommander.JCommander;
import com.beust.jcommander.Parameter;
-import org.onap.aai.restclient.PropertyPasswordConfiguration;
import org.onap.aai.dbmap.AAIGraph;
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.introspection.LoaderFactory;
String requestId = UUID.randomUUID().toString();
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
- PropertyPasswordConfiguration initializer = new PropertyPasswordConfiguration();
- initializer.initialize(ctx);
try {
ctx.scan(
"org.onap.aai.config",
# If you get an application startup failure that the port is already taken
# If thats not it, please check if the key-store file path makes sense
server.local.startpath=src/main/resources
-server.basic.auth.location=${server.local.startpath}etc/auth/realm.properties
server.port=8449
-server.ssl.enabled-protocols=TLSv1.1,TLSv1.2
-server.ssl.key-store=${server.local.startpath}/etc/auth/aai_keystore
-server.ssl.key-store-password=password(OBF:1vn21ugu1saj1v9i1v941sar1ugw1vo0)
-server.ssl.trust-store=${server.local.startpath}/etc/auth/aai_keystore
-server.ssl.trust-store-password=password(OBF:1vn21ugu1saj1v9i1v941sar1ugw1vo0)
-server.ssl.client-auth=want
-server.ssl.key-store-type=JKS
# dmaap is deprecated and now replaced with kafka
spring.kafka.producer.bootstrap-servers=${BOOTSTRAP_SERVERS}
schema.service.edges.endpoint=edgerules?version=
schema.service.versions.endpoint=versions
-schema.service.ssl.key-store=${server.local.startpath}/etc/auth/aai_keystore
-schema.service.ssl.key-store-password=password(OBF:1vn21ugu1saj1v9i1v941sar1ugw1vo0)
-schema.service.ssl.trust-store=${server.local.startpath}/etc/auth/aai_keystore
-schema.service.ssl.trust-store-password=password(OBF:1vn21ugu1saj1v9i1v941sar1ugw1vo0)
-
-aaf.cadi.file=${server.local.startpath}/cadi.properties
-
aperture.rdbmsname=aai_relational
aperture.service.client=no-auth
aperture.service.base.url=http://localhost:8457/aai/aperture
-aperture.service.ssl.key-store=${server.local.startpath}/etc/auth/aai_keystore
-aperture.service.ssl.trust-store=${server.local.startpath}/etc/auth/aai_keystore
-aperture.service.ssl.key-store-password=password(OBF:1vn21ugu1saj1v9i1v941sar1ugw1vo0)
-aperture.service.ssl.trust-store-password=password(OBF:1vn21ugu1saj1v9i1v941sar1ugw1vo0)
aperture.service.timeout-in-milliseconds=300000
#To Expose the Prometheus scraping endpoint
BOOTSTRAP_SERVERS=localhost:9092
JAAS_CONFIG=
aai.graph.properties.path=${server.local.startpath}/etc/appprops/janusgraph-realtime.properties
+
+aai.basic-auth.enabled=true
+aai.basic-auth.users[0].username=AAI
+aai.basic-auth.users[0].password=AAI
# Start of INTERNAL Specific Properties
-aai.truststore.filename=aai_keystore
-aai.truststore.passwd.x=OBF:1vn21ugu1saj1v9i1v941sar1ugw1vo0
-aai.keystore.filename=aai-client-cert.p12
-aai.keystore.passwd.x=OBF:1vn21ugu1saj1v9i1v941sar1ugw1vo0
-
aai.realtime.clients=RO,SDNC,MSO,SO
# End of INTERNAL Specific Properties
+++ /dev/null
-# format : username: password[,rolename ...]
-# default username/password: AAI/AAI, MSO/MSO, ModelLoader/ModelLoader...
-AAI:OBF:1gfr1ev31gg7,admin
-MSO:OBF:1jzx1lz31k01,admin
-SDNC:OBF:1itr1i0l1i151isv,admin
-DCAE:OBF:1g8u1f9d1f991g8w,admin
-POLICY:OBF:1mk61i171ima1im41i0j1mko,admin
-ASDC:OBF:1f991j0u1j001f9d,admin
-VID:OBF:1jm91i0v1jl9,admin
-APPC:OBF:1f991ksf1ksf1f9d,admin
-ModelLoader:OBF:1qvu1v2h1sov1sar1wfw1j7j1wg21saj1sov1v1x1qxw,admin
-AaiUI:OBF:1gfr1p571unz1p4j1gg7,admin
-OOF:OBF:1img1ke71ily,admin
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-import org.onap.aai.restclient.PropertyPasswordConfiguration;
import org.onap.aai.dbmap.AAIGraph;
import org.onap.aai.exceptions.AAIException;
import org.onap.aai.util.AAIConfig;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.annotation.Import;
import org.springframework.http.*;
-import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource;
import org.springframework.web.client.RestTemplate;
*/
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = GraphAdminApp.class)
@EnableAutoConfiguration(exclude={CassandraDataAutoConfiguration.class, CassandraAutoConfiguration.class}) // there is no running cassandra instance for the test
-@ContextConfiguration(initializers = PropertyPasswordConfiguration.class)
@Import(GraphAdminTestConfiguration.class)
@TestPropertySource(
properties = {
import org.apache.http.client.HttpClient;
import org.apache.http.impl.client.HttpClients;
-import org.apache.http.ssl.SSLContextBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.http.HttpStatus;
import org.springframework.http.client.ClientHttpResponse;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
-import org.springframework.util.ResourceUtils;
import org.springframework.web.client.ResponseErrorHandler;
import org.springframework.web.client.RestTemplate;
import javax.net.ssl.SSLContext;
-import java.io.File;
-import java.io.FileInputStream;
import java.io.IOException;
-import java.io.InputStream;
-import java.security.KeyStore;
@TestConfiguration
public class GraphAdminTestConfiguration {
private static final Logger logger = LoggerFactory.getLogger(GraphAdminTestConfiguration.class);
- @Autowired
- private Environment env;
-
/**
* Create a RestTemplate bean, using the RestTemplateBuilder provided
* by the auto-configuration.
@Bean
RestTemplate restTemplate(RestTemplateBuilder builder) throws Exception {
- char[] trustStorePassword = env.getProperty("server.ssl.trust-store-password").toCharArray();
- char[] keyStorePassword = env.getProperty("server.ssl.key-store-password").toCharArray();
-
- String keyStore = env.getProperty("server.ssl.key-store");
- String trustStore = env.getProperty("server.ssl.trust-store");
-
- SSLContextBuilder sslContextBuilder = SSLContextBuilder.create();
-
- if(env.acceptsProfiles("two-way-ssl")){
- sslContextBuilder = sslContextBuilder.loadKeyMaterial(loadPfx(keyStore, keyStorePassword), keyStorePassword);
- }
-
- SSLContext sslContext = sslContextBuilder
- .loadTrustMaterial(ResourceUtils.getFile(trustStore), trustStorePassword)
- .build();
+ SSLContext sslContext = SSLContext.getDefault();
HttpClient client = HttpClients.custom()
.setSSLContext(sslContext)
return restTemplate;
}
-
- private KeyStore loadPfx(String file, char[] password) throws Exception {
- KeyStore keyStore = KeyStore.getInstance("PKCS12");
- File key = ResourceUtils.getFile(file);
- try (InputStream in = new FileInputStream(key)) {
- keyStore.load(in, password);
- }
- return keyStore;
- }
}
import org.onap.aai.config.SpringContextAware;
import org.onap.aai.exceptions.AAIException;
-import org.onap.aai.restclient.PropertyPasswordConfiguration;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.actuate.autoconfigure.web.server.LocalManagementPort;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
@AutoConfigureMetrics
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
classes = {SpringContextAware.class, GraphAdminApp.class})
-@ContextConfiguration(initializers = PropertyPasswordConfiguration.class, classes = {SpringContextAware.class})
+@ContextConfiguration(classes = {SpringContextAware.class})
@EnableAutoConfiguration(exclude={CassandraDataAutoConfiguration.class, CassandraAutoConfiguration.class}) // there is no running cassandra instance for the test
@Import(GraphAdminTestConfiguration.class)
@TestPropertySource(locations = "classpath:application-test.properties")
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.jupiter.api.Assertions.*;
+import static org.junit.jupiter.api.Assertions.fail;
@TestMethodOrder(MethodName.class)
public class DataGroomingTest extends AAISetup {
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.jupiter.api.Assertions.*;
+import static org.junit.jupiter.api.Assertions.fail;
public class DupeToolTest extends AAISetup {
import org.onap.aai.dbmap.AAIGraph;
import org.onap.aai.exceptions.AAIException;
-import static org.junit.jupiter.api.Assertions.*;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
@TestMethodOrder(MethodName.class)
public class SchemaMod4HistTest extends AAISetup {
import org.onap.aai.AAISetup;
import org.onap.aai.dbmap.AAIGraph;
import org.onap.aai.exceptions.AAIException;
-import static org.junit.jupiter.api.Assertions.*;
+import static org.junit.jupiter.api.Assertions.fail;
@TestMethodOrder(MethodName.class)
public class SchemaModTest extends AAISetup {
*/
package org.onap.aai.migration.v12;
-import static org.junit.jupiter.api.Assertions.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
Vertex v2 = g.addV().property("aai-node-type", "l-interface")
.property("interface-name", "delcontains-test-lint")
.next();
- Edge e = v.addEdge("hasLInterface", v2, EdgeProperty.CONTAINS.toString(), AAIDirection.OUT.toString(),
+ Edge e = v.addEdge("hasLInterface", v2, EdgeProperty.CONTAINS.toString(), AAIDirection.OUT.toString(),
EdgeProperty.DELETE_OTHER_V.toString(), AAIDirection.NONE.toString());
-
+
Vertex v3 = g.addV().property("aai-node-type", "allotted-resource").next();
-
+
Edge e2 = v2.addEdge("uses", v3, EdgeProperty.CONTAINS.toString(), AAIDirection.NONE.toString(),
EdgeProperty.DELETE_OTHER_V.toString(), AAIDirection.NONE.toString());
TransactionalGraphEngine spy = spy(dbEngine);
migration = new ContainmentDeleteOtherVPropertyMigration(spy, loaderFactory, edgeIngestor, edgeSerializer, schemaVersions, "/edgeMigrationTestRules.json");
migration.run();
}
-
+
@AfterEach
public void cleanUp() {
tx.tx().rollback();
graph.close();
}
-
+
@Test
public void run() {
- assertEquals(true,
- g.E().hasLabel("hasLInterface").has(EdgeProperty.DELETE_OTHER_V.toString(), AAIDirection.OUT.toString()).hasNext(),
+ assertEquals(true,
+ g.E().hasLabel("hasLInterface").has(EdgeProperty.DELETE_OTHER_V.toString(), AAIDirection.OUT.toString()).hasNext(),
"del other now OUT");
- assertEquals(true,
- g.E().hasLabel("hasLInterface").has(EdgeProperty.CONTAINS.toString(), AAIDirection.OUT.toString()).hasNext(),
+ assertEquals(true,
+ g.E().hasLabel("hasLInterface").has(EdgeProperty.CONTAINS.toString(), AAIDirection.OUT.toString()).hasNext(),
"contains val still same");
assertEquals(true,
g.E().hasLabel("uses").has(EdgeProperty.DELETE_OTHER_V.toString(), AAIDirection.NONE.toString()).hasNext(),
.property("source-of-truth", "AAI-CSVP-INSTARAMS")
.next();
edgeSerializer.addTreeEdge(g, pnf1, pInterface1);
-
+
Vertex pnf2 = g.addV().property("aai-node-type", "pnf")
.property("pnf-name", "pnf-name2")
.next();
.next();
edgeSerializer.addTreeEdge(g, pnf2, pInterface2);
edgeSerializer.addEdge(g, pInterface2, pLink);
-
+
Vertex pnf3 = g.addV().property("aai-node-type", "pnf")
.property("pnf-name", "pnf-name3")
.next();
.next();
edgeSerializer.addTreeEdge(g, pnf3, pInterface3);
edgeSerializer.addTreeEdge(g, pInterface3, lInterface);
-
+
Vertex pnf4 = g.addV().property("aai-node-type", "pnf")
.property("pnf-name", "pnf-name4")
.next();
.property("interface-name", "interface-name4")
.next();
edgeSerializer.addTreeEdge(g, pnf4, pInterface4);
-
+
TransactionalGraphEngine spy = spy(dbEngine);
TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
GraphTraversalSource traversal = g;
public void test() {
assertEquals(false, g.V().has("aai-node-type", "pnf").has("pnf-name", "pnf-name1")
.in("tosca.relationships.network.BindsTo").has("aai-node-type", "p-interface").has("interface-name", "interface-name1").hasNext(), "pInterface1 deleted");
-
+
assertEquals(true, g.V().has("aai-node-type", "pnf").has("pnf-name", "pnf-name2")
.in("tosca.relationships.network.BindsTo").has("aai-node-type", "p-interface").hasNext(), "pInterface2 skipped");
-
+
assertEquals(true, g.V().has("aai-node-type", "pnf").has("pnf-name", "pnf-name3")
.in("tosca.relationships.network.BindsTo").has("aai-node-type", "p-interface").hasNext(), "pInterface3 skipped");
-
+
assertEquals(true, g.V().has("aai-node-type", "pnf").has("pnf-name", "pnf-name4")
.in("tosca.relationships.network.BindsTo").has("aai-node-type", "p-interface").has("interface-name", "interface-name4").hasNext(), "pInterface4 should not be deleted");
-
+
assertEquals(Status.SUCCESS, migration.getStatus(), "Status should be success");
}
dbEngine = new JanusGraphDBEngine(
queryStyle,
loader);
-
+
System.setProperty("BUNDLECONFIG_DIR", "src/test/resources");
Vertex genericvnf1 = g.addV().property("aai-node-type", "generic-vnf")
.property("vnf-id", "vnfId1")
loader);
System.setProperty("BUNDLECONFIG_DIR", "src/test/resources");
-
+
Vertex customer1 = g.addV()
.property("aai-node-type", "customer")
.property("global-customer-id", "customer-id-1")
.property("subscriber-type", "CUST")
.next();
-
+
Vertex servSub1 = g.addV()
.property("aai-node-type", "service-subscription")
.property("service-type", "SAREA")
.next();
-
+
Vertex servInstance1 = g.addV()
.property("aai-node-type", "service-instance")
.property("service-type", "SAREA")
.property("service-type", "SAREA")
.property("service-instance-id", "evc-name-2")
.next();
-
+
Vertex evc1 = g.addV().property("aai-node-type", "evc")
.property("evc-id", "evc-name-1")
.next();
.property("forwarder-evc-id", "evc-name-1-2")
.property("svlan", "16")
.next();
-
-
-
+
+
+
Vertex evc2 = g.addV().property("aai-node-type", "evc")
.property("evc-id", "evc-name-2")
.next();
.property("forwarder-evc-id", "evc-name-3-2")
// .property("svlan", "16")
.next();
-
+
// graph 1
edgeSerializer.addTreeEdge(g, customer1, servSub1);
edgeSerializer.addTreeEdge(g, servSub1, servInstance1);
edgeSerializer.addTreeEdge(g, servSub1, servInstance2);
edgeSerializer.addTreeEdge(g, servSub1, servInstance3);
-
+
edgeSerializer.addEdge(g, servInstance1, fp1);
edgeSerializer.addEdge(g, servInstance2, fp2);
-
+
edgeSerializer.addEdge(g, fp1, config1);
edgeSerializer.addEdge(g, fp2, config2);
edgeSerializer.addEdge(g, fp3, config3);
-
+
edgeSerializer.addTreeEdge(g, evc1, config1);
edgeSerializer.addTreeEdge(g, evc2, config2);
edgeSerializer.addTreeEdge(g, evc3, config3);
-
+
edgeSerializer.addTreeEdge(g, fp1, for11);
edgeSerializer.addTreeEdge(g, fp1, for12);
edgeSerializer.addTreeEdge(g, fp2, for21);
edgeSerializer.addTreeEdge(g, fp2, for24);
edgeSerializer.addTreeEdge(g, fp3, for31);
edgeSerializer.addTreeEdge(g, fp3, for32);
-
+
edgeSerializer.addEdge(g, for11, config11);
edgeSerializer.addEdge(g, for12, config12);
edgeSerializer.addEdge(g, for21, config21);
edgeSerializer.addEdge(g, for24, config24);
edgeSerializer.addEdge(g, for31, config31);
edgeSerializer.addEdge(g, for32, config32);
-
+
edgeSerializer.addTreeEdge(g, config11, fevc11);
edgeSerializer.addTreeEdge(g, config12, fevc12);
edgeSerializer.addTreeEdge(g, config21, fevc21);
edgeSerializer.addTreeEdge(g, config24, fevc24);
edgeSerializer.addTreeEdge(g, config31, fevc31);
edgeSerializer.addTreeEdge(g, config32, fevc32);
-
+
TransactionalGraphEngine spy = spy(dbEngine);
TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
when(spy.asAdmin()).thenReturn(adminSpy);
when(adminSpy.getTraversalSource()).thenReturn(traversal);
when(adminSpy.getReadOnlyTraversalSource()).thenReturn(readOnly);
-
+
migration = new MigrateHUBEvcInventory(spy, loaderFactory, edgeIngestor, edgeSerializer, schemaVersions);
migration.run();
}
-
+
@AfterEach
public void cleanUp() {
tx.tx().rollback();
graph.close();
}
-
+
@Test
public void testRun_checkFevc1AndFevc2AreUpdated() throws Exception {
-
+
// check if forwarder-evc nodes get updated
- assertEquals(true,
+ assertEquals(true,
g.V().has("aai-node-type", "forwarder-evc")
.has("forwarder-evc-id", "evc-name-1-1")
.has("ivlan","4054")
- .hasNext(),
+ .hasNext(),
"forwarder-evc evc-name-1-1 updated with ivlan");
-
- assertEquals(true,
+
+ assertEquals(true,
g.V().has("aai-node-type", "forwarder-evc")
.has("forwarder-evc-id", "evc-name-2-2")
.has("ivlan","4084")
- .hasNext(),
+ .hasNext(),
"forwarder-evc evc-name-2-2 updated with ivlan");
- assertEquals(true,
+ assertEquals(true,
g.V().has("aai-node-type", "forwarder-evc")
.has("forwarder-evc-id", "evc-name-2-3")
.has("ivlan","4054")
- .hasNext(),
+ .hasNext(),
"forwarder-evc evc-name-2-3 updated with ivlan");
-
- assertEquals(new Long(4L),
+
+ assertEquals(new Long(4L),
g.V().has("forwarding-path-id", "evc-name-2")
.in("org.onap.relationships.inventory.BelongsTo").has("aai-node-type", "forwarder")
.out("org.onap.relationships.inventory.Uses").has("aai-node-type", "configuration")
.in("org.onap.relationships.inventory.BelongsTo").has("aai-node-type", "forwarder-evc")
- .count().next(),
+ .count().next(),
"4 forwarder-evcs exist for evc evc-name-2");
-
- assertEquals(new Long(3L),
+
+ assertEquals(new Long(3L),
g.V().has("forwarding-path-id", "evc-name-2")
.in("org.onap.relationships.inventory.BelongsTo").has("aai-node-type", "forwarder")
.out("org.onap.relationships.inventory.Uses").has("aai-node-type", "configuration")
.in("org.onap.relationships.inventory.BelongsTo").has("aai-node-type", "forwarder-evc")
.has("forwarder-evc-id").has("ivlan")
- .count().next(),
+ .count().next(),
"3 forwarder-evcs updated for evc evc-name-2");
-
- assertEquals(false,
+
+ assertEquals(false,
g.V().has("aai-node-type", "forwarder-evc")
.has("forwarder-evc-id", "evc-name-3-1")
.has("ivlan")
- .hasNext(),
+ .hasNext(),
"forwarder-evc evc-name-3-1 updated with ivlan");
}
-
+
@Test
public void testGetAffectedNodeTypes() {
Optional<String[]> types = migration.getAffectedNodeTypes();
Optional<String[]> expected = Optional.of(new String[]{"forwarder-evc"});
-
+
assertNotNull(types);
assertArrayEquals(expected.get(), types.get());
}
loader);
System.setProperty("BUNDLECONFIG_DIR", "src/test/resources");
-
-
+
+
Vertex pnf1 = g.addV()
.property("aai-node-type", "pnf")
.property("pnf-name", "pnf-name-1")
.property("aai-uri", "/network/pnfs/pnf/pnf-name-1/p-interfaces/pinterface/1.1")
.next();
// graph 1
-
+
edgeSerializer.addTreeEdge(g, pnf1, port11);
when(spy.asAdmin()).thenReturn(adminSpy);
when(adminSpy.getTraversalSource()).thenReturn(traversal);
when(adminSpy.getReadOnlyTraversalSource()).thenReturn(readOnly);
-
+
migration = new MigrateINVPhysicalInventory(spy, loaderFactory, edgeIngestor, edgeSerializer, schemaVersions);
migration.run();
}
-
+
@AfterEach
public void cleanUp() {
tx.tx().rollback();
@Test
public void testRun_checkPnfsAndPInterfacesExist() throws Exception {
// check if graph nodes exist
-
+
// check if pnf node gets created
- assertEquals(new Long(2L),
+ assertEquals(new Long(2L),
g.V().has("aai-node-type", "pnf")
- .count().next(),
+ .count().next(),
"2 PNFs exist");
-
+
System.out.println("cOUNT:" +g.V().has("aai-node-type", "pnf")
.has("pnf-name", "pnf-name-collector-1").in("tosca.relationships.network.BindsTo").count().next());
-
+
assertEquals(new Long(1L),
g.V().has("aai-node-type", "pnf")
.has("pnf-name", "pnf-name-collector-1").count().next(),
"p-interfaces created for pnfs");
-
+
assertEquals(true,
g.V().has("aai-node-type", "pnf")
.has("pnf-name", "pnf-name-collector-1")
.in("tosca.relationships.network.BindsTo").count().next(),
"p-interfaces created for pnfs");
}
-
+
@Test
public void testGetAffectedNodeTypes() {
Optional<String[]> types = migration.getAffectedNodeTypes();
Optional<String[]> expected = Optional.of(new String[]{"pnf"});
-
+
assertNotNull(types);
assertArrayEquals(expected.get(), types.get());
}
loader);
System.setProperty("BUNDLECONFIG_DIR", "src/test/resources");
-
+
Vertex evc = g.addV()
.property("aai-node-type", "evc")
.property("evc-id", "evc-name-1")
.next();
-
+
Vertex evc2 = g.addV()
.property("aai-node-type", "evc")
.property("evc-id", "evc-name-2")
.next();
-
+
TransactionalGraphEngine spy = spy(dbEngine);
TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
when(spy.asAdmin()).thenReturn(adminSpy);
when(adminSpy.getTraversalSource()).thenReturn(traversal);
when(adminSpy.getReadOnlyTraversalSource()).thenReturn(readOnly);
-
+
migration = new MigrateINVEvcInventory(spy, loaderFactory, edgeIngestor, edgeSerializer, schemaVersions);
migration.run();
}
-
+
@AfterEach
public void cleanUp() {
tx.tx().rollback();
graph.close();
}
-
+
@Test
public void testRun_updateEvcNode() throws Exception {
// check if graph nodes exist
- assertEquals(true,
+ assertEquals(true,
g.V().has("aai-node-type", "evc")
.has("evc-id", "evc-name-1")
- .hasNext(),
+ .hasNext(),
"evc node exists");
-
+
// check if evc object is updated to set the value for inter-connect-type-ingress
- assertEquals(true,
+ assertEquals(true,
g.V().has("aai-node-type", "evc").has("evc-id", "evc-name-1")
.has("inter-connect-type-ingress", "SHARED")
- .hasNext(),
+ .hasNext(),
"evc is updated");
}
-
+
@Test
public void testRun_evcNotCreated() throws Exception {
-
- assertEquals(false,
+
+ assertEquals(false,
g.V().has("aai-node-type", "evc").has("evc-id", "evc-name-3")
- .hasNext(),
+ .hasNext(),
"evc node does not exist");
-
+
//inter-connect-type-ingress is not present on the evc
- assertEquals(true,
+ assertEquals(true,
g.V().has("aai-node-type", "evc").has("evc-id", "evc-name-2")
- .hasNext(),
+ .hasNext(),
"evc node exists");
- assertEquals(false,
+ assertEquals(false,
g.V().has("aai-node-type", "evc").has("evc-id", "evc-name-2").has("inter-connect-type-ingress")
- .hasNext(),
+ .hasNext(),
"evc node not updated with inter-connect-type-ingress");
-
+
}
@Test
public void testGetAffectedNodeTypes() {
Optional<String[]> types = migration.getAffectedNodeTypes();
Optional<String[]> expected = Optional.of(new String[]{"evc"});
-
+
assertNotNull(types);
assertArrayEquals(expected.get(), types.get());
}
import org.junit.jupiter.api.Test;
import org.onap.aai.AAISetup;
-import org.onap.aai.dbmap.DBConnectionType;
import org.onap.aai.introspection.Loader;
import org.onap.aai.introspection.ModelType;
import org.onap.aai.setup.SchemaVersions;
-import org.onap.aai.setup.SchemaVersion;
import org.onap.aai.serialization.engines.QueryStyle;
import org.onap.aai.serialization.engines.JanusGraphDBEngine;
import org.onap.aai.serialization.engines.TransactionalGraphEngine;
loader);
System.setProperty("BUNDLECONFIG_DIR", "src/test/resources");
-
+
Vertex customer1 = g.addV()
.property("aai-node-type", "customer")
.property("global-customer-id", "8a00890a-e6ae-446b-9dbe-b828dbeb38bd")
.property("subscriber-type", "CUST")
.next();
-
+
Vertex servSub1 = g.addV()
.property("aai-node-type", "service-subscription")
.property("service-type", "SAREA")
.next();
-
+
Vertex servInst1 = g.addV()
.property("aai-node-type", "service-instance")
.property("service-instance-id", "evc-name-1")
.next();
-
+
Vertex customer2 = g.addV()
.property("aai-node-type", "customer")
.property("global-customer-id", "cust-1")
.property("subscriber-type", "CUST")
.next();
-
+
Vertex servSub2 = g.addV()
.property("aai-node-type", "service-subscription")
.property("service-type", "SAREA")
.next();
-
+
Vertex servInst2 = g.addV()
.property("aai-node-type", "service-instance")
.property("service-instance-id", "evc-name-1")
.next();
-
+
Vertex collectorPnf = g.addV()
.property("aai-node-type", "pnf")
.property("pnf-name", "pnf-name-collector-1")
.next();
-
+
Vertex bearerPnf = g.addV()
.property("aai-node-type", "pnf")
.property("pnf-name", "pnf-name-bearer-1")
.next();
-
+
Vertex collectorPort = g.addV()
.property("aai-node-type", "p-interface")
.property("interface-name", "p-int-collector-1")
.next();
-
+
Vertex bearerPort = g.addV()
.property("aai-node-type", "p-interface")
.property("interface-name", "p-int-bearer-1")
.next();
-
+
Vertex servInst4 = g.addV()
.property("aai-node-type", "service-instance")
.property("service-instance-id", "evc-name-4")
when(spy.asAdmin()).thenReturn(adminSpy);
when(adminSpy.getTraversalSource()).thenReturn(traversal);
when(adminSpy.getReadOnlyTraversalSource()).thenReturn(readOnly);
-
+
migration = new MigrateSAREvcInventory(spy, loaderFactory, edgeIngestor, edgeSerializer, schemaVersions);
migration.run();
}
-
+
@AfterEach
public void cleanUp() {
tx.tx().rollback();
@Test
public void testRun_createServiceInstanceNode() throws Exception {
// check if graph nodes exist
- assertEquals(true,
+ assertEquals(true,
g.V().has("service-instance-id", "evc-name-1")
- .hasNext(),
+ .hasNext(),
"service instance node exists");
-
+
// check if service-instance node gets created
- assertEquals(true,
+ assertEquals(true,
g.V().has("service-instance-id", "evc-name-1")
.out("org.onap.relationships.inventory.BelongsTo").has("service-type", "SAREA")
- .hasNext(),
+ .hasNext(),
"service subscription node, service-type=SAREA");
-
-
-
+
+
+
// check if fowarding-path node gets created
assertEquals(true, g.V().has("forwarding-path-id", "evc-name-1")
.has("forwarding-path-name", "evc-name-1").hasNext(), "fowarding-path is created");
-
- assertEquals(true,
+
+ assertEquals(true,
g.V().has("global-customer-id", "8a00890a-e6ae-446b-9dbe-b828dbeb38bd")
.in("org.onap.relationships.inventory.BelongsTo").has("service-type", "SAREA")
.in("org.onap.relationships.inventory.BelongsTo").has("service-instance-id", "evc-name-1")
.has("aai-node-type", "forwarding-path")
.has("forwarding-path-id", "evc-name-1")
.has("forwarding-path-name", "evc-name-1")
- .hasNext(),
+ .hasNext(),
"fowarding-path node exists");
-
+
// check if configuration node gets created
assertEquals(true,
g.V().has("global-customer-id", "8a00890a-e6ae-446b-9dbe-b828dbeb38bd")
.has("configuration-sub-type", "evc")
.hasNext(),
"configuration node, configuration-type= forwarding-path");
-
+
//check if evc node gets created
- assertEquals(true,
+ assertEquals(true,
g.V().has("global-customer-id", "8a00890a-e6ae-446b-9dbe-b828dbeb38bd")
.in("org.onap.relationships.inventory.BelongsTo").has("service-type", "SAREA")
.in("org.onap.relationships.inventory.BelongsTo").has("service-instance-id", "evc-name-1")
.in("org.onap.relationships.inventory.AppliesTo").has("aai-node-type", "forwarding-path")
.out("org.onap.relationships.inventory.Uses").has("aai-node-type", "configuration")
.in("org.onap.relationships.inventory.BelongsTo").has("aai-node-type", "evc")
- .hasNext(),
+ .hasNext(),
"evc is created");
-
+
// check if evc node gets created
- assertEquals(true,
+ assertEquals(true,
g.V().has("global-customer-id", "8a00890a-e6ae-446b-9dbe-b828dbeb38bd")
.in("org.onap.relationships.inventory.BelongsTo").has("service-type", "SAREA")
.in("org.onap.relationships.inventory.BelongsTo").has("service-instance-id", "evc-name-1")
.has("cir-units", "Mbps")
.has("tagmode-access-ingress", "DOUBLE")
.has("tagmode-access-egress", "DOUBLE")
- .hasNext(),
+ .hasNext(),
"configuration node, configuration-type= evc");
}
@Test
public void testRun_evcNotCreated() throws Exception {
// check if graph nodes exist
- assertEquals(true,
+ assertEquals(true,
g.V().has("global-customer-id", "8a00890a-e6ae-446b-9dbe-b828dbeb38bd")
- .hasNext(),
+ .hasNext(),
"customer node exists");
-
- assertEquals(true,
+
+ assertEquals(true,
g.V().has("global-customer-id", "8a00890a-e6ae-446b-9dbe-b828dbeb38bd")
.in("org.onap.relationships.inventory.BelongsTo").has("service-type", "SAREA")
- .hasNext(),
+ .hasNext(),
"service subscription node, service-type=SAREA");
-
+
//service-instance should not be created
- assertEquals(false,
+ assertEquals(false,
g.V().has("global-customer-id", "8a00890a-e6ae-446b-9dbe-b828dbeb38bd")
.in("org.onap.relationships.inventory.BelongsTo").has("service-type", "SAREA")
.in("org.onap.relationships.inventory.BelongsTo").has("service-instance-id", "evc-name-2")
- .hasNext(),
+ .hasNext(),
"service instance node created");
-
- assertEquals(true,
+
+ assertEquals(true,
g.V().has("global-customer-id", "cust-1")
.in("org.onap.relationships.inventory.BelongsTo").has("service-type", "SAREA")
.in("org.onap.relationships.inventory.BelongsTo").has("service-instance-id", "evc-name-1")
- .hasNext(),
+ .hasNext(),
"service instance node already exists");
-
+
// fowarding-path node should not be created
assertEquals(false, g.V().has("aai-node-type", "forwarding-path")
.has("forwarding-path-name", "evc-name-2").hasNext(), "fowarding-path created");
-
+
// configuration node should not be created
assertEquals(false, g.V().has("aai-node-type", "configuration")
.has("configuration-id", "evc-name-2").hasNext(), "configuration node created");
-
+
// evc node should not be created
assertEquals(false, g.V().has("aai-node-type", "evc")
.has("evc-id", "evc-name-2").hasNext(), "evc node created");
-
+
// service-instance is not created because pnf exists, but p-interface does not
- assertEquals(false,
+ assertEquals(false,
g.V().has("global-customer-id", "8a00890a-e6ae-446b-9dbe-b828dbeb38bd")
.in("org.onap.relationships.inventory.BelongsTo").has("service-type", "SAREA")
.in("org.onap.relationships.inventory.BelongsTo").has("service-instance-id", "evc-name-3")
- .hasNext(),
+ .hasNext(),
"service instance node created");
}
@Test
public void testRun_createFPConfigurationEvcNode4() throws Exception {
// check if graph nodes exist
- assertEquals(true,
+ assertEquals(true,
g.V().has("service-instance-id", "evc-name-4")
- .hasNext(),
+ .hasNext(),
"service instance node exists");
-
+
// check if service-instance node gets created
- assertEquals(true,
+ assertEquals(true,
g.V().has("service-instance-id", "evc-name-4")
.out("org.onap.relationships.inventory.BelongsTo").has("service-type", "SAREA")
- .hasNext(),
+ .hasNext(),
"service subscription node, service-type=SAREA");
-
-
-
+
+
+
// check if fowarding-path node gets created
assertEquals(true, g.V().has("forwarding-path-id", "evc-name-4")
.has("forwarding-path-name", "evc-name-4").hasNext(), "fowarding-path is created");
-
- assertEquals(true,
+
+ assertEquals(true,
g.V().has("global-customer-id", "8a00890a-e6ae-446b-9dbe-b828dbeb38bd")
.in("org.onap.relationships.inventory.BelongsTo").has("service-type", "SAREA")
.in("org.onap.relationships.inventory.BelongsTo").has("service-instance-id", "evc-name-4")
.has("aai-node-type", "forwarding-path")
.has("forwarding-path-id", "evc-name-4")
.has("forwarding-path-name", "evc-name-4")
- .hasNext(),
+ .hasNext(),
"fowarding-path node exists");
-
+
// check if configuration node gets created
assertEquals(true,
g.V().has("global-customer-id", "8a00890a-e6ae-446b-9dbe-b828dbeb38bd")
.has("configuration-sub-type", "evc")
.hasNext(),
"configuration node, configuration-type= forwarding-path");
-
+
//check if evc node gets created
- assertEquals(true,
+ assertEquals(true,
g.V().has("global-customer-id", "8a00890a-e6ae-446b-9dbe-b828dbeb38bd")
.in("org.onap.relationships.inventory.BelongsTo").has("service-type", "SAREA")
.in("org.onap.relationships.inventory.BelongsTo").has("service-instance-id", "evc-name-4")
.in("org.onap.relationships.inventory.AppliesTo").has("aai-node-type", "forwarding-path")
.out("org.onap.relationships.inventory.Uses").has("aai-node-type", "configuration")
.in("org.onap.relationships.inventory.BelongsTo").has("aai-node-type", "evc")
- .hasNext(),
+ .hasNext(),
"evc is created");
-
+
// check if evc node gets created
- assertEquals(true,
+ assertEquals(true,
g.V().has("global-customer-id", "8a00890a-e6ae-446b-9dbe-b828dbeb38bd")
.in("org.onap.relationships.inventory.BelongsTo").has("service-type", "SAREA")
.in("org.onap.relationships.inventory.BelongsTo").has("service-instance-id", "evc-name-1")
.has("cir-units", "Mbps")
.has("tagmode-access-ingress", "DOUBLE")
.has("tagmode-access-egress", "DOUBLE")
- .hasNext(),
+ .hasNext(),
"configuration node, configuration-type= evc");
}
-
+
@Test
public void testGetAffectedNodeTypes() {
Optional<String[]> types = migration.getAffectedNodeTypes();
Optional<String[]> expected = Optional.of(new String[]{"service-instance"});
-
+
assertNotNull(types);
assertArrayEquals(expected.get(), types.get());
}
migration.seen.add(pInterface3.id());
assertEquals(Collections.EMPTY_SET, migration.getChildren(lInterface3));
}
-}
\ No newline at end of file
+}
*/
package org.onap.aai.migration.v13;
-import static org.junit.jupiter.api.Assertions.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
}
private void createFirstVertexAndRelatedVertexes() throws AAIException {
-
+
// Add model1/model-ver1 -- invalid model/model-ver
Vertex model1 = g.addV().property("aai-node-type", "model")
.property("model-invariant-id", "model-invariant-id-1").property("model-type", "widget").next();
modelVer1 = g.addV().property("aai-node-type", "model-ver").property("model-version-id", "model-version-id-1")
.property("model-name", "connector").property("model-version", "v1.0").next();
edgeSerializer.addTreeEdge(g, model1, modelVer1);
-
+
// Add named-query and named-query-element nodes. Point the named-query-element at model1
Vertex namedQ1 = g.addV().property("aai-node-type", "named-query")
.property("named-query-uuid", "named-query-uuid-1").property("named-query-name", "test-NQ-1").next();
assertEquals(true,
g.V().has("aai-node-type", "named-query-element").has("named-query-element-uuid", "named-query-element-uuid-1")
.out("org.onap.relationships.inventory.BelongsTo")
- .has("named-query-uuid", "named-query-uuid-1").hasNext());
+ .has("named-query-uuid", "named-query-uuid-1").hasNext());
}
-
+
@Test
public void testBadNodesAreNotGone() {
assertEquals(true,
assertEquals(true,
g.V().has("aai-node-type", "model").has("model-invariant-id", "model-invariant-id-1").hasNext());
}
-
+
@Test
public void testNQNodesaAreStillThere() {
assertEquals(true,
g.V().has("aai-node-type", "named-query").has("named-query-uuid", "named-query-uuid-1").hasNext());
assertEquals(true,
g.V().has("aai-node-type", "named-query-element").has("named-query-element-uuid", "named-query-element-uuid-1").hasNext());
-
+
}
-
+
@Test
public void testThatNewEdgeAdded() {
.in("org.onap.relationships.inventory.IsA").has("named-query-element-uuid", "named-query-element-uuid-1")
.hasNext());
}
-
-
-}
\ No newline at end of file
+
+
+}
*/
package org.onap.aai.migration.v13;
-import static org.junit.jupiter.api.Assertions.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
.out("org.onap.relationships.inventory.BelongsTo").has("model-version-id", "model-version-id-2")
.hasNext());
}
-
+
@Test
public void testBadVerNodeIsGoneX() {
assertEquals(false,
g.V().has("aai-node-type", "model-ver").has("model-version-id", "model-version-id-1").hasNext());
}
-
+
@Test
public void testBadModelNodeIsGoneX() {
assertEquals(false,
.hasNext());
}
-}
\ No newline at end of file
+}
g.addV().property("aai-node-type", "vserver")\r
.property("vserver-id", "vserver3")\r
.property("is-closed-loop-disabled", false)\r
- .next(); \r
+ .next();\r
//l3-network\r
g.addV().property("aai-node-type", "l3-network")\r
.property("network-id", "l3-network0")\r
.property("is-provider-network", false)\r
.property("is-shared-network", false)\r
.property("is-external-network", false)\r
- .next(); \r
+ .next();\r
//subnet\r
g.addV().property("aai-node-type", "subnet")\r
.property("subnet-id", "subnet0")\r
.property("in-maint", false)\r
.property("is-port-mirrored", false)\r
.property("is-ip-unnumbered", false)\r
- .next(); \r
+ .next();\r
//vf-module\r
g.addV().property("aai-node-type", "vf-module")\r
.property("vf-module-id", "vf-module0")\r
.next();\r
g.addV().property("aai-node-type", "vf-module")\r
.property("vf-module-id", "vf-module3")\r
- .property("is-base-vf-module", false) \r
- .next(); \r
- \r
+ .property("is-base-vf-module", false)\r
+ .next();\r
+\r
//vlan\r
g.addV().property("aai-node-type", "vlan")\r
.property("vlan-interface", "vlan0")\r
.next();\r
g.addV().property("aai-node-type", "vlan")\r
.property("vlan-interface", "vlan3")\r
- .property("is-ip-unnumbered", false) \r
+ .property("is-ip-unnumbered", false)\r
.next();\r
- \r
+\r
TransactionalGraphEngine spy = spy(dbEngine);\r
TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());\r
GraphTraversalSource traversal = g;\r
when(adminSpy.getTraversalSource()).thenReturn(traversal);\r
migration = new BooleanDefaultMigrator(spy, loaderFactory, edgeIngestor, edgeSerializer, schemaVersions);\r
migration.run();\r
- \r
+\r
}\r
\r
@Test\r
"Value of subnet should be updated since the property dhcp-enabled doesn't exist");\r
//l3-network: is-bound-to-vpn, is-shared-network, is-external-network\r
assertTrue(g.V().has("aai-node-type", "l3-network").has("network-id", "l3-network0").has("network-name", "l3-network-name0").has("is-bound-to-vpn", false).hasNext(),\r
- "Value of l3-network should be updated since the property is-bound-to-vpn doesn't exist"); \r
+ "Value of l3-network should be updated since the property is-bound-to-vpn doesn't exist");\r
assertTrue(g.V().has("aai-node-type", "l3-network").has("network-id", "l3-network0").has("network-name", "l3-network-name0").has("is-provider-network", false).hasNext(),\r
- "Value of l3-network should be updated since the property is-provider-network doesn't exist"); \r
+ "Value of l3-network should be updated since the property is-provider-network doesn't exist");\r
assertTrue(g.V().has("aai-node-type", "l3-network").has("network-id", "l3-network0").has("network-name", "l3-network-name0").has("is-shared-network", false).hasNext(),\r
- "Value of l3-network should be updated since the property is-shared-network doesn't exist"); \r
+ "Value of l3-network should be updated since the property is-shared-network doesn't exist");\r
assertTrue(g.V().has("aai-node-type", "l3-network").has("network-id", "l3-network0").has("network-name", "l3-network-name0").has("is-external-network", false).hasNext(),\r
- "Value of l3-network should be updated since the property is-external-network doesn't exist"); \r
+ "Value of l3-network should be updated since the property is-external-network doesn't exist");\r
//l-interface: is-port-mirrored, is-ip-unnumbered\r
assertTrue(g.V().has("aai-node-type", "l-interface").has("interface-name", "l-interface0").has("is-port-mirrored", false).hasNext(),\r
- "Value of l-interface should be updated since the property is-port-mirrored doesn't exist"); \r
+ "Value of l-interface should be updated since the property is-port-mirrored doesn't exist");\r
assertTrue(g.V().has("aai-node-type", "l-interface").has("interface-name", "l-interface0").has("is-ip-unnumbered", false).hasNext(),\r
"Value of l-interface should be updated since the property is-ip-unnumbered doesn't exist");\r
//vf-module: is-base-vf-module\r
assertTrue(g.V().has("aai-node-type", "vf-module").has("vf-module-id", "vf-module0").has("is-base-vf-module", false).hasNext(),\r
- "Value of vf-module should be updated since the property is-base-vf-module doesn't exist"); \r
+ "Value of vf-module should be updated since the property is-base-vf-module doesn't exist");\r
//vlan: is-ip-unnumbered\r
assertTrue(g.V().has("aai-node-type", "vlan").has("vlan-interface", "vlan0").has("is-ip-unnumbered", false).hasNext(),\r
"Value of vlan should be updated since the property is-ip-unnumbered doesn't exist");\r
}\r
\r
@Test\r
- public void testEmptyValue() { \r
+ public void testEmptyValue() {\r
//is-closed-loop-disabled\r
assertTrue(g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "generic-vnf1").has("is-closed-loop-disabled", false).hasNext(),\r
"Value of generic-vnf should be updated since the value for is-closed-loop-disabled is an empty string");\r
"Value of subnet should be updated since the value for dhcp-enabled is an empty string");\r
//l3-network: is-bound-to-vpn, is-shared-network, is-external-network\r
assertTrue(g.V().has("aai-node-type", "l3-network").has("network-id", "l3-network1").has("network-name", "l3-network-name1").has("is-bound-to-vpn", false).hasNext(),\r
- "Value of l3-network should be updated since the value for is-bound-to-vpn is an empty string"); \r
+ "Value of l3-network should be updated since the value for is-bound-to-vpn is an empty string");\r
assertTrue(g.V().has("aai-node-type", "l3-network").has("network-id", "l3-network1").has("network-name", "l3-network-name1").has("is-provider-network", false).hasNext(),\r
- "Value of l3-network should be updated since the value for is-provider-network is an empty string"); \r
+ "Value of l3-network should be updated since the value for is-provider-network is an empty string");\r
assertTrue(g.V().has("aai-node-type", "l3-network").has("network-id", "l3-network1").has("network-name", "l3-network-name1").has("is-shared-network", false).hasNext(),\r
"Value of l3-network should be updated since the value for is-shared-network is an empty string");\r
assertTrue(g.V().has("aai-node-type", "l3-network").has("network-id", "l3-network1").has("network-name", "l3-network-name1").has("is-external-network", false).hasNext(),\r
"Value of l3-network should be updated since the value for is-external-network is an empty string");\r
//l-interface: is-port-mirrored, is-ip-unnumbered\r
assertTrue(g.V().has("aai-node-type", "l-interface").has("interface-name", "l-interface1").has("is-port-mirrored", false).hasNext(),\r
- "Value of l-interface should be updated since the property is-port-mirrored is an empty string"); \r
+ "Value of l-interface should be updated since the property is-port-mirrored is an empty string");\r
assertTrue(g.V().has("aai-node-type", "l-interface").has("interface-name", "l-interface1").has("is-ip-unnumbered", false).hasNext(),\r
"Value of l-interface should be updated since the property is-ip-unnumbered is an empty string");\r
//vf-module: is-base-vf-module, is-ip-unnumbered\r
assertTrue(g.V().has("aai-node-type", "vf-module").has("vf-module-id", "vf-module1").has("is-base-vf-module", false).hasNext(),\r
- "Value of vf-module should be updated since the property is-base-vf-module is an empty string"); \r
+ "Value of vf-module should be updated since the property is-base-vf-module is an empty string");\r
//vlan: is-ip-unnumbered\r
assertTrue(g.V().has("aai-node-type", "vlan").has("vlan-interface", "vlan1").has("is-ip-unnumbered", false).hasNext(),\r
"Value of vlan should be updated since the property is-ip-unnumbered is an empty string");\r
}\r
- \r
+\r
@Test\r
public void testExistingTrueValues() {\r
//is-closed-loop-disabled\r
"Value of vserver shouldn't be update since is-closed-loop-disabled already exists");\r
//dhcp-enabled\r
assertTrue(g.V().has("aai-node-type", "subnet").has("subnet-id", "subnet2").has("dhcp-enabled", true).hasNext(),\r
- "Value of subnet shouldn't be update since dhcp-enabled already exists"); \r
+ "Value of subnet shouldn't be update since dhcp-enabled already exists");\r
//l3-network: is-bound-to-vpn, is-shared-network, is-external-network\r
assertTrue(g.V().has("aai-node-type", "l3-network").has("network-id", "l3-network2").has("network-name", "l3-network-name2").has("is-bound-to-vpn", true).hasNext(),\r
"Value of l3-network shouldn't be updated since is-bound-to-vpn already exists");\r
assertTrue(g.V().has("aai-node-type", "l3-network").has("network-id", "l3-network2").has("network-name", "l3-network-name2").has("is-shared-network", true).hasNext(),\r
"Value of l3-network shouldn't be updated since is-shared-network already exists");\r
assertTrue(g.V().has("aai-node-type", "l3-network").has("network-id", "l3-network2").has("network-name", "l3-network-name2").has("is-external-network", true).hasNext(),\r
- "Value of l3-network shouldn't be updated since is-external-network already exists"); \r
+ "Value of l3-network shouldn't be updated since is-external-network already exists");\r
//l-interface: is-port-mirrored, is-ip-unnumbered\r
assertTrue(g.V().has("aai-node-type", "l-interface").has("interface-name", "l-interface2").has("is-port-mirrored", true).hasNext(),\r
- "Value of l-interface shouldn't be updated since is-port-mirrored already exists"); \r
+ "Value of l-interface shouldn't be updated since is-port-mirrored already exists");\r
assertTrue(g.V().has("aai-node-type", "l-interface").has("interface-name", "l-interface2").has("is-ip-unnumbered", true).hasNext(),\r
- "Value of ll-interface shouldn't be updated since is-ip-unnumbered already exists"); \r
+ "Value of ll-interface shouldn't be updated since is-ip-unnumbered already exists");\r
//vf-module: is-base-vf-module\r
assertTrue(g.V().has("aai-node-type", "vf-module").has("vf-module-id", "vf-module2").has("is-base-vf-module", true).hasNext(),\r
- "Value of vf-module shouldn't be updated since is-base-vf-module already exists"); \r
+ "Value of vf-module shouldn't be updated since is-base-vf-module already exists");\r
//vlan: is-ip-unnumbered\r
assertTrue(g.V().has("aai-node-type", "vlan").has("vlan-interface", "vlan2").has("is-ip-unnumbered", true).hasNext(),\r
"Value of vlan shouldn't be updated since is-ip-unnumbered already exists");\r
- \r
+\r
}\r
- \r
+\r
@Test\r
public void testExistingFalseValues() {\r
//is-closed-loop-disabled\r
"Value of subnet shouldn't be update since dhcp-enabled already exists");\r
//l3-network: is-bound-to-vpn, is-shared-network, is-external-network\r
assertTrue(g.V().has("aai-node-type", "l3-network").has("network-id", "l3-network3").has("network-name", "l3-network-name3").has("is-bound-to-vpn", false).hasNext(),\r
- "Value of l3-network shouldn't be updated since is-bound-to-vpn already exists"); \r
+ "Value of l3-network shouldn't be updated since is-bound-to-vpn already exists");\r
assertTrue(g.V().has("aai-node-type", "l3-network").has("network-id", "l3-network3").has("network-name", "l3-network-name3").has("is-provider-network", false).hasNext(),\r
- "Value of l3-network shouldn't be updated since is-provider-network already exists"); \r
+ "Value of l3-network shouldn't be updated since is-provider-network already exists");\r
assertTrue(g.V().has("aai-node-type", "l3-network").has("network-id", "l3-network3").has("network-name", "l3-network-name3").has("is-shared-network", false).hasNext(),\r
"Value of l3-network shouldn't be updated since is-shared-network already exists");\r
assertTrue(g.V().has("aai-node-type", "l3-network").has("network-id", "l3-network3").has("network-name", "l3-network-name3").has("is-external-network", false).hasNext(),\r
- "Value of l3-network shouldn't be updated since is-external-network already exists"); \r
+ "Value of l3-network shouldn't be updated since is-external-network already exists");\r
//l-interface: is-port-mirrored, is-ip-unnumbered\r
assertTrue(g.V().has("aai-node-type", "l-interface").has("interface-name", "l-interface3").has("is-port-mirrored", false).hasNext(),\r
- "Value of l-interface shouldn't be updated since is-port-mirrored already exists"); \r
+ "Value of l-interface shouldn't be updated since is-port-mirrored already exists");\r
assertTrue(g.V().has("aai-node-type", "l-interface").has("interface-name", "l-interface3").has("is-ip-unnumbered", false).hasNext(),\r
- "Value of ll-interface shouldn't be updated since is-ip-unnumbered already exists"); \r
+ "Value of ll-interface shouldn't be updated since is-ip-unnumbered already exists");\r
//vf-module: is-base-vf-module\r
assertTrue(g.V().has("aai-node-type", "vf-module").has("vf-module-id", "vf-module3").has("is-base-vf-module", false).hasNext(),\r
- "Value of vf-module shouldn't be updated since is-base-vf-module already exists"); \r
+ "Value of vf-module shouldn't be updated since is-base-vf-module already exists");\r
//vlan: is-ip-unnumbered\r
assertTrue(g.V().has("aai-node-type", "vlan").has("vlan-interface", "vlan3").has("is-ip-unnumbered", false).hasNext(),\r
"Value of vlan shouldn't be updated since is-ip-unnumbered already exists");\r
- } \r
-}
\ No newline at end of file
+ }\r
+}\r
dbEngine = new JanusGraphDBEngine(
queryStyle,
loader);
-
+
System.setProperty("BUNDLECONFIG_DIR", "src/test/resources");
Vertex pnf1 = g.addV().property("aai-node-type", "pnf").property("pnf-name", "pnf-1").next();
.property("forwarder-role", "ingress").next();
Vertex forwarder5 = g.addV().property("aai-node-type", "forwarder").property("sequence", 1)
.property("forwarder-role", "ingress").next();
-
-
+
+
Vertex configuration1 = g.addV().property("aai-node-type", "configuration").property("configuration-id", "config-1")
.property("configuration-type", "test").property("configuration-subt-type", "test").next();
Vertex configuration2 = g.addV().property("aai-node-type", "configuration").property("configuration-id", "config-2")
Vertex forwarderEvc4 = g.addV().property("aai-node-type", "forwarder-evc").property("forwarder-evc-id", "evc-4")
.property("circuit-id", "3").property("resource-version", "v13").next();
Vertex forwarderEvc5 = g.addV().property("aai-node-type", "forwarder-evc").property("forwarder-evc-id", "evc-5")
- .property("resource-version", "v13").next();
-
+ .property("resource-version", "v13").next();
+
+
-
edgeSerializer.addTreeEdge(g, pnf1, pInterface1);
edgeSerializer.addEdge(g, pInterface1, forwarder1);
edgeSerializer.addEdge(g, forwarder1, configuration1);
edgeSerializer.addTreeEdge(g, configuration1, forwarderEvc1);
-
+
edgeSerializer.addTreeEdge(g, pnf2, pInterface2);
edgeSerializer.addEdge(g, pInterface2, forwarder2);
edgeSerializer.addEdge(g, forwarder2, configuration2);
edgeSerializer.addTreeEdge(g, configuration2, forwarderEvc2);
-
+
edgeSerializer.addTreeEdge(g, pnf3, pInterface3);
edgeSerializer.addEdge(g, pInterface3, forwarder3);
edgeSerializer.addEdge(g, forwarder3, configuration3);
edgeSerializer.addTreeEdge(g, configuration3, forwarderEvc3);
-
+
edgeSerializer.addTreeEdge(g, pnf4, pInterface4);
edgeSerializer.addEdge(g, pInterface4, forwarder4);
edgeSerializer.addEdge(g, forwarder4, configuration4);
edgeSerializer.addTreeEdge(g, configuration4, forwarderEvc4);
-
+
edgeSerializer.addTreeEdge(g, pnf5, pInterface5);
edgeSerializer.addEdge(g, pInterface5, forwarder5);
edgeSerializer.addEdge(g, forwarder5, configuration5);
when(spy.asAdmin()).thenReturn(adminSpy);
when(adminSpy.getTraversalSource()).thenReturn(traversal);
when(adminSpy.getReadOnlyTraversalSource()).thenReturn(readOnly);
-
+
migration = new MigrateForwarderEvcCircuitId(spy, loaderFactory, edgeIngestor, edgeSerializer, schemaVersions);
migration.run();
}
-
+
@Test
public void testCircuitIdsUpdated() throws Exception {
// check if graph nodes are updated
-
- assertEquals("10",
- g.V().has("aai-node-type", "forwarder-evc").has("circuit-id", "10").next().value("circuit-id").toString(),
+
+ assertEquals("10",
+ g.V().has("aai-node-type", "forwarder-evc").has("circuit-id", "10").next().value("circuit-id").toString(),
"First circuit-id updated");
- assertEquals("20",
- g.V().has("aai-node-type", "forwarder-evc").has("circuit-id", "20").next().value("circuit-id").toString(),
+ assertEquals("20",
+ g.V().has("aai-node-type", "forwarder-evc").has("circuit-id", "20").next().value("circuit-id").toString(),
"Second circuit-id updated");
assertFalse(g.V().has("aai-node-type", "forwarder-evc").has("forwarder-evc-id", "evc-3")
.next().property("circuit-id").isPresent(), "Third circuit-id remains empty");
- assertEquals("3",
- g.V().has("aai-node-type", "forwarder-evc").has("circuit-id", "3").next().value("circuit-id").toString(),
+ assertEquals("3",
+ g.V().has("aai-node-type", "forwarder-evc").has("circuit-id", "3").next().value("circuit-id").toString(),
"Fourth circuit-id not updated");
assertFalse(g.V().has("aai-node-type", "forwarder-evc").has("forwarder-evc-id", "evc-5")
.next().property("circuit-id").isPresent(), "Fifth circuit-id remains empty");
}
-
+
@Test
public void testGetAffectedNodeTypes() {
Optional<String[]> types = migration.getAffectedNodeTypes();
Optional<String[]> expected = Optional.of(new String[]{"forwarder-evc"});
-
+
assertNotNull(types);
assertArrayEquals(expected.get(), types.get());
}
import org.onap.aai.serialization.db.EdgeSerializer;\r
import org.onap.aai.serialization.engines.TransactionalGraphEngine;\r
\r
-import org.janusgraph.core.JanusGraph;\r
-import org.janusgraph.core.JanusGraphFactory;\r
import org.janusgraph.core.JanusGraphTransaction;\r
-import org.janusgraph.core.schema.JanusGraphManagement;\r
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;\r
import org.junit.jupiter.api.BeforeEach;\r
import org.junit.jupiter.api.Test;\r
import org.onap.aai.serialization.engines.QueryStyle;
import org.onap.aai.serialization.engines.TransactionalGraphEngine;
-import static org.junit.jupiter.api.Assertions.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
assertFalse(instanceGroupWithoutTSubType.property(MigrateInstanceGroupSubType.INSTANCE_GROUP_ROLE_PROPERTY).isPresent());
assertFalse(instanceGroupWithoutTSubType.property(MigrateInstanceGroupSubType.SUB_TYPE_PROPERTY).isPresent());
}
-}
\ No newline at end of file
+}
queryStyle,
loader);
instanceGroup = g.addV().property("aai-node-type", MigrateInstanceGroupType.INSTANCE_GROUP_NODE_TYPE)
- .property( MigrateInstanceGroupType.TYPE_PROPERTY, TYPE_VALUE)
+ .property( MigrateInstanceGroupType.TYPE_PROPERTY, TYPE_VALUE)
.next();
-
+
instanceGroupWithoutType = g.addV().property("aai-node-type", MigrateInstanceGroupType.INSTANCE_GROUP_NODE_TYPE)
.next();
-
+
TransactionalGraphEngine spy = spy(dbEngine);
TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
GraphTraversalSource traversal = g;
assertFalse(instanceGroupWithoutType.property(MigrateInstanceGroupType.INSTANCE_GROUP_TYPE_PROPERTY).isPresent());
assertFalse(instanceGroupWithoutType.property(MigrateInstanceGroupType.TYPE_PROPERTY).isPresent());
}
-}
\ No newline at end of file
+}
*/
package org.onap.aai.migration.v13;
-import static org.junit.jupiter.api.Assertions.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.onap.aai.AAISetup;
-import org.onap.aai.dbmap.DBConnectionType;
import org.onap.aai.introspection.Loader;
import org.onap.aai.introspection.LoaderFactory;
import org.onap.aai.introspection.ModelType;
import org.onap.aai.setup.SchemaVersions;
-import org.onap.aai.setup.SchemaVersion;
import org.onap.aai.serialization.engines.JanusGraphDBEngine;
import org.onap.aai.serialization.engines.QueryStyle;
import org.onap.aai.serialization.engines.TransactionalGraphEngine;
pserver1 = g.addV().property("aai-node-type", MigratePserverAndPnfEquipType.PSERVER_NODE_TYPE)
.property( MigratePserverAndPnfEquipType.EQUIP_TYPE_PROPERTY, "Server")
.next();
-
+
pserver2 = g.addV().property("aai-node-type", MigratePserverAndPnfEquipType.PSERVER_NODE_TYPE)
.property( MigratePserverAndPnfEquipType.EQUIP_TYPE_PROPERTY, "server")
.next();
-
+
pnf1 = g.addV().property("aai-node-type", MigratePserverAndPnfEquipType.PNF_NODE_TYPE)
.property( MigratePserverAndPnfEquipType.EQUIP_TYPE_PROPERTY, "Switch")
.next();
pserver3 = g.addV().property("aai-node-type", MigratePserverAndPnfEquipType.PSERVER_NODE_TYPE)
.property( MigratePserverAndPnfEquipType.EQUIP_TYPE_PROPERTY, "server1")
.next();
-
+
pnf2 = g.addV().property("aai-node-type", MigratePserverAndPnfEquipType.PNF_NODE_TYPE)
.property( MigratePserverAndPnfEquipType.EQUIP_TYPE_PROPERTY, "Switch1")
.next();
assertEquals("SWITCH",pnf1.property(MigratePserverAndPnfEquipType.EQUIP_TYPE_PROPERTY).value());
assertEquals("SWITCH",pnf22.property(MigratePserverAndPnfEquipType.EQUIP_TYPE_PROPERTY).value());
}
-
+
@Test
public void verifyEquipTypeIsNotChanged() {
assertEquals("server1",pserver3.property(MigratePserverAndPnfEquipType.EQUIP_TYPE_PROPERTY).value());
assertEquals("Switch1",pnf2.property(MigratePserverAndPnfEquipType.EQUIP_TYPE_PROPERTY).value());
}
-
-
-
-}
\ No newline at end of file
+
+
+
+}
import java.util.Optional;
public class MigrateGenericVnfMgmtOptionsTest extends AAISetup {
-
+
protected static final String VNF_NODE_TYPE = "generic-vnf";
public static class MigrateVnfType extends MigrateGenericVnfMgmtOptions {
.property("vnf-type", "HN")
.property("management-option", "existingOption")
.next();
-
+
g.addV().property("aai-node-type", "generic-vnf")
.property("vnf-id", "generic-vnf10")
.property("vnf-type", "HP")
.property("vnf-type", "HP")
.property("management-option", "existingOption")
.next();
-
+
g.addV().property("aai-node-type", "generic-vnf")
.property("vnf-id", "generic-vnf20")
.property("vnf-type", "HG")
.property("vnf-id", "generic-vnf22")
.property("vnf-type", "HG")
.property("management-option", "existingOption")
- .next();
-
+ .next();
+
// Non-eligible migration conditions - vnf-type = XX
g.addV().property("aai-node-type", "generic-vnf")
.property("vnf-id", "generic-vnf30")
.property("vnf-id", "generic-vnf32")
.property("vnf-type", "XX")
.property("management-option", "existingOption")
- .next();
+ .next();
// Non-eligible migration conditions - vnf-type = missing
g.addV().property("aai-node-type", "generic-vnf")
.property("vnf-id", "generic-vnf40")
g.addV().property("aai-node-type", "generic-vnf")
.property("vnf-id", "generic-vnf42")
.property("management-option", "existingOption")
- .next();
-
+ .next();
+
TransactionalGraphEngine spy = spy(dbEngine);
TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
GraphTraversalSource traversal = g;
when(adminSpy.getTraversalSource()).thenReturn(traversal);
migration = new MigrateVnfType(spy, loaderFactory, edgeIngestor, edgeSerializer, schemaVersions);
migration.run();
-
+
}
@Test
public void testMissingProperty(){
//management-option
assertTrue(g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "generic-vnf0").has("management-option", "AT&T Managed-Basic").hasNext(),
- "Value of generic-vnf should be updated since the property management-option doesn't exist");
+ "Value of generic-vnf should be updated since the property management-option doesn't exist");
assertTrue(g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "generic-vnf10").has("management-option", "AT&T Managed-Basic").hasNext(),
"Value of generic-vnf should be updated since the property management-option doesn't exist");
assertTrue(g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "generic-vnf20").has("management-option", "AT&T Managed-Basic").hasNext(),
- "Value of generic-vnf should be updated since the property management-option doesn't exist");
+ "Value of generic-vnf should be updated since the property management-option doesn't exist");
}
@Test
- public void testEmptyValue() {
+ public void testEmptyValue() {
//management-option
assertTrue(g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "generic-vnf1").has("management-option", "AT&T Managed-Basic").hasNext(),
"Value of generic-vnf should be updated since the value for management-option is an empty string");
"Value of generic-vnf should be updated since the value for management-option is an empty string");
assertTrue(g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "generic-vnf21").has("management-option", "AT&T Managed-Basic").hasNext(),
"Value of generic-vnf should be updated since the value for management-option is an empty string");
-
+
}
-
+
@Test
public void testExistingValues() {
//management-option
"Value of generic-vnf shouldn't be updated since management-option already exists");
assertTrue(!g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "generic-vnf22").has("management-option", "AT&T Managed-Basic").hasNext(),
"Value of generic-vnf shouldn't be updated since management-option already exists");
-
-
+
+
}
-
+
@Test
public void testExistingVnfsNotMigrated() {
//management-option
"Value of generic-vnf shouldn't be updated since vnf-type is not affected");
assertTrue(!g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "generic-vnf32").has("management-option", "AT&T Managed-Basic").hasNext(),
"Value of generic-vnf shouldn't be updated since vnf-type is not affected and management-option already exists");
-
+
assertTrue(!g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "generic-vnf40").has("management-option", "AT&T Managed-Basic").hasNext(),
"Value of generic-vnf shouldn't be updated since vnf-type is not present");
assertTrue(!g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "generic-vnf41").has("management-option", "AT&T Managed-Basic").hasNext(),
"Value of generic-vnf shouldn't be updated since vnf-type is not present");
assertTrue(!g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "generic-vnf42").has("management-option", "AT&T Managed-Basic").hasNext(),
"Value of generic-vnf shouldn't be updated since vnf-type is not present and management-option already exists");
-
- }
-}
\ No newline at end of file
+
+ }
+}
*/
package org.onap.aai.migration.v14;
-import static org.junit.jupiter.api.Assertions.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.onap.aai.AAISetup;
-import org.onap.aai.dbmap.DBConnectionType;
import org.onap.aai.introspection.Loader;
import org.onap.aai.introspection.ModelType;
-import org.onap.aai.migration.v14.MigrateSameSourcedRCTROPserverData;
import org.onap.aai.serialization.engines.QueryStyle;
import org.onap.aai.serialization.engines.JanusGraphDBEngine;
import org.onap.aai.serialization.engines.TransactionalGraphEngine;
*/
package org.onap.aai.migration.v14;
-import static org.junit.jupiter.api.Assertions.*;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
-import java.util.ArrayList;
-import java.util.List;
-
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.ReadOnlyStrategy;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.janusgraph.core.JanusGraph;
-import org.janusgraph.core.JanusGraphFactory;
import org.janusgraph.core.JanusGraphTransaction;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.onap.aai.AAISetup;
import org.onap.aai.db.props.AAIProperties;
-import org.onap.aai.dbmap.DBConnectionType;
import org.onap.aai.introspection.Loader;
import org.onap.aai.introspection.ModelType;
import org.onap.aai.serialization.engines.JanusGraphDBEngine;
*/
package org.onap.aai.migration.v14;
-import static org.junit.jupiter.api.Assertions.*;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
-import java.util.List;
-
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.apache.tinkerpop.gremlin.process.traversal.strategy.verification.ReadOnlyStrategy;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.onap.aai.AAISetup;
-import org.onap.aai.dbmap.DBConnectionType;
import org.onap.aai.introspection.Loader;
import org.onap.aai.introspection.ModelType;
import org.onap.aai.serialization.engines.QueryStyle;
g.addV().property("aai-node-type", "vserver")\r
.property("vserver-id", "vserver3")\r
.property("is-closed-loop-disabled", false)\r
- .next(); \r
+ .next();\r
//l3-network\r
g.addV().property("aai-node-type", "l3-network")\r
.property("network-id", "l3-network0")\r
.property("is-provider-network", false)\r
.property("is-shared-network", false)\r
.property("is-external-network", false)\r
- .next(); \r
+ .next();\r
//subnet\r
g.addV().property("aai-node-type", "subnet")\r
.property("subnet-id", "subnet0")\r
.property("in-maint", false)\r
.property("is-port-mirrored", false)\r
.property("is-ip-unnumbered", false)\r
- .next(); \r
+ .next();\r
//vf-module\r
g.addV().property("aai-node-type", "vf-module")\r
.property("vf-module-id", "vf-module0")\r
.next();\r
g.addV().property("aai-node-type", "vf-module")\r
.property("vf-module-id", "vf-module3")\r
- .property("is-base-vf-module", false) \r
- .next(); \r
- \r
+ .property("is-base-vf-module", false)\r
+ .next();\r
+\r
//vlan\r
g.addV().property("aai-node-type", "vlan")\r
.property("vlan-interface", "vlan0")\r
.next();\r
g.addV().property("aai-node-type", "vlan")\r
.property("vlan-interface", "vlan3")\r
- .property("is-ip-unnumbered", false) \r
+ .property("is-ip-unnumbered", false)\r
.next();\r
- \r
+\r
TransactionalGraphEngine spy = spy(dbEngine);\r
TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());\r
GraphTraversalSource traversal = g;\r
when(adminSpy.getTraversalSource()).thenReturn(traversal);\r
migration = new BooleanDefaultMigrator(spy, loaderFactory, edgeIngestor, edgeSerializer, schemaVersions);\r
migration.run();\r
- \r
+\r
}\r
\r
@Test\r
"Value of subnet should be updated since the property dhcp-enabled doesn't exist");\r
//l3-network: is-bound-to-vpn, is-shared-network, is-external-network\r
assertTrue(g.V().has("aai-node-type", "l3-network").has("network-id", "l3-network0").has("network-name", "l3-network-name0").has("is-bound-to-vpn", false).hasNext(),\r
- "Value of l3-network should be updated since the property is-bound-to-vpn doesn't exist"); \r
+ "Value of l3-network should be updated since the property is-bound-to-vpn doesn't exist");\r
assertTrue(g.V().has("aai-node-type", "l3-network").has("network-id", "l3-network0").has("network-name", "l3-network-name0").has("is-provider-network", false).hasNext(),\r
- "Value of l3-network should be updated since the property is-provider-network doesn't exist"); \r
+ "Value of l3-network should be updated since the property is-provider-network doesn't exist");\r
assertTrue(g.V().has("aai-node-type", "l3-network").has("network-id", "l3-network0").has("network-name", "l3-network-name0").has("is-shared-network", false).hasNext(),\r
- "Value of l3-network should be updated since the property is-shared-network doesn't exist"); \r
+ "Value of l3-network should be updated since the property is-shared-network doesn't exist");\r
assertTrue(g.V().has("aai-node-type", "l3-network").has("network-id", "l3-network0").has("network-name", "l3-network-name0").has("is-external-network", false).hasNext(),\r
- "Value of l3-network should be updated since the property is-external-network doesn't exist"); \r
+ "Value of l3-network should be updated since the property is-external-network doesn't exist");\r
//l-interface: is-port-mirrored, is-ip-unnumbered\r
assertTrue(g.V().has("aai-node-type", "l-interface").has("interface-name", "l-interface0").has("is-port-mirrored", false).hasNext(),\r
- "Value of l-interface should be updated since the property is-port-mirrored doesn't exist"); \r
+ "Value of l-interface should be updated since the property is-port-mirrored doesn't exist");\r
assertTrue(g.V().has("aai-node-type", "l-interface").has("interface-name", "l-interface0").has("is-ip-unnumbered", false).hasNext(),\r
"Value of l-interface should be updated since the property is-ip-unnumbered doesn't exist");\r
//vf-module: is-base-vf-module\r
assertTrue(g.V().has("aai-node-type", "vf-module").has("vf-module-id", "vf-module0").has("is-base-vf-module", false).hasNext(),\r
- "Value of vf-module should be updated since the property is-base-vf-module doesn't exist"); \r
+ "Value of vf-module should be updated since the property is-base-vf-module doesn't exist");\r
//vlan: is-ip-unnumbered\r
assertTrue(g.V().has("aai-node-type", "vlan").has("vlan-interface", "vlan0").has("is-ip-unnumbered", false).hasNext(),\r
"Value of vlan should be updated since the property is-ip-unnumbered doesn't exist");\r
}\r
\r
@Test\r
- public void testEmptyValue() { \r
+ public void testEmptyValue() {\r
//is-closed-loop-disabled\r
assertTrue(g.V().has("aai-node-type", "generic-vnf").has("vnf-id", "generic-vnf1").has("is-closed-loop-disabled", false).hasNext(),\r
"Value of generic-vnf should be updated since the value for is-closed-loop-disabled is an empty string");\r
"Value of subnet should be updated since the value for dhcp-enabled is an empty string");\r
//l3-network: is-bound-to-vpn, is-shared-network, is-external-network\r
assertTrue(g.V().has("aai-node-type", "l3-network").has("network-id", "l3-network1").has("network-name", "l3-network-name1").has("is-bound-to-vpn", false).hasNext(),\r
- "Value of l3-network should be updated since the value for is-bound-to-vpn is an empty string"); \r
+ "Value of l3-network should be updated since the value for is-bound-to-vpn is an empty string");\r
assertTrue(g.V().has("aai-node-type", "l3-network").has("network-id", "l3-network1").has("network-name", "l3-network-name1").has("is-provider-network", false).hasNext(),\r
- "Value of l3-network should be updated since the value for is-provider-network is an empty string"); \r
+ "Value of l3-network should be updated since the value for is-provider-network is an empty string");\r
assertTrue(g.V().has("aai-node-type", "l3-network").has("network-id", "l3-network1").has("network-name", "l3-network-name1").has("is-shared-network", false).hasNext(),\r
"Value of l3-network should be updated since the value for is-shared-network is an empty string");\r
assertTrue(g.V().has("aai-node-type", "l3-network").has("network-id", "l3-network1").has("network-name", "l3-network-name1").has("is-external-network", false).hasNext(),\r
"Value of l3-network should be updated since the value for is-external-network is an empty string");\r
//l-interface: is-port-mirrored, is-ip-unnumbered\r
assertTrue(g.V().has("aai-node-type", "l-interface").has("interface-name", "l-interface1").has("is-port-mirrored", false).hasNext(),\r
- "Value of l-interface should be updated since the property is-port-mirrored is an empty string"); \r
+ "Value of l-interface should be updated since the property is-port-mirrored is an empty string");\r
assertTrue(g.V().has("aai-node-type", "l-interface").has("interface-name", "l-interface1").has("is-ip-unnumbered", false).hasNext(),\r
"Value of l-interface should be updated since the property is-ip-unnumbered is an empty string");\r
//vf-module: is-base-vf-module, is-ip-unnumbered\r
assertTrue(g.V().has("aai-node-type", "vf-module").has("vf-module-id", "vf-module1").has("is-base-vf-module", false).hasNext(),\r
- "Value of vf-module should be updated since the property is-base-vf-module is an empty string"); \r
+ "Value of vf-module should be updated since the property is-base-vf-module is an empty string");\r
//vlan: is-ip-unnumbered\r
assertTrue(g.V().has("aai-node-type", "vlan").has("vlan-interface", "vlan1").has("is-ip-unnumbered", false).hasNext(),\r
"Value of vlan should be updated since the property is-ip-unnumbered is an empty string");\r
}\r
- \r
+\r
@Test\r
public void testExistingTrueValues() {\r
//is-closed-loop-disabled\r
"Value of vserver shouldn't be update since is-closed-loop-disabled already exists");\r
//dhcp-enabled\r
assertTrue(g.V().has("aai-node-type", "subnet").has("subnet-id", "subnet2").has("dhcp-enabled", true).hasNext(),\r
- "Value of subnet shouldn't be update since dhcp-enabled already exists"); \r
+ "Value of subnet shouldn't be update since dhcp-enabled already exists");\r
//l3-network: is-bound-to-vpn, is-shared-network, is-external-network\r
assertTrue(g.V().has("aai-node-type", "l3-network").has("network-id", "l3-network2").has("network-name", "l3-network-name2").has("is-bound-to-vpn", true).hasNext(),\r
"Value of l3-network shouldn't be updated since is-bound-to-vpn already exists");\r
assertTrue(g.V().has("aai-node-type", "l3-network").has("network-id", "l3-network2").has("network-name", "l3-network-name2").has("is-shared-network", true).hasNext(),\r
"Value of l3-network shouldn't be updated since is-shared-network already exists");\r
assertTrue(g.V().has("aai-node-type", "l3-network").has("network-id", "l3-network2").has("network-name", "l3-network-name2").has("is-external-network", true).hasNext(),\r
- "Value of l3-network shouldn't be updated since is-external-network already exists"); \r
+ "Value of l3-network shouldn't be updated since is-external-network already exists");\r
//l-interface: is-port-mirrored, is-ip-unnumbered\r
assertTrue(g.V().has("aai-node-type", "l-interface").has("interface-name", "l-interface2").has("is-port-mirrored", true).hasNext(),\r
- "Value of l-interface shouldn't be updated since is-port-mirrored already exists"); \r
+ "Value of l-interface shouldn't be updated since is-port-mirrored already exists");\r
assertTrue(g.V().has("aai-node-type", "l-interface").has("interface-name", "l-interface2").has("is-ip-unnumbered", true).hasNext(),\r
- "Value of ll-interface shouldn't be updated since is-ip-unnumbered already exists"); \r
+ "Value of ll-interface shouldn't be updated since is-ip-unnumbered already exists");\r
//vf-module: is-base-vf-module\r
assertTrue(g.V().has("aai-node-type", "vf-module").has("vf-module-id", "vf-module2").has("is-base-vf-module", true).hasNext(),\r
- "Value of vf-module shouldn't be updated since is-base-vf-module already exists"); \r
+ "Value of vf-module shouldn't be updated since is-base-vf-module already exists");\r
//vlan: is-ip-unnumbered\r
assertTrue(g.V().has("aai-node-type", "vlan").has("vlan-interface", "vlan2").has("is-ip-unnumbered", true).hasNext(),\r
"Value of vlan shouldn't be updated since is-ip-unnumbered already exists");\r
- \r
+\r
}\r
- \r
+\r
@Test\r
public void testExistingFalseValues() {\r
//is-closed-loop-disabled\r
"Value of subnet shouldn't be update since dhcp-enabled already exists");\r
//l3-network: is-bound-to-vpn, is-shared-network, is-external-network\r
assertTrue(g.V().has("aai-node-type", "l3-network").has("network-id", "l3-network3").has("network-name", "l3-network-name3").has("is-bound-to-vpn", false).hasNext(),\r
- "Value of l3-network shouldn't be updated since is-bound-to-vpn already exists"); \r
+ "Value of l3-network shouldn't be updated since is-bound-to-vpn already exists");\r
assertTrue(g.V().has("aai-node-type", "l3-network").has("network-id", "l3-network3").has("network-name", "l3-network-name3").has("is-provider-network", false).hasNext(),\r
- "Value of l3-network shouldn't be updated since is-provider-network already exists"); \r
+ "Value of l3-network shouldn't be updated since is-provider-network already exists");\r
assertTrue(g.V().has("aai-node-type", "l3-network").has("network-id", "l3-network3").has("network-name", "l3-network-name3").has("is-shared-network", false).hasNext(),\r
"Value of l3-network shouldn't be updated since is-shared-network already exists");\r
assertTrue(g.V().has("aai-node-type", "l3-network").has("network-id", "l3-network3").has("network-name", "l3-network-name3").has("is-external-network", false).hasNext(),\r
- "Value of l3-network shouldn't be updated since is-external-network already exists"); \r
+ "Value of l3-network shouldn't be updated since is-external-network already exists");\r
//l-interface: is-port-mirrored, is-ip-unnumbered\r
assertTrue(g.V().has("aai-node-type", "l-interface").has("interface-name", "l-interface3").has("is-port-mirrored", false).hasNext(),\r
- "Value of l-interface shouldn't be updated since is-port-mirrored already exists"); \r
+ "Value of l-interface shouldn't be updated since is-port-mirrored already exists");\r
assertTrue(g.V().has("aai-node-type", "l-interface").has("interface-name", "l-interface3").has("is-ip-unnumbered", false).hasNext(),\r
- "Value of ll-interface shouldn't be updated since is-ip-unnumbered already exists"); \r
+ "Value of ll-interface shouldn't be updated since is-ip-unnumbered already exists");\r
//vf-module: is-base-vf-module\r
assertTrue(g.V().has("aai-node-type", "vf-module").has("vf-module-id", "vf-module3").has("is-base-vf-module", false).hasNext(),\r
- "Value of vf-module shouldn't be updated since is-base-vf-module already exists"); \r
+ "Value of vf-module shouldn't be updated since is-base-vf-module already exists");\r
//vlan: is-ip-unnumbered\r
assertTrue(g.V().has("aai-node-type", "vlan").has("vlan-interface", "vlan3").has("is-ip-unnumbered", false).hasNext(),\r
"Value of vlan shouldn't be updated since is-ip-unnumbered already exists");\r
- } \r
-}
\ No newline at end of file
+ }\r
+}\r
Vertex cloudRegion1;
Vertex cloudRegion2;
Vertex cloudRegion3;
-
+
@BeforeEach
public void setUp() throws Exception {
-
+
graph = JanusGraphFactory.build().set("storage.backend", "inmemory").open();
tx = graph.newTransaction();
g = tx.traversal();
dbEngine = new JanusGraphDBEngine(
queryStyle,
loader);
-
+
System.setProperty("BUNDLECONFIG_DIR", "src/test/resources");
-
+
cloudRegion1 = g.addV().property("aai-node-type", MigrateCloudRegionUpgradeCycle.CLOUD_REGION_NODE_TYPE)
.property(MigrateCloudRegionUpgradeCycle.CLOUD_REGION_ID, "akr1")
.property(MigrateCloudRegionUpgradeCycle.CLOUD_OWNER, "att-aic")
.property( MigrateCloudRegionUpgradeCycle.UPGRADE_CYCLE, "Test")
.next();
-
+
cloudRegion2 = g.addV().property("aai-node-type", MigrateCloudRegionUpgradeCycle.CLOUD_REGION_NODE_TYPE)
.property(MigrateCloudRegionUpgradeCycle.CLOUD_REGION_ID, "amsnl1b")
.property(MigrateCloudRegionUpgradeCycle.CLOUD_OWNER, "att-aic")
//.property( MigrateCloudRegionUpgradeCycle.UPGRADE_CYCLE, "server")
.next();
-
+
cloudRegion3 = g.addV().property("aai-node-type", MigrateCloudRegionUpgradeCycle.CLOUD_REGION_NODE_TYPE)
.property(MigrateCloudRegionUpgradeCycle.CLOUD_REGION_ID, "alp1")
.property(MigrateCloudRegionUpgradeCycle.CLOUD_OWNER, "Test")
.property( MigrateCloudRegionUpgradeCycle.UPGRADE_CYCLE, "server1")
.next();
-
+
TransactionalGraphEngine spy = spy(dbEngine);
TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
GraphTraversalSource traversal = g;
assertEquals("B",cloudRegion2.property(MigrateCloudRegionUpgradeCycle.UPGRADE_CYCLE).value());
assertEquals("server1",cloudRegion3.property(MigrateCloudRegionUpgradeCycle.UPGRADE_CYCLE).value());//Not changed
}
-}
\ No newline at end of file
+}
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.onap.aai.AAISetup;
-import org.onap.aai.dbmap.DBConnectionType;
import org.onap.aai.introspection.Loader;
import org.onap.aai.introspection.ModelType;
import org.onap.aai.setup.SchemaVersions;
-import org.onap.aai.setup.SchemaVersion;
import org.onap.aai.serialization.engines.QueryStyle;
import org.onap.aai.serialization.engines.JanusGraphDBEngine;
import org.onap.aai.serialization.engines.TransactionalGraphEngine;
-import org.janusgraph.core.JanusGraphFactory;
import org.janusgraph.core.JanusGraph;
import org.janusgraph.core.JanusGraphTransaction;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.onap.aai.config.WebClientConfiguration;
-import org.onap.aai.restclient.PropertyPasswordConfiguration;
import org.onap.aai.service.SchemaJobStatusService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.context.annotation.Import;
-import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.web.reactive.server.WebTestClient;
@Import(WebClientConfiguration.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
-@ContextConfiguration(initializers = PropertyPasswordConfiguration.class)
public class SchemaJobStatusControllerTest {
- @MockBean
+ @MockBean
private SchemaJobStatusService schemaJobStatusService;
@Autowired
@Test
void testIsSchemaInitializedTrue() throws Exception {
when(schemaJobStatusService.isSchemaInitialized()).thenReturn(true);
-
+
webClient.get()
.uri("/isSchemaInitialized")
.exchange()
@Test
void testIsSchemaInitializedFalse() throws Exception {
when(schemaJobStatusService.isSchemaInitialized()).thenReturn(false);
-
+
webClient.get()
.uri("/isSchemaInitialized")
.exchange()
.expectStatus()
.isNotFound();
}
-}
\ No newline at end of file
+}
assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus());
}
-
+
@Test
public void testCheckDbNowAction_Unknown() {
when(aaiGraphCheckerMock.isAaiGraphDbAvailable()).thenReturn(null);
assertNotNull(response);
assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatus());
}
-}
\ No newline at end of file
+}
management.metrics.web.server.auto-time-requests=false
aai.notifications.enabled=false
+
+aai.basic-auth.enabled=true
+aai.basic-auth.users[0].username=AAI
+aai.basic-auth.users[0].password=AAI
major_version=1
minor_version=15
-patch_version=4
+patch_version=5
base_version=${major_version}.${minor_version}.${patch_version}