1b05e4b0e8c249364a26b6165a053bd10466e39e
[ccsdk/features.git] /
1 /*\r
2  * Copyright © 2017-2018 AT&T Intellectual Property.\r
3  * \r
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except\r
5  * in compliance with the License. You may obtain a copy of the License at\r
6  * \r
7  * http://www.apache.org/licenses/LICENSE-2.0\r
8  * \r
9  * Unless required by applicable law or agreed to in writing, software distributed under the License\r
10  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express\r
11  * or implied. See the License for the specific language governing permissions and limitations under\r
12  * the License.\r
13  */\r
14 \r
15 package org.onap.ccsdk.config.assignment.service;\r
16 \r
17 import java.nio.charset.Charset;\r
18 import java.util.List;\r
19 import org.apache.commons.io.IOUtils;\r
20 import org.junit.Assert;\r
21 import org.junit.Test;\r
22 import org.onap.ccsdk.config.assignment.processor.ResourceAssignmentProcessor;\r
23 import org.onap.ccsdk.config.model.data.ResourceAssignment;\r
24 import org.onap.ccsdk.config.model.utils.TransformationUtils;\r
25 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;\r
26 import com.att.eelf.configuration.EELFLogger;\r
27 import com.att.eelf.configuration.EELFManager;\r
28 \r
29 public class TopologicalSortingTest {\r
30     private static EELFLogger logger = EELFManager.getInstance().getLogger(TopologicalSortingTest.class);\r
31     \r
32     @Test\r
33     public void testBulkSequencingMapping() {\r
34         try {\r
35             logger.info(" **************** Bulk Sequencing Default *****************");\r
36             String resourceMapping = IOUtils.toString(\r
37                     TopologicalSortingTest.class.getClassLoader().getResourceAsStream("mapping/dependency.json"),\r
38                     Charset.defaultCharset());\r
39             \r
40             List<ResourceAssignment> assignments =\r
41                     TransformationUtils.getListfromJson(resourceMapping, ResourceAssignment.class);\r
42             if (assignments != null) {\r
43                 SvcLogicContext ctx = new SvcLogicContext();\r
44                 ResourceAssignmentProcessor resourceAssignmentProcessor =\r
45                         new ResourceAssignmentProcessor(assignments, ctx);\r
46                 List<List<ResourceAssignment>> sequenceBatchResourceAssignment = resourceAssignmentProcessor.process();\r
47                 \r
48                 Assert.assertNotNull("Failed to populate Sequence Bulk Mappings", sequenceBatchResourceAssignment);\r
49                 Assert.assertNotEquals("Failed to populate Sequence Bulk Mappings size ",\r
50                         (sequenceBatchResourceAssignment.size() > 0));\r
51             }\r
52         } catch (Exception e) {\r
53             e.printStackTrace();\r
54         }\r
55     }\r
56     \r
57 }\r