474136d5b57cf4879842e6190db0c48b99d38763
[ccsdk/sli.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP : CCSDK
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights
6  *                                              reserved.
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  */
21
22 package org.onap.ccsdk.sli.core.sli.provider.base;
23
24 import java.util.Map.Entry;
25 import java.util.Properties;
26
27 import org.onap.ccsdk.sli.core.sli.DuplicateValueException;
28 import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
29 import org.onap.ccsdk.sli.core.sli.SvcLogicException;
30 import org.onap.ccsdk.sli.core.sli.SvcLogicExpression;
31 import org.onap.ccsdk.sli.core.sli.SvcLogicGraph;
32 import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin;
33 import org.onap.ccsdk.sli.core.sli.SvcLogicNode;
34 import org.onap.ccsdk.sli.core.sli.provider.base.ExecuteNodeExecutor;
35 import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicPropertiesProvider;
36 import org.onap.ccsdk.sli.core.sli.provider.base.SvcLogicServiceImplBase;
37
38 import junit.framework.TestCase;
39
40 public class ExecuteNodeExecutorTest extends TestCase {
41     public class MockExecuteNodeExecutor extends ExecuteNodeExecutor {
42
43         protected SvcLogicJavaPlugin getSvcLogicJavaPlugin(String pluginName) {
44             return (SvcLogicJavaPlugin) new LunchSelectorPlugin();
45         }
46
47         protected String evaluate(SvcLogicExpression expr, SvcLogicNode node,
48                 SvcLogicContext ctx) throws SvcLogicException {
49             return "selectLunch";
50         }
51     }
52
53     public void testBadPlugin() throws DuplicateValueException, SvcLogicException {
54         LunchSelectorPlugin p = new LunchSelectorPlugin();
55         MockExecuteNodeExecutor execute = new MockExecuteNodeExecutor();
56         SvcLogicNode node = new SvcLogicNode(0, "", "", new SvcLogicGraph());
57         node.setAttribute("method", "selectLunch");
58         SvcLogicPropertiesProvider resourceProvider = new SvcLogicPropertiesProvider() {
59
60                         public Properties getProperties() {
61                                 return new Properties();
62                         };
63         };
64         
65         
66         execute.execute(new SvcLogicServiceImplBase(null), new SvcLogicNode(0, "", "", new SvcLogicGraph()), new SvcLogicContext());
67     }
68
69 }