2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
20 package org.onap.aai.migration.v12;
22 import org.janusgraph.core.JanusGraphFactory;
23 import org.janusgraph.core.JanusGraph;
24 import org.janusgraph.core.JanusGraphTransaction;
25 import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
26 import org.apache.tinkerpop.gremlin.structure.Vertex;
27 import org.junit.After;
28 import org.junit.Before;
29 import org.junit.Test;
30 import org.onap.aai.AAISetup;
31 import org.onap.aai.dbmap.DBConnectionType;
32 import org.onap.aai.introspection.Loader;
33 import org.onap.aai.introspection.ModelType;
34 import org.onap.aai.setup.SchemaVersions;
35 import org.onap.aai.setup.SchemaVersion;
36 import org.onap.aai.serialization.engines.QueryStyle;
37 import org.onap.aai.serialization.engines.JanusGraphDBEngine;
38 import org.onap.aai.serialization.engines.TransactionalGraphEngine;
39 import static org.junit.Assert.assertEquals;
40 import static org.mockito.Mockito.spy;
41 import static org.mockito.Mockito.when;
44 public class MigrateModelVerDistributionStatusPropertyTest extends AAISetup{
46 private final static ModelType introspectorFactoryType = ModelType.MOXY;
47 private final static QueryStyle queryStyle = QueryStyle.TRAVERSAL;
48 private final static DBConnectionType type = DBConnectionType.REALTIME;
49 private Loader loader;
50 private TransactionalGraphEngine dbEngine;
51 private JanusGraph graph;
52 private MigrateModelVerDistriubutionStatusProperty migration;
53 private GraphTraversalSource g;
54 private JanusGraphTransaction tx;
59 public void setUp() throws Exception {
60 graph = JanusGraphFactory.build().set("storage.backend", "inmemory").open();
61 tx = graph.newTransaction();
63 loader = loaderFactory.createLoaderForVersion(introspectorFactoryType, schemaVersions.getDefaultVersion());
64 dbEngine = new JanusGraphDBEngine(
68 modelVer1 = g.addV().property("aai-node-type", "model-ver")
69 .property("model-version-id", "modelVer1")
70 .property("distribution-status", "test1")
73 modelVer2 = g.addV().property("aai-node-type", "model-ver")
74 .property("model-version-id", "modelVer1")
77 TransactionalGraphEngine spy = spy(dbEngine);
78 TransactionalGraphEngine.Admin adminSpy = spy(dbEngine.asAdmin());
79 GraphTraversalSource traversal = g;
80 when(spy.asAdmin()).thenReturn(adminSpy);
81 when(adminSpy.getTraversalSource()).thenReturn(traversal);
82 migration = new MigrateModelVerDistriubutionStatusProperty(spy, loaderFactory, edgeIngestor, edgeSerializer, schemaVersions);
87 public void cleanUp() {
94 * checks if the Distribution Status value was changed
98 public void confirmDistributionStatusChanged() {
100 assertEquals("DISTRIBUTION_COMPLETE_OK",modelVer1.property("distribution-status").value());
101 assertEquals("DISTRIBUTION_COMPLETE_OK",modelVer2.property("distribution-status").value());