Toggle navigation
Toggle navigation
This project
Loading...
Sign in
홍길동
/
onos
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
Ray Milkey
2015-05-13 15:42:50 -0700
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
1534f8df8fc1cfb831e74f18345445a7c06156d4
1534f8df
1 parent
47dbe17c
Add intent state to JSON output
Change-Id: I3a5995e0dfdc83e1253b8e414e825b796a57264c
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
6 deletions
core/api/src/test/java/org/onosproject/net/intent/IntentServiceAdapter.java
core/common/src/main/java/org/onosproject/codec/impl/IntentCodec.java
core/common/src/test/java/org/onosproject/codec/impl/IntentCodecTest.java
web/api/src/test/java/org/onosproject/rest/IntentsResourceTest.java
core/api/src/test/java/org/onosproject/net/intent/IntentServiceAdapter.java
View file @
1534f8d
...
...
@@ -54,7 +54,7 @@ public class IntentServiceAdapter implements IntentService {
@Override
public
IntentState
getIntentState
(
Key
intentKey
)
{
return
null
;
return
IntentState
.
INSTALLED
;
}
@Override
...
...
core/common/src/main/java/org/onosproject/codec/impl/IntentCodec.java
View file @
1534f8d
...
...
@@ -19,6 +19,8 @@ import org.onosproject.codec.CodecContext;
import
org.onosproject.codec.JsonCodec
;
import
org.onosproject.net.NetworkResource
;
import
org.onosproject.net.intent.Intent
;
import
org.onosproject.net.intent.IntentService
;
import
org.onosproject.net.intent.IntentState
;
import
com.fasterxml.jackson.databind.node.ArrayNode
;
import
com.fasterxml.jackson.databind.node.ObjectNode
;
...
...
@@ -44,6 +46,11 @@ public final class IntentCodec extends JsonCodec<Intent> {
for
(
final
NetworkResource
resource
:
intent
.
resources
())
{
jsonResources
.
add
(
resource
.
toString
());
}
IntentService
service
=
context
.
getService
(
IntentService
.
class
);
IntentState
state
=
service
.
getIntentState
(
intent
.
key
());
result
.
put
(
"state"
,
state
.
toString
());
return
result
;
}
}
...
...
core/common/src/test/java/org/onosproject/codec/impl/IntentCodecTest.java
View file @
1534f8d
...
...
@@ -18,12 +18,12 @@ package org.onosproject.codec.impl;
import
java.time.Duration
;
import
java.util.List
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.onlab.packet.IpPrefix
;
import
org.onlab.packet.MacAddress
;
import
org.onlab.packet.MplsLabel
;
import
org.onlab.util.Bandwidth
;
import
org.onosproject.codec.CodecContext
;
import
org.onosproject.codec.JsonCodec
;
import
org.onosproject.core.ApplicationId
;
import
org.onosproject.core.DefaultApplicationId
;
...
...
@@ -39,6 +39,8 @@ import org.onosproject.net.flow.TrafficTreatment;
import
org.onosproject.net.intent.AbstractIntentTest
;
import
org.onosproject.net.intent.Constraint
;
import
org.onosproject.net.intent.HostToHostIntent
;
import
org.onosproject.net.intent.IntentService
;
import
org.onosproject.net.intent.IntentServiceAdapter
;
import
org.onosproject.net.intent.PointToPointIntent
;
import
org.onosproject.net.intent.constraint.AnnotationConstraint
;
import
org.onosproject.net.intent.constraint.AsymmetricPathConstraint
;
...
...
@@ -71,7 +73,13 @@ public class IntentCodecTest extends AbstractIntentTest {
DefaultTrafficSelector
.
emptySelector
();
final
TrafficTreatment
emptyTreatment
=
DefaultTrafficTreatment
.
emptyTreatment
();
private
final
CodecContext
context
=
new
MockCodecContext
();
private
final
MockCodecContext
context
=
new
MockCodecContext
();
@Before
public
void
setUpIntentService
()
{
final
IntentService
mockIntentService
=
new
IntentServiceAdapter
();
context
.
registerService
(
IntentService
.
class
,
mockIntentService
);
}
/**
* Tests the encoding of a host to host intent.
...
...
@@ -109,7 +117,6 @@ public class IntentCodecTest extends AbstractIntentTest {
.
ingressPoint
(
ingress
)
.
egressPoint
(
egress
).
build
();
final
CodecContext
context
=
new
MockCodecContext
();
final
JsonCodec
<
PointToPointIntent
>
intentCodec
=
context
.
codec
(
PointToPointIntent
.
class
);
assertThat
(
intentCodec
,
notNullValue
());
...
...
@@ -165,7 +172,6 @@ public class IntentCodecTest extends AbstractIntentTest {
.
build
();
final
CodecContext
context
=
new
MockCodecContext
();
final
JsonCodec
<
PointToPointIntent
>
intentCodec
=
context
.
codec
(
PointToPointIntent
.
class
);
assertThat
(
intentCodec
,
notNullValue
());
...
...
web/api/src/test/java/org/onosproject/rest/IntentsResourceTest.java
View file @
1534f8d
...
...
@@ -35,6 +35,7 @@ import org.onosproject.core.IdGenerator;
import
org.onosproject.net.NetworkResource
;
import
org.onosproject.net.intent.Intent
;
import
org.onosproject.net.intent.IntentService
;
import
org.onosproject.net.intent.IntentState
;
import
org.onosproject.net.intent.Key
;
import
org.onosproject.net.intent.MockIdGenerator
;
...
...
@@ -44,6 +45,7 @@ import com.eclipsesource.json.JsonValue;
import
com.sun.jersey.api.client.UniformInterfaceException
;
import
com.sun.jersey.api.client.WebResource
;
import
static
org
.
easymock
.
EasyMock
.
anyObject
;
import
static
org
.
easymock
.
EasyMock
.
createMock
;
import
static
org
.
easymock
.
EasyMock
.
expect
;
import
static
org
.
easymock
.
EasyMock
.
replay
;
...
...
@@ -121,6 +123,13 @@ public class IntentsResourceTest extends ResourceTest {
return
false
;
}
// check state field
final
String
jsonState
=
jsonIntent
.
get
(
"state"
).
asString
();
if
(!
jsonState
.
equals
(
"INSTALLED"
))
{
reason
=
"state INSTALLED"
;
return
false
;
}
// check resources array
final
JsonArray
jsonResources
=
jsonIntent
.
get
(
"resources"
).
asArray
();
if
(
intent
.
resources
()
!=
null
)
{
...
...
@@ -180,7 +189,7 @@ public class IntentsResourceTest extends ResourceTest {
@Override
public
boolean
matchesSafely
(
JsonArray
json
)
{
boolean
intentFound
=
false
;
final
int
expectedAttributes
=
5
;
final
int
expectedAttributes
=
6
;
for
(
int
jsonIntentIndex
=
0
;
jsonIntentIndex
<
json
.
size
();
jsonIntentIndex
++)
{
...
...
@@ -229,6 +238,9 @@ public class IntentsResourceTest extends ResourceTest {
@Before
public
void
setUpTest
()
{
expect
(
mockIntentService
.
getIntents
()).
andReturn
(
intents
).
anyTimes
();
expect
(
mockIntentService
.
getIntentState
(
anyObject
()))
.
andReturn
(
IntentState
.
INSTALLED
)
.
anyTimes
();
// Register the services needed for the test
final
CodecManager
codecService
=
new
CodecManager
();
codecService
.
activate
();
...
...
Please
register
or
login
to post a comment