import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Optional;
-
import org.json.JSONObject;
import org.junit.Before;
import org.junit.Test;
public void setUp() throws Exception {
dataBroker = getDataBroker();
domDataBroker = getDomBroker();
- SchemaContext sc = YangParserTestUtils.parseYangSource(
+ SchemaContext sc = YangParserTestUtils.parseYangResource(
"/instanceidentifier/yang/instance-identifier-patch-module.yang");
ControllerContext.getInstance().setGlobalSchema(sc);
}
private String lastNotification = null;
- ListenerAdapterTester(YangInstanceIdentifier path, String streamName,
- NotificationOutputTypeGrouping.NotificationOutputType outputType, boolean leafNodesOnly) {
+ ListenerAdapterTester(final YangInstanceIdentifier path, final String streamName,
+ final NotificationOutputTypeGrouping.NotificationOutputType outputType,
+ final boolean leafNodesOnly) {
super(path, streamName, outputType);
setQueryParams(EPOCH, Optional.empty(), Optional.empty(), leafNodesOnly);
}
this.lastNotification = event.getData();
}
- public void assertGot(String json) throws Exception {
+ public void assertGot(final String json) throws Exception {
long start = System.currentTimeMillis();
while (true) {
if (lastNotification != null) {
if (System.currentTimeMillis() - start > 1000) {
throw new Exception("TIMED OUT waiting for notification with " + json);
}
- Thread.currentThread().sleep(200);
+ Thread.currentThread();
+ Thread.sleep(200);
}
LOG.debug("Comparing {} {}", json, lastNotification);
JSONAssert.assertEquals(json, withFakeDate(lastNotification), false);
}
}
- static String withFakeDate(String in) {
+ static String withFakeDate(final String in) {
JSONObject doc = new JSONObject(in);
JSONObject notification = doc.getJSONObject("notification");
if (notification == null) {
return doc.toString();
}
- private String getNotifJson(String path) throws IOException, URISyntaxException {
+ private String getNotifJson(final String path) throws IOException, URISyntaxException {
URL url = getClass().getResource(path);
byte[] bytes = Files.readAllBytes(Paths.get(url.toURI()));
return withFakeDate(new String(bytes, StandardCharsets.UTF_8));