Servicehandler Tests
[transportpce.git] / cli / src / main / java / org / opendaylight / transportpce / cli / commands / TransportpceCliTestCommand.java
1 /*
2  * Copyright © 2016 Orange and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.transportpce.cli.commands;
9
10 import org.apache.karaf.shell.commands.Command;
11 import org.apache.karaf.shell.commands.Option;
12 import org.apache.karaf.shell.console.AbstractAction;
13 import org.opendaylight.transportpce.cli.api.TransportpceCliCommands;
14 import org.slf4j.Logger;
15 import org.slf4j.LoggerFactory;
16
17 /**
18  * This is an example class. The class name can be renamed to match the command implementation that it will invoke.
19  * Specify command details by updating the fields in the Command annotation below.
20  */
21 @Command(name = "test-command",
22          scope = "add the scope of the command, usually project name",
23          description = "add a description for the command")
24 public class TransportpceCliTestCommand extends AbstractAction {
25
26     private static final Logger LOG = LoggerFactory.getLogger(TransportpceCliTestCommand.class);
27     protected final TransportpceCliCommands service;
28
29     public TransportpceCliTestCommand(final TransportpceCliCommands service) {
30         this.service = service;
31     }
32
33     /**
34      * Add the arguments required by the command.
35      * Any number of arguments can be added using the Option annotation
36      * The below argument is just an example and should be changed as per your requirements
37      */
38     @Option(name = "-tA",
39             aliases = { "--testArgument" },
40             description = "test command argument",
41             required = true,
42             multiValued = false)
43     private Object testArgument;
44
45     @Override
46     protected Object doExecute() throws Exception {
47         /**
48          * Invoke commannd implementation here using the service instance.
49          * Implement how you want the output of the command to be displayed.
50          * Below is just an example.
51          */
52         final String testMessage = (String) service.testCommand(testArgument);
53         return testMessage;
54     }
55 }