82283f5a3537e1a391c880e260ddf5b303291e93
[ccsdk/features.git] /
1 /*******************************************************************************
2  * ============LICENSE_START========================================================================
3  * ONAP : ccsdk feature sdnr wt
4  * =================================================================================================
5  * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. All rights reserved.
6  * =================================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
8  * in compliance with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software distributed under the License
13  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
14  * or implied. See the License for the specific language governing permissions and limitations under
15  * the License.
16  * ============LICENSE_END==========================================================================
17  ******************************************************************************/
18 package org.onap.ccsdk.features.sdnr.wt.dataprovider.setup;
19
20 import static org.junit.Assert.assertEquals;
21 import static org.junit.Assert.assertTrue;
22 import static org.junit.Assert.fail;
23
24 import org.junit.Test;
25 import org.onap.ccsdk.features.sdnr.wt.common.database.config.HostInfo;
26 import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.DataMigrationProviderImpl;
27 import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.DataMigrationReport;
28 import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.Release;
29
30 /**
31  * @author Michael Dürre
32  *
33  */
34 public class TestMigrationProvider {
35
36           private static final String FRANKFURT_BACKUP_FILE = "src/test/resources/test2.bak.json";
37         public static HostInfo[] hosts = new HostInfo[] { new HostInfo("localhost", Integer
38                     .valueOf(System.getProperty("databaseport") != null ? System.getProperty("databaseport") : "49200")) };
39
40         @Test
41         public void testCreateImport() {
42                 DataMigrationProviderImpl provider = new DataMigrationProviderImpl(hosts, null, null,true);
43                 
44                 try {
45                         //create el alto db infrastructure
46                         provider.initDatabase(Release.FRANKFURT_R1, 5, 1, "", true);
47                         //import data into database
48                         DataMigrationReport report = provider.importData(FRANKFURT_BACKUP_FILE, false, Release.FRANKFURT_R1);
49                         assertTrue(report.completed());
50                         assertEquals(Release.FRANKFURT_R1, provider.autoDetectRelease());
51                 } catch (Exception e) {
52                         fail(e.getMessage());
53                 }
54         }
55 }