Code Review
/
nonrtric.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Bugfix
[nonrtric.git]
/
policy-agent
/
src
/
test
/
java
/
org
/
oransc
/
policyagent
/
ApplicationTest.java
diff --git
a/policy-agent/src/test/java/org/oransc/policyagent/ApplicationTest.java
b/policy-agent/src/test/java/org/oransc/policyagent/ApplicationTest.java
index
b7e9a4b
..
4e3fd0f
100644
(file)
--- a/
policy-agent/src/test/java/org/oransc/policyagent/ApplicationTest.java
+++ b/
policy-agent/src/test/java/org/oransc/policyagent/ApplicationTest.java
@@
-184,7
+184,7
@@
public class ApplicationTest {
ric.getLock().lockBlocking(LockType.EXCLUSIVE);
ric.getLock().unlockBlocking();
assertThat(ric.getLock().getLockCounter()).isEqualTo(0);
ric.getLock().lockBlocking(LockType.EXCLUSIVE);
ric.getLock().unlockBlocking();
assertThat(ric.getLock().getLockCounter()).isEqualTo(0);
- assertThat(ric.getState()).isEqualTo(Ric.RicState.
ID
LE);
+ assertThat(ric.getState()).isEqualTo(Ric.RicState.
AVAILAB
LE);
}
}
}
}
@@
-211,7
+211,7
@@
public class ApplicationTest {
@Test
public void testSynchronization() throws Exception {
@Test
public void testSynchronization() throws Exception {
- addRic("ric").setState(Ric.RicState.UN
DEFINED
);
+ addRic("ric").setState(Ric.RicState.UN
AVAILABLE
);
String ricName = "ric";
Policy policy2 = addPolicy("policyId2", "typeName", "service", ricName);
String ricName = "ric";
Policy policy2 = addPolicy("policyId2", "typeName", "service", ricName);
@@
-222,7
+222,7
@@
public class ApplicationTest {
Policy policy = addPolicy(policyId, "typeName", "service", ricName); // This should be created in the RIC
supervision.checkAllRics(); // The created policy should be put in the RIC
await().untilAsserted(() -> RicState.SYNCHRONIZING.equals(rics.getRic(ricName).getState()));
Policy policy = addPolicy(policyId, "typeName", "service", ricName); // This should be created in the RIC
supervision.checkAllRics(); // The created policy should be put in the RIC
await().untilAsserted(() -> RicState.SYNCHRONIZING.equals(rics.getRic(ricName).getState()));
- await().untilAsserted(() -> RicState.
ID
LE.equals(rics.getRic(ricName).getState()));
+ await().untilAsserted(() -> RicState.
AVAILAB
LE.equals(rics.getRic(ricName).getState()));
Policies ricPolicies = getA1Client(ricName).getPolicies();
assertThat(ricPolicies.size()).isEqualTo(1);
Policies ricPolicies = getA1Client(ricName).getPolicies();
assertThat(ricPolicies.size()).isEqualTo(1);
@@
-247,9
+247,9
@@
public class ApplicationTest {
private String putPolicyUrl(String serviceName, String ricName, String policyTypeName, String policyInstanceId) {
if (policyTypeName.isEmpty()) {
private String putPolicyUrl(String serviceName, String ricName, String policyTypeName, String policyInstanceId) {
if (policyTypeName.isEmpty()) {
- return "/policy?i
nstance
=" + policyInstanceId + "&ric=" + ricName + "&service=" + serviceName;
+ return "/policy?i
d
=" + policyInstanceId + "&ric=" + ricName + "&service=" + serviceName;
} else {
} else {
- return "/policy?i
nstance
=" + policyInstanceId + "&ric=" + ricName + "&service=" + serviceName + "&type="
+ return "/policy?i
d
=" + policyInstanceId + "&ric=" + ricName + "&service=" + serviceName + "&type="
+ policyTypeName;
}
}
+ policyTypeName;
}
}
@@
-266,7
+266,7
@@
public class ApplicationTest {
String url = putPolicyUrl(serviceName, ricName, policyTypeName, policyInstanceId);
final String policyBody = jsonString();
String url = putPolicyUrl(serviceName, ricName, policyTypeName, policyInstanceId);
final String policyBody = jsonString();
- this.rics.getRic(ricName).setState(Ric.RicState.
ID
LE);
+ this.rics.getRic(ricName).setState(Ric.RicState.
AVAILAB
LE);
restClient().put(url, policyBody).block();
restClient().put(url, policyBody).block();
@@
-290,7
+290,7
@@
public class ApplicationTest {
url = putPolicyUrl(serviceName, ricName, policyTypeName, policyInstanceId);
this.rics.getRic(ricName).setState(Ric.RicState.SYNCHRONIZING);
testErrorCode(restClient().put(url, policyBody), HttpStatus.LOCKED);
url = putPolicyUrl(serviceName, ricName, policyTypeName, policyInstanceId);
this.rics.getRic(ricName).setState(Ric.RicState.SYNCHRONIZING);
testErrorCode(restClient().put(url, policyBody), HttpStatus.LOCKED);
- this.rics.getRic(ricName).setState(Ric.RicState.
ID
LE);
+ this.rics.getRic(ricName).setState(Ric.RicState.
AVAILAB
LE);
}
@Test
}
@Test
@@
-320,17
+320,17
@@
public class ApplicationTest {
// DELETE POLICY
this.addPolicy("instance1", "type1", "service1", "ric1");
doReturn(Mono.error(a1Exception)).when(a1Client).deletePolicy(any());
// DELETE POLICY
this.addPolicy("instance1", "type1", "service1", "ric1");
doReturn(Mono.error(a1Exception)).when(a1Client).deletePolicy(any());
- testErrorCode(restClient().delete("/policy?i
nstance
=instance1"), httpStatus, responseBody);
+ testErrorCode(restClient().delete("/policy?i
d
=instance1"), httpStatus, responseBody);
// GET STATUS
this.addPolicy("instance1", "type1", "service1", "ric1");
doReturn(Mono.error(a1Exception)).when(a1Client).getPolicyStatus(any());
// GET STATUS
this.addPolicy("instance1", "type1", "service1", "ric1");
doReturn(Mono.error(a1Exception)).when(a1Client).getPolicyStatus(any());
- testErrorCode(restClient().get("/policy_status?i
nstance
=instance1"), httpStatus, responseBody);
+ testErrorCode(restClient().get("/policy_status?i
d
=instance1"), httpStatus, responseBody);
// Check that empty response body is OK
a1Exception = new WebClientResponseException(httpStatus.value(), "", null, null, null, null);
doReturn(Mono.error(a1Exception)).when(a1Client).getPolicyStatus(any());
// Check that empty response body is OK
a1Exception = new WebClientResponseException(httpStatus.value(), "", null, null, null, null);
doReturn(Mono.error(a1Exception)).when(a1Client).getPolicyStatus(any());
- testErrorCode(restClient().get("/policy_status?i
nstance
=instance1"), httpStatus);
+ testErrorCode(restClient().get("/policy_status?i
d
=instance1"), httpStatus);
}
@Test
}
@Test
@@
-355,6
+355,7
@@
public class ApplicationTest {
this.addRic("ric1");
this.addRic("ricXXX");
this.addPolicy("instance1", "type1", "service1", "ric1");
this.addRic("ric1");
this.addRic("ricXXX");
this.addPolicy("instance1", "type1", "service1", "ric1");
+ this.addPolicy("instance2", "type1", "service1", "ricXXX");
// Try change ric1 -> ricXXX
String urlWrongRic = putPolicyUrl("service1", "ricXXX", "type1", "instance1");
// Try change ric1 -> ricXXX
String urlWrongRic = putPolicyUrl("service1", "ricXXX", "type1", "instance1");
@@
-363,7
+364,7
@@
public class ApplicationTest {
@Test
public void testGetPolicy() throws Exception {
@Test
public void testGetPolicy() throws Exception {
- String url = "/policy?i
nstance
=id";
+ String url = "/policy?i
d
=id";
Policy policy = addPolicy("id", "typeName", "service1", "ric1");
{
String rsp = restClient().get(url).block();
Policy policy = addPolicy("id", "typeName", "service1", "ric1");
{
String rsp = restClient().get(url).block();
@@
-380,7
+381,7
@@
public class ApplicationTest {
addPolicy("id", "typeName", "service1", "ric1");
assertThat(policies.size()).isEqualTo(1);
addPolicy("id", "typeName", "service1", "ric1");
assertThat(policies.size()).isEqualTo(1);
- String url = "/policy?i
nstance
=id";
+ String url = "/policy?i
d
=id";
ResponseEntity<String> entity = restClient().deleteForEntity(url).block();
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT);
ResponseEntity<String> entity = restClient().deleteForEntity(url).block();
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.NO_CONTENT);
@@
-542,7
+543,7
@@
public class ApplicationTest {
// Keep alive
url = "/services/keepalive?name=name";
// Keep alive
url = "/services/keepalive?name=name";
- ResponseEntity<String> entity = restClient().p
ostForEntity(url, nul
l).block();
+ ResponseEntity<String> entity = restClient().p
utForEntity(ur
l).block();
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
// DELETE service
assertThat(entity.getStatusCode()).isEqualTo(HttpStatus.OK);
// DELETE service
@@
-552,11
+553,14
@@
public class ApplicationTest {
assertThat(services.size()).isEqualTo(0);
// Keep alive, no registerred service
assertThat(services.size()).isEqualTo(0);
// Keep alive, no registerred service
- testErrorCode(restClient().p
os
t("/services/keepalive?name=name", ""), HttpStatus.NOT_FOUND);
+ testErrorCode(restClient().p
u
t("/services/keepalive?name=name", ""), HttpStatus.NOT_FOUND);
- // PUT servive with
crap
payload
+ // PUT servive with
bad
payload
testErrorCode(restClient().put("/service", "crap"), HttpStatus.BAD_REQUEST);
testErrorCode(restClient().put("/service", "{}"), HttpStatus.BAD_REQUEST);
testErrorCode(restClient().put("/service", "crap"), HttpStatus.BAD_REQUEST);
testErrorCode(restClient().put("/service", "{}"), HttpStatus.BAD_REQUEST);
+ testErrorCode(restClient().put("/service", createServiceJson("name", -123)), HttpStatus.BAD_REQUEST);
+ testErrorCode(restClient().put("/service", createServiceJson("name", 0, "missing.portandprotocol.com")),
+ HttpStatus.BAD_REQUEST);
// GET non existing servive
testErrorCode(restClient().get("/services?name=XXX"), HttpStatus.NOT_FOUND);
// GET non existing servive
testErrorCode(restClient().get("/services?name=XXX"), HttpStatus.NOT_FOUND);
@@
-584,12
+588,12
@@
public class ApplicationTest {
addPolicy("id", "typeName", "service1", "ric1");
assertThat(policies.size()).isEqualTo(1);
addPolicy("id", "typeName", "service1", "ric1");
assertThat(policies.size()).isEqualTo(1);
- String url = "/policy_status?i
nstance
=id";
+ String url = "/policy_status?i
d
=id";
String rsp = restClient().get(url).block();
assertThat(rsp.equals("OK")).isTrue();
// GET non existing policy status
String rsp = restClient().get(url).block();
assertThat(rsp.equals("OK")).isTrue();
// GET non existing policy status
- url = "/policy_status?i
nstance
=XXX";
+ url = "/policy_status?i
d
=XXX";
testErrorCode(restClient().get(url), HttpStatus.NOT_FOUND);
}
testErrorCode(restClient().get(url), HttpStatus.NOT_FOUND);
}
@@
-610,7
+614,11
@@
public class ApplicationTest {
}
private String createServiceJson(String name, long keepAliveIntervalSeconds) {
}
private String createServiceJson(String name, long keepAliveIntervalSeconds) {
- ServiceRegistrationInfo service = new ServiceRegistrationInfo(name, keepAliveIntervalSeconds, "callbackUrl");
+ return createServiceJson(name, keepAliveIntervalSeconds, "https://examples.javacodegeeks.com/core-java/");
+ }
+
+ private String createServiceJson(String name, long keepAliveIntervalSeconds, String url) {
+ ServiceRegistrationInfo service = new ServiceRegistrationInfo(name, keepAliveIntervalSeconds, url);
String json = gson.toJson(service);
return json;
String json = gson.toJson(service);
return json;
@@
-717,7
+725,7
@@
public class ApplicationTest {
.controllerName("") //
.build();
Ric ric = new Ric(conf);
.controllerName("") //
.build();
Ric ric = new Ric(conf);
- ric.setState(Ric.RicState.
ID
LE);
+ ric.setState(Ric.RicState.
AVAILAB
LE);
this.rics.put(ric);
return ric;
}
this.rics.put(ric);
return ric;
}