Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Autofill connection attribute if only one connection is defined
Change-Id: Ic541aba448733aa34417a83ddd0082658fa236b7 Closes-Bug: #1772594
- Loading branch information
1 parent
879485c
commit 3970a78
Showing
14 changed files
with
117 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
#maven.buildNumber.plugin properties file | ||
#Thu Jun 14 17:13:15 CEST 2018 | ||
buildNumber=1461 | ||
#Mon Jun 18 14:58:52 CEST 2018 | ||
buildNumber=1470 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
...tests/src/test/groovy/net/juniper/contrail/vro/tests/actions/DefaultConnectionSpec.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* Copyright (c) 2018 Juniper Networks, Inc. All rights reserved. | ||
*/ | ||
|
||
package net.juniper.contrail.vro.tests.actions | ||
|
||
import com.vmware.o11n.plugin.sdk.spring.platform.GlobalPluginNotificationHandler | ||
import net.juniper.contrail.api.ApiConnector | ||
import net.juniper.contrail.vro.base.ConnectionManager | ||
import net.juniper.contrail.vro.base.ConnectionPersister | ||
import net.juniper.contrail.vro.base.ConnectorFactory | ||
import net.juniper.contrail.vro.base.DefaultConnectionRepository | ||
import net.juniper.contrail.vro.model.Connection | ||
import net.juniper.contrail.vro.model.ConnectionInfo | ||
|
||
import static net.juniper.contrail.vro.config.Actions.defaultConnection | ||
|
||
class DefaultConnectionSpec extends ActionSpec { | ||
def defaultConnectionAction = actionFromScript(defaultConnection) | ||
|
||
def persister = Stub(ConnectionPersister) | ||
def notifier = Stub(GlobalPluginNotificationHandler) | ||
def connectorFactory = Stub(ConnectorFactory) | ||
def connector = Stub(ApiConnector) | ||
|
||
def connection1 = new Connection(new ConnectionInfo("c1", "1.2.3.4", 22), connector) | ||
def connection2 = new Connection(new ConnectionInfo("c2", "4.3.2.1", 33), connector) | ||
|
||
def repository = new DefaultConnectionRepository(persister) | ||
def connectionManager = new ConnectionManager(repository, connectorFactory, notifier) | ||
|
||
@Override | ||
def additionalSetup() { | ||
addToContext("ContrailConnectionManager", connectionManager) | ||
} | ||
|
||
def "Default connection is null when there are no connections"() { | ||
given: | ||
|
||
when: | ||
def result = engine.invokeFunction(defaultConnectionAction) | ||
|
||
then: | ||
result == null | ||
} | ||
def "Default connection is returned if only one connection is present in the repository"() { | ||
given: | ||
repository.addConnection(connection1) | ||
|
||
when: | ||
def result = engine.invokeFunction(defaultConnectionAction) | ||
|
||
then: | ||
result == connection1 | ||
} | ||
def "Default connection is null when there is more than one connection"() { | ||
given: | ||
repository.addConnection(connection1) | ||
repository.addConnection(connection2) | ||
|
||
when: | ||
def result = engine.invokeFunction(defaultConnectionAction) | ||
|
||
then: | ||
result == null | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
o11nplugin-contrail-workflows/src/main/js/actions/defaultConnection.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
var connections = ContrailConnectionManager.connections; | ||
if (connections.length == 1) { | ||
var connectionId = connections[0].name; | ||
return ContrailConnectionManager.connection(connectionId); | ||
} | ||
return null; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters