Merge branch 'master' into compendiumR6merge
Conflicts:
platform/northbound/jsonpath-filtering/json-path/pom.xml
diff --git a/distribution/sensinact-distribution-generator/profile/jsonpath-profile/pom.xml b/distribution/sensinact-distribution-generator/profile/jsonpath-profile/pom.xml
index b432229..c586585 100644
--- a/distribution/sensinact-distribution-generator/profile/jsonpath-profile/pom.xml
+++ b/distribution/sensinact-distribution-generator/profile/jsonpath-profile/pom.xml
@@ -25,7 +25,7 @@
<packaging>pom</packaging>
<name>sensiNact IoT Gateway - sensiNact Runtime (${project.artifactId} bridge dependencies)</name>
-
+
<build>
<plugins>
<plugin>
@@ -39,7 +39,7 @@
<goal>copy-dependencies</goal>
</goals>
<configuration>
- <outputDirectory>${project.build.directory}/sensinact/load/${project.artifactId}</outputDirectory>
+ <outputDirectory>${project.build.directory}/sensinact/load/${artifactId}</outputDirectory>
<excludeArtifactIds>${excludeArtifactId}</excludeArtifactIds>
<excludeGroupIds>${excludeGroupId}</excludeGroupIds>
<excludeTransitive>${excludeTransitive}</excludeTransitive>
@@ -48,70 +48,26 @@
<inherited>false</inherited>
</execution>
</executions>
- </plugin>
- <plugin>
- <groupId>org.codehaus.gmaven</groupId>
- <artifactId>groovy-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>search-dependency</id>
- <phase>generate-resources</phase>
- <goals>
- <goal>execute</goal>
- </goals>
- <configuration>
- <defaults>
- <name>search-dependency</name>
- </defaults>
- <source>
- String basedir = project.basedir.absolutePath.replace('\\','/');
- File parent = new File(basedir).getParentFile().getParentFile().getParentFile().getParentFile();
-
- File a = new File(parent, "platform/northbound/jsonpath-filtering/json-path/target/json-path-2.4.0.jar");
- File b = new File(parent, "platform/northbound/jsonpath-filtering/json-provider-minimal/target/json-provider-minimal-2.0-SNAPSHOT.jar");
- File c = new File(parent, "platform/northbound/jsonpath-filtering/jsonpath-filter/target/jsonpath-filter-2.0-SNAPSHOT.jar");
-
- if((!a.exists())||(!b.exists())||(!c.exists()))
- {
- project.getCompileSourceRoots().clear();
- project.getTestCompileSourceRoots().clear();
-
- } else
- {
- File dir = new File(new File(basedir),'target/sensinact/load/json-path');
- if(!dir.exists())
- {
- dir.mkdirs();
- }
- def newFile = new File(dir,'json-path-2.4.0.jar');
- newFile.createNewFile();
-
- output = newFile.newOutputStream();
- a.newInputStream().eachByte(1024,
- {data, lenth -> output.write(data, 0, lenth)});
- output.close();
-
- newFile = new File(dir,'json-provider-minimal-2.0-SNAPSHOT.jar');
- newFile.createNewFile();
-
- output = newFile.newOutputStream();
- b.newInputStream().eachByte(1024,
- {data, lenth -> output.write(data, 0, lenth)});
- output.close();
-
- newFile = new File(dir,'jsonpath-filter-2.0-SNAPSHOT.jar');
- newFile.createNewFile();
-
- output = newFile.newOutputStream();
- c.newInputStream().eachByte(1024,
- {data, lenth -> output.write(data, 0, lenth)});
- output.close();
- }
- </source>
- </configuration>
- </execution>
- </executions>
- </plugin>
+ </plugin>
</plugins>
</build>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.eclipse.sensinact.gateway.nthbnd</groupId>
+ <artifactId>jsonpath-filter</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>com.jayway.jsonpath</groupId>
+ <artifactId>json-path</artifactId>
+ <version>2.4.0</version>
+ </dependency>
+ <dependency>
+ <groupId>net.minidev</groupId>
+ <artifactId>json-smart</artifactId>
+ <version>2.3</version>
+ </dependency>
+ </dependencies>
+
</project>
diff --git a/platform/northbound/jsonpath-filtering/json-path/pom.xml b/platform/northbound/jsonpath-filtering/json-path/pom.xml
deleted file mode 100644
index 2063b02..0000000
--- a/platform/northbound/jsonpath-filtering/json-path/pom.xml
+++ /dev/null
@@ -1,141 +0,0 @@
-<!--
- ~ Copyright (c) 2017 CEA.
- ~ All rights reserved. This program and the accompanying materials
- ~ are made available under the terms of the Eclipse Public License v1.0
- ~ which accompanies this distribution, and is available at
- ~ http://www.eclipse.org/legal/epl-v10.html
- ~
- ~ Contributors:
- ~ CEA - initial API and implementation
- -->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.eclipse.sensinact.gateway.nthbnd</groupId>
- <artifactId>jsonpath-filtering</artifactId>
- <version>2.0-SNAPSHOT</version>
- </parent>
-
- <groupId>com.jayway.jsonpath</groupId>
- <artifactId>json-path</artifactId>
- <version>2.4.0</version>
- <packaging>jar</packaging>
-
- <name>sensiNact IoT Gateway - JsonPath</name>
-
- <properties>
- <tmp.repository>${project.build.directory}</tmp.repository>
- </properties>
-
- <scm>
- <connection>scm:git:https://github.com/cmunilla/JsonPath.git</connection>
- </scm>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-scm-plugin</artifactId>
- <version>1.9.4</version>
- <executions>
- <execution>
- <phase>validate</phase>
- <goals>
- <goal>checkout</goal>
- </goals>
- </execution>
- </executions>
- <configuration>
- <checkoutDirectory>${tmp.repository}/JsonPath</checkoutDirectory>
- <connectionType>connection</connectionType>
- <scmVersionType>revision</scmVersionType>
- <scmVersion>03c9514c5d22808821dec7de8884f65ba0eabe97</scmVersion>
- <excludes>
- .git,
- json-provider,
- json-path-web-test,
- json-path-assert
- </excludes>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.fortasoft</groupId>
- <artifactId>gradle-maven-plugin</artifactId>
- <version>1.0.8</version>
- <configuration>
- <tasks>
- <task>:json-path:compileJava</task>
- <task>:json-path:assemble</task>
- </tasks>
- <gradleProjectDirectory>${tmp.repository}/JsonPath</gradleProjectDirectory>
- </configuration>
- <executions>
- <execution>
- <phase>compile</phase>
- <goals>
- <goal>invoke</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <skip>true</skip>
- </configuration>
- </plugin>
- <plugin>
- <artifactId>maven-jar-plugin</artifactId>
- <configuration>
- <skip>true</skip>
- </configuration>
- </plugin>
- <plugin>
- <artifactId>maven-install-plugin</artifactId>
- <configuration>
- <skip>true</skip>
- </configuration>
- </plugin>
- <plugin>
- <artifactId>maven-deploy-plugin</artifactId>
- <configuration>
- <skip>true</skip>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-antrun-plugin</artifactId>
- <version>1.8</version>
- <executions>
- <execution>
- <id>copy-built-jar</id>
- <phase>install</phase>
- <configuration>
- <target>
- <delete file="${project.build.directory}/json-path-2.4.0.jar" />
- <copy todir="${project.build.directory}"
- file="${tmp.repository}/JsonPath/json-path/build/libs/json-path-2.4.0.jar" />
- </target>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-
- <dependencies>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- <version>1.7.25</version>
- <scope>provided</scope>
- </dependency>
- </dependencies>
-
-</project>
diff --git a/platform/northbound/jsonpath-filtering/json-provider-minimal/pom.xml b/platform/northbound/jsonpath-filtering/json-provider-minimal/pom.xml
deleted file mode 100644
index 8142c86..0000000
--- a/platform/northbound/jsonpath-filtering/json-provider-minimal/pom.xml
+++ /dev/null
@@ -1,176 +0,0 @@
-<!--
- ~ Copyright (c) 2017 CEA.
- ~ All rights reserved. This program and the accompanying materials
- ~ are made available under the terms of the Eclipse Public License v1.0
- ~ which accompanies this distribution, and is available at
- ~ http://www.eclipse.org/legal/epl-v10.html
- ~
- ~ Contributors:
- ~ CEA - initial API and implementation
- -->
-
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.eclipse.sensinact.gateway.nthbnd</groupId>
- <artifactId>jsonpath-filtering</artifactId>
- <version>2.0-SNAPSHOT</version>
- </parent>
-
- <artifactId>json-provider-minimal</artifactId>
-
- <name>sensiNact IoT Gateway - JsonPath Provider </name>
- <packaging>bundle</packaging>
-
- <dependencies>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- <version>1.7.25</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.json</groupId>
- <artifactId>json</artifactId>
- <version>20080701</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.assertj</groupId>
- <artifactId>assertj-core</artifactId>
- <version>2.1.0</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.hamcrest</groupId>
- <artifactId>hamcrest-core</artifactId>
- <version>1.3</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.hamcrest</groupId>
- <artifactId>hamcrest-library</artifactId>
- <version>1.3</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
- <version>2.4</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-simple</artifactId>
- <version>1.7.16</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.12</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.codehaus.gmaven</groupId>
- <artifactId>groovy-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>search-dependency</id>
- <phase>validate</phase>
- <goals>
- <goal>execute</goal>
- </goals>
- <configuration>
- <defaults>
- <name>search-dependency</name>
- </defaults>
- <source>
- String basedir = project.basedir.absolutePath.replace('\\','/');
- File dependencyFile = new File(new File(basedir).getParentFile(), "json-path/target/json-path-2.4.0.jar");
-
- if(!dependencyFile.exists())
- {
- project.getCompileSourceRoots().clear();
- project.getTestCompileSourceRoots().clear();
-
-
- org.apache.maven.plugin.internal.DefaultPluginManager
- manager = session.getContainer().lookup(
- org.apache.maven.plugin.PluginManager.class.getName());
-
- log.info('{}',manager);
-
- } else
- {
- org.apache.maven.artifact.Artifact artifact =
- new org.apache.maven.artifact.DefaultArtifact('com.jayway.jsonpath',
- 'json-path',
- org.apache.maven.artifact.versioning.VersionRange.createFromVersionSpec('2.4.0'),
- org.apache.maven.artifact.Artifact.SCOPE_SYSTEM,
- 'jar', '',
- new org.apache.maven.artifact.handler.DefaultArtifactHandler('jar')
- {
- @Override
- public boolean isAddedToClasspath()
- {
- return true;
- }
-
- @Override
- public boolean isIncludesDependencies()
- {
- return true;
- }
-
- @Override
- public String getDirectory()
- {
- return dependencyFile.getParentFile().getAbsolutePath();
- }
- },
- false);
- artifact.setFile(dependencyFile);
- project.getDependencyArtifacts().add(artifact);
- }
- </source>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.7</source>
- <target>1.7</target>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
- <Bundle-Name>${project.name}</Bundle-Name>
- <Bundle-Vendor>Eclipse</Bundle-Vendor>
- <Build-By>Eclipse</Build-By>
- <Bundle-Description>${project.name}</Bundle-Description>
- <_nouses>true</_nouses>
- <_failok>true</_failok>
- <_noee>true</_noee>
- <Fragment-Host>com.jayway.jsonpath.json-path</Fragment-Host>
- <Provide-Capability>json-path-provider</Provide-Capability>
- <Export-Package></Export-Package>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/main/java/org/eclipse/sensinact/gateway/nthbnd/jsonpath/JsonOrgDefaults.java b/platform/northbound/jsonpath-filtering/json-provider-minimal/src/main/java/org/eclipse/sensinact/gateway/nthbnd/jsonpath/JsonOrgDefaults.java
deleted file mode 100644
index 216325e..0000000
--- a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/main/java/org/eclipse/sensinact/gateway/nthbnd/jsonpath/JsonOrgDefaults.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (c) 2017 CEA.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA - initial API and implementation
- */
-package org.eclipse.sensinact.gateway.nthbnd.jsonpath;
-
-import com.jayway.jsonpath.Defaults;
-import com.jayway.jsonpath.Option;
-import com.jayway.jsonpath.spi.builder.NodeBuilder;
-import com.jayway.jsonpath.spi.json.JsonProvider;
-import com.jayway.jsonpath.spi.mapper.MappingProvider;
-import org.eclipse.sensinact.gateway.nthbnd.jsonpath.builder.JsonOrgNodeBuilder;
-import org.eclipse.sensinact.gateway.nthbnd.jsonpath.json.JsonOrgJsonProvider;
-import org.eclipse.sensinact.gateway.nthbnd.jsonpath.mapper.JsonOrgMappingProvider;
-
-import java.util.EnumSet;
-import java.util.Set;
-
-/**
- * @author <a href="mailto:christophe.munilla@cea.fr">Christophe Munilla</a>
- */
-public class JsonOrgDefaults implements Defaults {
- private final MappingProvider mappingProvider = new JsonOrgMappingProvider();
-
- public JsonOrgDefaults() {
- }
-
- /**
- * @inheritDoc
- * @see com.jayway.jsonpath.Defaults#jsonProvider()
- */
- @Override
- public JsonProvider jsonProvider() {
- return new JsonOrgJsonProvider();
- }
-
- /**
- * @inheritDoc
- * @see com.jayway.jsonpath.Defaults#options()
- */
- @Override
- public Set<Option> options() {
- return EnumSet.noneOf(Option.class);
- }
-
- /**
- * @inheritDoc
- * @see com.jayway.jsonpath.Defaults#mappingProvider()
- */
- @Override
- public MappingProvider mappingProvider() {
- return mappingProvider;
- }
-
- /**
- * @inheritDoc
- * @see com.jayway.jsonpath.Defaults#nodeBuilder()
- */
- @Override
- public NodeBuilder nodeBuilder() {
- return new JsonOrgNodeBuilder();
- }
-}
diff --git a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/main/java/org/eclipse/sensinact/gateway/nthbnd/jsonpath/JsonOrgJson.java b/platform/northbound/jsonpath-filtering/json-provider-minimal/src/main/java/org/eclipse/sensinact/gateway/nthbnd/jsonpath/JsonOrgJson.java
deleted file mode 100644
index 2d22315..0000000
--- a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/main/java/org/eclipse/sensinact/gateway/nthbnd/jsonpath/JsonOrgJson.java
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * Copyright (c) 2017 CEA.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA - initial API and implementation
- */
-package org.eclipse.sensinact.gateway.nthbnd.jsonpath;
-
-/**
- * @author <a href="mailto:christophe.munilla@cea.fr">Christophe Munilla</a>
- */
-public interface JsonOrgJson {
-}
diff --git a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/main/java/org/eclipse/sensinact/gateway/nthbnd/jsonpath/JsonOrgJsonArray.java b/platform/northbound/jsonpath-filtering/json-provider-minimal/src/main/java/org/eclipse/sensinact/gateway/nthbnd/jsonpath/JsonOrgJsonArray.java
deleted file mode 100644
index feb5b6d..0000000
--- a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/main/java/org/eclipse/sensinact/gateway/nthbnd/jsonpath/JsonOrgJsonArray.java
+++ /dev/null
@@ -1,262 +0,0 @@
-/*
- * Copyright (c) 2017 CEA.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA - initial API and implementation
- */
-package org.eclipse.sensinact.gateway.nthbnd.jsonpath;
-
-import org.json.JSONArray;
-import org.json.JSONException;
-
-import java.lang.reflect.Field;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-
-/**
- * @author <a href="mailto:christophe.munilla@cea.fr">Christophe Munilla</a>
- */
-public class JsonOrgJsonArray extends JSONArray implements JsonOrgJson, List {
- /**
- * Construct an empty JSONArray.
- */
- public JsonOrgJsonArray() {
- super();
- init();
- }
-
- /**
- * Construct a JSONArray from a JSONTokener.
- *
- * @param x A JSONTokener
- * @throws JSONException If there is a syntax error.
- */
- public JsonOrgJsonArray(JsonOrgJsonTokener x) throws JSONException {
- super(x);
- init();
- }
-
- /**
- * Construct a JSONArray from a source JSON text.
- *
- * @param source A string that begins with
- * <code>[</code> <small>(left bracket)</small>
- * and ends with <code>]</code> <small>(right bracket)</small>.
- * @throws JSONException If there is a syntax error.
- */
- public JsonOrgJsonArray(String source) throws JSONException {
- this(new JsonOrgJsonTokener(source));
- init();
- }
-
- /**
- * Construct a JSONArray from a Collection.
- *
- * @param collection A Collection.
- */
- public JsonOrgJsonArray(Collection collection) {
- super(collection);
- init();
- }
-
- /**
- * Construct a JSONArray from a collection of beans.
- * The collection should have Java Beans.
- *
- * @throws JSONException If not an array.
- */
- public JsonOrgJsonArray(Collection collection, boolean includeSuperClass) {
- super(collection, includeSuperClass);
- init();
- }
-
- /**
- * Construct a JSONArray from an array
- *
- * @throws JSONException If not an array.
- */
- public JsonOrgJsonArray(Object array) throws JSONException {
- super(array);
- init();
- }
-
- /**
- * Construct a JSONArray from an array with a bean.
- * The array should have Java Beans.
- *
- * @throws JSONException If not an array.
- */
- public JsonOrgJsonArray(Object array, boolean includeSuperClass) throws JSONException {
- super(array, includeSuperClass);
- init();
- }
-
- @Override
- public int size() {
- return parentList.size();
- }
-
- @Override
- public boolean isEmpty() {
- return parentList.isEmpty();
- }
-
- @Override
- public boolean contains(Object o) {
- return parentList.contains(o);
- }
-
- @Override
- public Iterator iterator() {
- return parentList.iterator();
- }
-
- @Override
- public Object[] toArray() {
- return parentList.toArray();
- }
-
- @Override
- public Object[] toArray(Object[] a) {
- return parentList.toArray(a);
- }
-
- @Override
- public boolean add(Object e) {
- return parentList.add(e);
- }
-
- @Override
- public boolean remove(Object o) {
- return parentList.remove(o);
- }
-
- @Override
- public boolean containsAll(Collection c) {
- return parentList.containsAll(c);
- }
-
- @Override
- public boolean addAll(Collection c) {
- return parentList.addAll(c);
- }
-
- @Override
- public boolean addAll(int index, Collection c) {
- return parentList.addAll(index, c);
- }
-
- @Override
- public boolean removeAll(Collection c) {
- return parentList.removeAll(c);
- }
-
- @Override
- public boolean retainAll(Collection c) {
- return parentList.retainAll(c);
- }
-
- @Override
- public void clear() {
- parentList.clear();
- }
-
- @Override
- public Object set(int index, Object element) {
- return parentList.set(index, element);
- }
-
- @Override
- public void add(int index, Object element) {
- parentList.add(index, element);
- }
-
- @Override
- public Object remove(int index) {
- return parentList.remove(index);
- }
-
- @Override
- public int indexOf(Object o) {
- return parentList.indexOf(o);
- }
-
- @Override
- public int lastIndexOf(Object o) {
- return parentList.lastIndexOf(o);
- }
-
- @Override
- public ListIterator listIterator() {
- return parentList.listIterator();
- }
-
- @Override
- public ListIterator listIterator(int index) {
- return parentList.listIterator(index);
- }
-
- @Override
- public List subList(int fromIndex, int toIndex) {
- return new JsonOrgJsonArray(parentList.subList(fromIndex, toIndex));
- }
-
- @Override
- public Object get(int index) {
- return parentList.get(index);
- }
-
- private void init() {
- if (this.parentList != null) {
- return;
- }
- Field[] fields = JSONArray.class.getDeclaredFields();
- for (Field field : fields) {
- if (List.class.isAssignableFrom(field.getType())) {
- field.setAccessible(true);
- try {
- this.parentList = (List) field.get(this);
- } catch (Exception e) {
- e.printStackTrace();
- }
- break;
- }
- }
- }
-
- public boolean equals(Object o) {
- if (o == null) {
- return false;
- }
- if (List.class.isAssignableFrom(o.getClass()) || JsonOrgJsonArray.class.isAssignableFrom(o.getClass())) {
- return o.equals(this.parentList);
-
- }
- if (JSONArray.class.isAssignableFrom(o.getClass())) {
- int index = 0;
- int length = ((JSONArray) o).length();
- if (this.length() != length) {
- return false;
- }
- for (; index < length; index++) {
- try {
- if ((((JSONArray) o).get(index) == null && this.get(index) != null) || !((JSONArray) o).get(index).equals(this.get(index))) {
- return false;
- }
- } catch (JSONException e) {
- return false;
- }
- }
- return true;
- }
- return false;
- }
-
- private List parentList = null;
-}
diff --git a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/main/java/org/eclipse/sensinact/gateway/nthbnd/jsonpath/JsonOrgJsonObject.java b/platform/northbound/jsonpath-filtering/json-provider-minimal/src/main/java/org/eclipse/sensinact/gateway/nthbnd/jsonpath/JsonOrgJsonObject.java
deleted file mode 100644
index f7bb3d3..0000000
--- a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/main/java/org/eclipse/sensinact/gateway/nthbnd/jsonpath/JsonOrgJsonObject.java
+++ /dev/null
@@ -1,263 +0,0 @@
-/*
- * Copyright (c) 2017 CEA.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA - initial API and implementation
- */
-package org.eclipse.sensinact.gateway.nthbnd.jsonpath;
-
-import org.json.JSONException;
-import org.json.JSONObject;
-
-import java.lang.reflect.Field;
-import java.util.Collection;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * @author <a href="mailto:christophe.munilla@cea.fr">Christophe Munilla</a>
- */
-public class JsonOrgJsonObject extends JSONObject implements JsonOrgJson, Map {
- /**
- * Construct an empty JsonOrgJsonObject.
- */
- public JsonOrgJsonObject() {
- super();
- init();
- }
-
- /**
- * Construct a JsonOrgJsonObject from a subset of another JSONObject.
- * An array of strings is used to identify the keys that should be copied.
- * Missing keys are ignored.
- *
- * @param jo A JSONObject.
- * @param names An array of strings.
- * @throws JSONException If a value is a non-finite number.
- */
- public JsonOrgJsonObject(JSONObject jo, String[] names) throws JSONException {
- super(jo, names);
- init();
- }
-
- /**
- * Construct a JSONObject from a JSONTokener.
- *
- * @param x A JSONTokener object containing the source string.
- * @throws JSONException If there is a syntax error in the source string.
- */
- public JsonOrgJsonObject(JsonOrgJsonTokener x) throws JSONException {
- super(x);
- init();
- }
-
- /**
- * Construct a JSONObject from a Map.
- *
- * @param map A map object that can be used to initialize the contents of
- * the JSONObject.
- */
- public JsonOrgJsonObject(Map map) {
- super(map);
- init();
- }
-
- /**
- * Construct a JSONObject from a Map.
- * <p>
- * Note: Use this constructor when the map contains <key,bean>.
- *
- * @param map - A map with Key-Bean data.
- * @param includeSuperClass - Tell whether to include the super class properties.
- */
- public JsonOrgJsonObject(Map map, boolean includeSuperClass) {
- super(map, includeSuperClass);
- init();
- }
-
- /**
- * Construct a JSONObject from an Object using bean getters.
- * It reflects on all of the public methods of the object.
- * For each of the methods with no parameters and a name starting
- * with <code>"get"</code> or <code>"is"</code> followed by an uppercase letter,
- * the method is invoked, and a key and the value returned from the getter method
- * are put into the new JSONObject.
- * <p>
- * The key is formed by removing the <code>"get"</code> or <code>"is"</code> prefix. If the second remaining
- * character is not upper case, then the first
- * character is converted to lower case.
- * <p>
- * For example, if an object has a method named <code>"getName"</code>, and
- * if the result of calling <code>object.getName()</code> is <code>"Larry Fine"</code>,
- * then the JSONObject will contain <code>"name": "Larry Fine"</code>.
- *
- * @param bean An object that has getter methods that should be used
- * to make a JSONObject.
- */
- public JsonOrgJsonObject(Object bean) {
- super(bean);
- init();
- }
-
-
- /**
- * Construct JSONObject from the given bean. This will also create JSONObject
- * for all internal object (List, Map, Inner Objects) of the provided bean.
- * <p>
- * -- See Documentation of JSONObject(Object bean) also.
- *
- * @param bean An object that has getter methods that should be used
- * to make a JSONObject.
- * @param includeSuperClass - Tell whether to include the super class properties.
- */
- public JsonOrgJsonObject(Object bean, boolean includeSuperClass) {
- super(bean, includeSuperClass);
- init();
- }
-
- /**
- * Construct a JSONObject from an Object, using reflection to find the
- * public members. The resulting JSONObject's keys will be the strings
- * from the names array, and the values will be the field values associated
- * with those keys in the object. If a key is not found or not visible,
- * then it will not be copied into the new JSONObject.
- *
- * @param object An object that has fields that should be used to make a
- * JSONObject.
- * @param names An array of strings, the names of the fields to be obtained
- * from the object.
- */
- public JsonOrgJsonObject(Object object, String names[]) {
- super(object, names);
- init();
- }
-
- /**
- * Construct a JSONObject from a source JSON text string.
- * This is the most commonly used JSONObject constructor.
- *
- * @param source A string beginning
- * with <code>{</code> <small>(left brace)</small> and ending
- * with <code>}</code> <small>(right brace)</small>.
- * @throws JSONException If there is a syntax error in the source string.
- */
- public JsonOrgJsonObject(String source) throws JSONException {
- this(new JsonOrgJsonTokener(source));
- init();
- }
-
- @Override
- public int size() {
- return super.length();
- }
-
- @Override
- public boolean isEmpty() {
- return size() == 0;
- }
-
- @Override
- public boolean containsKey(Object key) {
- return parentMap.containsKey(key);
- }
-
- @Override
- public boolean containsValue(Object value) {
- return parentMap.containsValue(value);
- }
-
- @Override
- public void putAll(Map m) {
- parentMap.putAll(m);
- }
-
- @Override
- public void clear() {
- parentMap.clear();
- }
-
- @Override
- public Set keySet() {
- return parentMap.keySet();
- }
-
- @Override
- public Collection values() {
- return parentMap.values();
- }
-
- @Override
- public Set entrySet() {
- return parentMap.entrySet();
- }
-
- @Override
- public Object get(Object key) {
- return parentMap.get(key);
- }
-
- @Override
- public Object put(Object key, Object value) {
- return parentMap.put(key.toString(), value);
- }
-
- @Override
- public Object remove(Object key) {
- return parentMap.remove(key);
- }
-
- private final void init() {
- if (this.parentMap != null) {
- return;
- }
- Field[] fields = JSONObject.class.getDeclaredFields();
- for (Field field : fields) {
- if (Map.class.isAssignableFrom(field.getType())) {
- field.setAccessible(true);
- try {
- this.parentMap = (Map) field.get(this);
- } catch (Exception e) {
- e.printStackTrace();
- }
- break;
- }
- }
- }
-
- public boolean equals(Object o) {
- if (o == null) {
- return false;
- }
- if (Map.class.isAssignableFrom(o.getClass()) || JsonOrgJsonObject.class.isAssignableFrom(o.getClass())) {
- return o.equals(this.parentMap);
-
- }
- if (JSONObject.class.isAssignableFrom(o.getClass())) {
- int index = 0;
- int length = ((JSONObject) o).length();
-
- if (this.length() != length) {
- return false;
- }
- String[] names = JSONObject.getNames(((JSONObject) o));
-
- for (; index < length; index++) {
- try {
- if ((((JSONObject) o).get(names[index]) == null && super.get(names[index]) != null) || !((JSONObject) o).get(names[index]).equals(super.get(names[index]))) {
- return false;
- }
- } catch (JSONException e) {
- return false;
- }
- }
- return true;
- }
- return false;
- }
-
- private Map parentMap = null;
-}
diff --git a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/main/java/org/eclipse/sensinact/gateway/nthbnd/jsonpath/JsonOrgJsonTokener.java b/platform/northbound/jsonpath-filtering/json-provider-minimal/src/main/java/org/eclipse/sensinact/gateway/nthbnd/jsonpath/JsonOrgJsonTokener.java
deleted file mode 100644
index 6504aad..0000000
--- a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/main/java/org/eclipse/sensinact/gateway/nthbnd/jsonpath/JsonOrgJsonTokener.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Copyright (c) 2017 CEA.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA - initial API and implementation
- */
-package org.eclipse.sensinact.gateway.nthbnd.jsonpath;
-
-import org.json.JSONException;
-import org.json.JSONObject;
-import org.json.JSONTokener;
-
-import java.io.Reader;
-
-/**
- * @author <a href="mailto:christophe.munilla@cea.fr">Christophe Munilla</a>
- */
-public class JsonOrgJsonTokener extends JSONTokener {
- public JsonOrgJsonTokener(Reader reader) {
- super(reader);
- }
-
- public JsonOrgJsonTokener(String s) {
- super(s);
- }
-
- /**
- * Get the next value. The value can be a Boolean, Double, Integer,
- * JSONArray, JSONObject, Long, or String, or the JSONObject.NULL object.
- *
- * @return An object.
- * @throws JSONException If syntax error.
- */
- @Override
- public Object nextValue() throws JSONException {
- char c = nextClean();
- String s;
- switch (c) {
- case '"':
- case '\'':
- return nextString(c);
- case '{':
- back();
- return new JsonOrgJsonObject(this);
- case '[':
- case '(':
- back();
- return new JsonOrgJsonArray(this);
- }
- /*
- * Handle unquoted text. This could be the values true, false, or
- * null, or it can be a number. An implementation (such as this one)
- * is allowed to also accept non-standard forms.
- *
- * Accumulate characters until we reach the end of the text or a
- * formatting character.
- */
- StringBuffer sb = new StringBuffer();
- char b = c;
- while (c >= ' ' && ",:]}/\\\"[{;=#".indexOf(c) < 0) {
- sb.append(c);
- c = next();
- }
- back();
- /*
- * If it is true, false, or null, return the proper value.
- */
- s = sb.toString().trim();
- if (s.equals("")) {
- throw syntaxError("Missing value");
- }
- if (s.equalsIgnoreCase("true")) {
- return Boolean.TRUE;
- }
- if (s.equalsIgnoreCase("false")) {
- return Boolean.FALSE;
- }
- if (s.equalsIgnoreCase("null")) {
- return JSONObject.NULL;
- }
- /*
- * If it might be a number, try converting it. We support the 0- and 0x-
- * conventions. If a number cannot be produced, then the value will just
- * be a string. Note that the 0-, 0x-, plus, and implied string
- * conventions are non-standard. A JSON parser is free to accept
- * non-JSON forms as long as it accepts all correct JSON forms.
- */
- if ((b >= '0' && b <= '9') || b == '.' || b == '-' || b == '+') {
- if (b == '0') {
- if (s.length() > 2 && (s.charAt(1) == 'x' || s.charAt(1) == 'X')) {
- try {
- return new Integer(Integer.parseInt(s.substring(2), 16));
- } catch (Exception e) {
- /* Ignore the error */
- }
- } else {
- try {
- return new Integer(Integer.parseInt(s, 8));
- } catch (Exception e) {
- /* Ignore the error */
- }
- }
- }
- try {
- return new Integer(s);
- } catch (Exception e) {
- try {
- return new Long(s);
- } catch (Exception f) {
- try {
- return new Double(s);
- } catch (Exception g) {
- return s;
- }
- }
- }
- }
- return s;
- }
-}
diff --git a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/main/java/org/eclipse/sensinact/gateway/nthbnd/jsonpath/builder/JsonOrgNodeBuilder.java b/platform/northbound/jsonpath-filtering/json-provider-minimal/src/main/java/org/eclipse/sensinact/gateway/nthbnd/jsonpath/builder/JsonOrgNodeBuilder.java
deleted file mode 100644
index 5690986..0000000
--- a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/main/java/org/eclipse/sensinact/gateway/nthbnd/jsonpath/builder/JsonOrgNodeBuilder.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * Copyright (c) 2017 CEA.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA - initial API and implementation
- */
-package org.eclipse.sensinact.gateway.nthbnd.jsonpath.builder;
-
-import com.jayway.jsonpath.Predicate.PredicateContext;
-import com.jayway.jsonpath.internal.filter.JsonNode;
-import com.jayway.jsonpath.internal.filter.ValueListNode;
-import com.jayway.jsonpath.internal.filter.ValueNode;
-import com.jayway.jsonpath.spi.builder.AbstractNodeBuilder;
-import org.eclipse.sensinact.gateway.nthbnd.jsonpath.JsonOrgJsonTokener;
-import org.json.JSONException;
-import org.json.JSONTokener;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * @author <a href="mailto:christophe.munilla@cea.fr">Christophe Munilla</a>
- */
-public class JsonOrgNodeBuilder extends AbstractNodeBuilder {
- class JsonNodeImpl extends JsonNode {
-
- /**
- * @param charSequence
- */
- JsonNodeImpl(CharSequence charSequence) {
- super(charSequence);
- }
-
- /**
- * @param parsedJson
- */
- JsonNodeImpl(Object parsedJson) {
- super(parsedJson);
- }
-
- /**
- * @inheritDoc
- * @see com.jayway.jsonpath.internal.filter.JsonNode#parse(com.jayway.jsonpath.Predicate.PredicateContext)
- */
- @Override
- public Object parse(PredicateContext ctx) {
- if (parsed) {
- return json;
- }
- try {
- return new JsonOrgJsonTokener(json.toString().trim()).nextValue();
- } catch (JSONException e) {
- throw new IllegalArgumentException(e);
- }
- }
-
- /**
- * @inheritDoc
- * @see com.jayway.jsonpath.internal.filter.JsonNode#asValueListNode(com.jayway.jsonpath.Predicate.PredicateContext)
- */
- @Override
- @SuppressWarnings("rawtypes")
- public ValueNode asValueListNode(PredicateContext ctx) {
- if (!isArray(ctx)) {
- return ValueNode.UNDEFINED;
- } else {
- List list = (List) parse(ctx);
- Iterator iterator = list.iterator();
- List<ValueNode> valueNodes = new ArrayList<ValueNode>();
- while (iterator.hasNext()) {
- valueNodes.add(toValueNode(iterator.next()));
- }
- return new ValueListNode(Collections.unmodifiableList(valueNodes));
- }
- }
-
- }
-
- /**
- *
- */
- public JsonOrgNodeBuilder() {
- }
-
- /**
- * @inheritDoc
- * @see com.jayway.jsonpath.spi.builder.NodeBuilder#isJson(java.lang.Object)
- */
- @Override
- public boolean isJson(Object o) {
- if (o == null || !(o instanceof String)) {
- return false;
- }
- String str = o.toString().trim();
- if (str.length() <= 1) {
- return false;
- }
- char c0 = str.charAt(0);
- char c1 = str.charAt(str.length() - 1);
- if ((c0 == '[' && c1 == ']') || (c0 == '{' && c1 == '}')) {
- try {
- new JSONTokener(str).nextValue();
- return true;
- } catch (Exception e) {
- return false;
- }
- }
- return false;
- }
-
- /**
- * @inheritDoc
- * @see com.jayway.jsonpath.spi.builder.NodeBuilder#createJsonNode(java.lang.CharSequence)
- */
- @Override
- public JsonNode createJsonNode(CharSequence json) {
- JsonNodeImpl n = new JsonNodeImpl(json);
- return n;
- }
-
- /**
- * @inheritDoc
- * @see com.jayway.jsonpath.spi.builder.NodeBuilder#createJsonNode(java.lang.Object)
- */
- @Override
- public JsonNode createJsonNode(Object parsedJson) {
- JsonNodeImpl n = new JsonNodeImpl(parsedJson);
- return n;
- }
-}
\ No newline at end of file
diff --git a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/main/java/org/eclipse/sensinact/gateway/nthbnd/jsonpath/json/JsonOrgJsonProvider.java b/platform/northbound/jsonpath-filtering/json-provider-minimal/src/main/java/org/eclipse/sensinact/gateway/nthbnd/jsonpath/json/JsonOrgJsonProvider.java
deleted file mode 100644
index 2dd96b1..0000000
--- a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/main/java/org/eclipse/sensinact/gateway/nthbnd/jsonpath/json/JsonOrgJsonProvider.java
+++ /dev/null
@@ -1,256 +0,0 @@
-/*
- * Copyright (c) 2017 CEA.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA - initial API and implementation
- */
-package org.eclipse.sensinact.gateway.nthbnd.jsonpath.json;
-
-import com.jayway.jsonpath.InvalidJsonException;
-import com.jayway.jsonpath.JsonPathException;
-import com.jayway.jsonpath.spi.json.AbstractJsonProvider;
-import org.eclipse.sensinact.gateway.nthbnd.jsonpath.JsonOrgJson;
-import org.eclipse.sensinact.gateway.nthbnd.jsonpath.JsonOrgJsonArray;
-import org.eclipse.sensinact.gateway.nthbnd.jsonpath.JsonOrgJsonObject;
-import org.eclipse.sensinact.gateway.nthbnd.jsonpath.JsonOrgJsonTokener;
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.UnsupportedEncodingException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author <a href="mailto:christophe.munilla@cea.fr">Christophe Munilla</a>
- */
-public class JsonOrgJsonProvider extends AbstractJsonProvider {
-
- @Override
- public Object parse(String json, boolean strict) throws InvalidJsonException {
- try {
- Object o = new JsonOrgJsonTokener(json).nextValue();
- if (strict && !(o instanceof JsonOrgJson)) {
- throw new InvalidJsonException(json);
- }
- return o;
- } catch (JSONException e) {
- throw new InvalidJsonException(e);
- }
- }
-
- @Override
- public Object parse(InputStream jsonStream, String charset, boolean strict) throws InvalidJsonException {
- try {
- Object o = new JsonOrgJsonTokener(new InputStreamReader(jsonStream, charset)).nextValue();
- if (strict && !(o instanceof JsonOrgJson)) {
- throw new InvalidJsonException(o.toString());
- }
- return o;
- } catch (JSONException e) {
- e.printStackTrace();
- throw new InvalidJsonException(e);
- } catch (UnsupportedEncodingException e) {
- throw new JsonPathException(e);
- }
- }
-
- @Override
- public Object unwrap(Object obj) {
- if (JSONObject.NULL.equals(obj)) {
- return null;
- }
- return obj;
- }
-
- @Override
- public String toJson(Object obj) {
- Class clazz = obj.getClass();
- if (JSONObject.class.isAssignableFrom(clazz) || JSONArray.class.isAssignableFrom(clazz)) {
- return obj.toString();
- }
- if (obj instanceof Map) {
- return new JsonOrgJsonObject((Map) obj).toString();
- } else if (obj instanceof List) {
- return new JsonOrgJsonArray((List) obj).toString();
- } else {
- throw new UnsupportedOperationException(obj.getClass().getName() + " can not be converted to JSON");
- }
- }
-
- @Override
- public Object createArray() {
- return new JsonOrgJsonArray();
- }
-
- @Override
- public Object createMap() {
- return new JsonOrgJsonObject();
- }
-
- @Override
- public boolean isArray(Object obj) {
- return (obj instanceof List);
- }
-
- @Override
- public Object getArrayIndex(Object obj, int idx) {
- Class clazz = obj.getClass();
- if (JSONArray.class.isAssignableFrom(clazz)) {
- try {
- Object o = ((JSONArray) obj).get(idx);
- return unwrap(o);
-
- } catch (JSONException e) {
- return UNDEFINED;
- }
- } else if (List.class.isAssignableFrom(clazz)) {
- if (idx >= ((List) obj).size()) {
- return UNDEFINED;
- }
- Object o = ((List) obj).get(idx);
- return unwrap(o);
- }
- return UNDEFINED;
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public void setArrayIndex(Object array, int index, Object newValue) {
- if (!isArray(array)) {
- throw new UnsupportedOperationException();
- } else {
- if (index < 0) {
- throw new IllegalArgumentException("JSONArray[" + index + "] not found.");
- }
- List l = toJsonArray(array);
- if (index < l.size()) {
- l.set(index, createJsonElement(newValue));
- } else {
- while (index != l.size()) {
- l.add(JSONObject.NULL);
- index++;
- }
- l.add(createJsonElement(newValue));
- }
- }
- }
-
- @Override
- public Object getMapValue(Object obj, String key) {
- Class clazz = obj.getClass();
- if (JSONObject.class.isAssignableFrom(clazz)) {
- try {
- Object o = ((JSONObject) obj).get(key);
- return unwrap(o);
-
- } catch (JSONException e) {
- return UNDEFINED;
- }
- } else if (Map.class.isAssignableFrom(clazz)) {
- if (!((Map) obj).containsKey(key)) {
- return UNDEFINED;
- }
- Object o = ((Map) obj).get(key);
- return unwrap(o);
- }
- return UNDEFINED;
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public void setProperty(Object obj, Object key, Object value) {
- if (isMap(obj)) toJsonObject(obj).put(key.toString(), createJsonElement(value));
- else {
- List array = toJsonArray(obj);
- int index;
- if (key != null) {
- index = key instanceof Integer ? (Integer) key : Integer.parseInt(key.toString());
- } else {
- index = array.size();
- }
- if (index == array.size()) {
- array.add(createJsonElement(value));
- } else {
- array.set(index, createJsonElement(value));
- }
- }
- }
-
- public void removeProperty(Object obj, Object key) {
- if (isMap(obj)) toJsonObject(obj).remove(key.toString());
- else {
- List array = toJsonArray(obj);
- int index = key instanceof Integer ? (Integer) key : Integer.parseInt(key.toString());
- array.remove(index);
- }
- }
-
- @Override
- public boolean isMap(Object obj) {
- return (obj instanceof Map);
- }
-
- @Override
- public Collection<String> getPropertyKeys(Object obj) {
- List<String> keys = new ArrayList<String>();
- Iterator<?> arr = toJsonObject(obj).keySet().iterator();
- for (; arr.hasNext(); ) {
- keys.add((String) arr.next());
- }
- return keys;
- }
-
- @Override
- public int length(Object obj) {
- if (isArray(obj)) {
- return toJsonArray(obj).size();
- } else if (isMap(obj)) {
- return toJsonObject(obj).size();
- } else {
- if (obj instanceof String) {
- return ((String) obj).length();
- }
- }
- throw new JsonPathException("length operation can not applied to " + obj != null ? obj.getClass().getName() : "null");
- }
-
- @Override
- public Iterable<?> toIterable(Object obj) {
- List<Object> values = new ArrayList<Object>();
- if (isArray(obj)) {
- Iterator<?> arr = toJsonArray(obj).iterator();
- for (; arr.hasNext(); ) {
- values.add(unwrap(arr.next()));
- }
- return values;
- } else {
- Iterator arr = toJsonObject(obj).values().iterator();
- for (; arr.hasNext(); ) {
- values.add(unwrap(arr.next()));
- }
- return values;
- }
- }
-
- private Object createJsonElement(Object o) {
- return o;
- }
-
- private List toJsonArray(Object o) {
- return (List) o;
- }
-
- private Map toJsonObject(Object o) {
- return (Map) o;
- }
-}
diff --git a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/main/java/org/eclipse/sensinact/gateway/nthbnd/jsonpath/mapper/JsonOrgMappingProvider.java b/platform/northbound/jsonpath-filtering/json-provider-minimal/src/main/java/org/eclipse/sensinact/gateway/nthbnd/jsonpath/mapper/JsonOrgMappingProvider.java
deleted file mode 100644
index 73792cc..0000000
--- a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/main/java/org/eclipse/sensinact/gateway/nthbnd/jsonpath/mapper/JsonOrgMappingProvider.java
+++ /dev/null
@@ -1,246 +0,0 @@
-/*
- * Copyright (c) 2017 CEA.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * CEA - initial API and implementation
- */
-package org.eclipse.sensinact.gateway.nthbnd.jsonpath.mapper;
-
-import com.jayway.jsonpath.Configuration;
-import com.jayway.jsonpath.TypeRef;
-import com.jayway.jsonpath.spi.mapper.MappingException;
-import com.jayway.jsonpath.spi.mapper.MappingProvider;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.text.DateFormat;
-import java.text.ParseException;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author <a href="mailto:christophe.munilla@cea.fr">Christophe Munilla</a>
- */
-public class JsonOrgMappingProvider implements MappingProvider {
- private static Map<Class, Converter> DEFAULT = new HashMap<Class, Converter>();
-
- static {
- DEFAULT.put(Long.class, new LongConverter());
- DEFAULT.put(long.class, new LongConverter());
- DEFAULT.put(Integer.class, new IntegerConverter());
- DEFAULT.put(int.class, new IntegerConverter());
- DEFAULT.put(Double.class, new DoubleConverter());
- DEFAULT.put(double.class, new DoubleConverter());
- DEFAULT.put(Float.class, new FloatConverter());
- DEFAULT.put(float.class, new FloatConverter());
- DEFAULT.put(BigDecimal.class, new BigDecimalConverter());
- DEFAULT.put(String.class, new StringConverter());
- DEFAULT.put(Date.class, new DateConverter());
- DEFAULT.put(BigInteger.class, new BigIntegerConverter());
- DEFAULT.put(boolean.class, new BooleanConverter());
- }
-
- public interface Converter<T> {
- T convert(Object o);
- }
-
- private static class StringConverter implements Converter<String> {
- public String convert(Object src) {
- if (src == null) {
- return null;
- }
- return src.toString();
- }
- }
-
- private static class IntegerConverter implements Converter<Integer> {
- public Integer convert(Object src) {
- if (src == null) {
- return null;
- }
- if (Integer.class.isAssignableFrom(src.getClass())) {
- return (Integer) src;
- } else if (Long.class.isAssignableFrom(src.getClass())) {
- return ((Long) src).intValue();
- } else if (Double.class.isAssignableFrom(src.getClass())) {
- return ((Double) src).intValue();
- } else if (BigDecimal.class.isAssignableFrom(src.getClass())) {
- return ((BigDecimal) src).intValue();
- } else if (Float.class.isAssignableFrom(src.getClass())) {
- return ((Float) src).intValue();
- } else if (String.class.isAssignableFrom(src.getClass())) {
- return Integer.valueOf(src.toString());
- }
- throw new MappingException("can not map a " + src.getClass() + " to " + Integer.class.getName());
- }
- }
-
- private static class LongConverter implements Converter<Long> {
- public Long convert(Object src) {
- if (src == null) {
- return null;
- }
- if (Long.class.isAssignableFrom(src.getClass())) {
- return (Long) src;
- } else if (Integer.class.isAssignableFrom(src.getClass())) {
- return ((Integer) src).longValue();
- } else if (Double.class.isAssignableFrom(src.getClass())) {
- return ((Double) src).longValue();
- } else if (BigDecimal.class.isAssignableFrom(src.getClass())) {
- return ((BigDecimal) src).longValue();
- } else if (Float.class.isAssignableFrom(src.getClass())) {
- return ((Float) src).longValue();
- } else if (String.class.isAssignableFrom(src.getClass())) {
- return Long.valueOf(src.toString());
- }
- throw new MappingException("can not map a " + src.getClass() + " to " + Long.class.getName());
- }
- }
-
- private static class DoubleConverter implements Converter<Double> {
- public Double convert(Object src) {
- if (src == null) {
- return null;
- }
- if (Double.class.isAssignableFrom(src.getClass())) {
- return (Double) src;
- } else if (Integer.class.isAssignableFrom(src.getClass())) {
- return ((Integer) src).doubleValue();
- } else if (Long.class.isAssignableFrom(src.getClass())) {
- return ((Long) src).doubleValue();
- } else if (BigDecimal.class.isAssignableFrom(src.getClass())) {
- return ((BigDecimal) src).doubleValue();
- } else if (Float.class.isAssignableFrom(src.getClass())) {
- return ((Float) src).doubleValue();
- } else if (String.class.isAssignableFrom(src.getClass())) {
- return Double.valueOf(src.toString());
- }
- throw new MappingException("can not map a " + src.getClass() + " to " + Double.class.getName());
- }
- }
-
- private static class FloatConverter implements Converter<Float> {
- public Float convert(Object src) {
- if (src == null) {
- return null;
- }
- if (Float.class.isAssignableFrom(src.getClass())) {
- return (Float) src;
- } else if (Integer.class.isAssignableFrom(src.getClass())) {
- return ((Integer) src).floatValue();
- } else if (Long.class.isAssignableFrom(src.getClass())) {
- return ((Long) src).floatValue();
- } else if (BigDecimal.class.isAssignableFrom(src.getClass())) {
- return ((BigDecimal) src).floatValue();
- } else if (Double.class.isAssignableFrom(src.getClass())) {
- return ((Double) src).floatValue();
- } else if (String.class.isAssignableFrom(src.getClass())) {
- return Float.valueOf(src.toString());
- }
- throw new MappingException("can not map a " + src.getClass() + " to " + Float.class.getName());
- }
- }
-
- private static class BigDecimalConverter implements Converter<BigDecimal> {
- public BigDecimal convert(Object src) {
- if (src == null) {
- return null;
- }
- return new BigDecimal(src.toString());
- }
- }
-
- private static class BigIntegerConverter implements Converter<BigInteger> {
- public BigInteger convert(Object src) {
- if (src == null) {
- return null;
- }
- return new BigInteger(src.toString());
- }
- }
-
- private static class DateConverter implements Converter<Date> {
- public Date convert(Object src) {
- if (src == null) {
- return null;
- }
- if (Date.class.isAssignableFrom(src.getClass())) {
- return (Date) src;
- } else if (Long.class.isAssignableFrom(src.getClass())) {
- return new Date((Long) src);
- } else if (String.class.isAssignableFrom(src.getClass())) {
- try {
- return DateFormat.getInstance().parse(src.toString());
- } catch (ParseException e) {
- throw new MappingException(e);
- }
- }
- throw new MappingException("can not map a " + src.getClass() + " to " + Date.class.getName());
- }
- }
-
- private static class BooleanConverter implements Converter<Boolean> {
- public Boolean convert(Object src) {
- if (src == null) {
- return null;
- }
- if (Boolean.class.isAssignableFrom(src.getClass())) {
- return (Boolean) src;
- }
- throw new MappingException("can not map a " + src.getClass() + " to " + Boolean.class.getName());
- }
- }
-
- @Override
- public <T> T map(Object source, TypeRef<T> targetType, Configuration configuration) {
- throw new UnsupportedOperationException("JsonOrg provider does not support TypeRef! Use a Jackson or Gson based provider");
- }
-
- private Object mapToObject(Object source) {
- if (source instanceof List) {
- List<Object> mapped = new ArrayList<Object>();
- List array = (List) source;
- for (int i = 0; i < array.size(); i++) {
- mapped.add(mapToObject(array.get(i)));
- }
- return mapped;
- } else if (source instanceof Map) {
- Map<String, Object> mapped = new HashMap<String, Object>();
- Map obj = (Map) source;
- Iterator<?> iterator = obj.keySet().iterator();
- while (iterator.hasNext()) {
- String key = iterator.next().toString();
- mapped.put(key, mapToObject(obj.get(key)));
- }
- return mapped;
- } else {
- return source;
- }
- }
-
- @Override
- public <T> T map(Object source, Class<T> targetType, Configuration configuration) {
-
- if (source == null) {
- return null;
- }
- if (targetType.isAssignableFrom(source.getClass())) {
- return (T) source;
- }
- if (targetType.equals(Object.class) || targetType.equals(List.class) || targetType.equals(Map.class)) {
- return (T) mapToObject(source);
- }
- if (!configuration.jsonProvider().isMap(source) && !configuration.jsonProvider().isArray(source)) {
- return (T) DEFAULT.get(targetType).convert(source);
- }
- return (T) source;
- }
-}
diff --git a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/main/resources/META-INF/services/com.jayway.jsonpath.Defaults b/platform/northbound/jsonpath-filtering/json-provider-minimal/src/main/resources/META-INF/services/com.jayway.jsonpath.Defaults
deleted file mode 100644
index ff0e485..0000000
--- a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/main/resources/META-INF/services/com.jayway.jsonpath.Defaults
+++ /dev/null
@@ -1 +0,0 @@
-org.eclipse.sensinact.gateway.nthbnd.jsonpath.JsonOrgDefaults
\ No newline at end of file
diff --git a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/BaseTestConfiguration.java b/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/BaseTestConfiguration.java
deleted file mode 100644
index f2be34d..0000000
--- a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/BaseTestConfiguration.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package org.eclipse.sensinact.gateway.nthbnd.test.jsonpath;
-
-import com.jayway.jsonpath.Configuration;
-import com.jayway.jsonpath.Predicate;
-import com.jayway.jsonpath.internal.Path;
-import com.jayway.jsonpath.internal.path.PredicateContextImpl;
-import org.eclipse.sensinact.gateway.nthbnd.jsonpath.builder.JsonOrgNodeBuilder;
-import org.eclipse.sensinact.gateway.nthbnd.jsonpath.json.JsonOrgJsonProvider;
-import org.eclipse.sensinact.gateway.nthbnd.jsonpath.mapper.JsonOrgMappingProvider;
-
-import java.util.Arrays;
-import java.util.HashMap;
-
-public class BaseTestConfiguration {
- public static final Configuration JSON_ORG_CONFIGURATION = Configuration.builder().mappingProvider(new JsonOrgMappingProvider()).jsonProvider(new JsonOrgJsonProvider()).nodeBuilder(new JsonOrgNodeBuilder()).build();
-
- public static Iterable<Configuration> configurations() {
- return Arrays.asList(JSON_ORG_CONFIGURATION);
- }
-
- public static Iterable<Configuration> objectMappingConfigurations() {
- return Arrays.asList(JSON_ORG_CONFIGURATION);
- }
-
- public static Predicate.PredicateContext createPredicateContext(final Object check) {
- return new PredicateContextImpl(check, check, Configuration.defaultConfiguration(), new HashMap<Path, Object>());
- }
-}
diff --git a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/BaseTestJson.java b/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/BaseTestJson.java
deleted file mode 100644
index bdb1e11..0000000
--- a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/BaseTestJson.java
+++ /dev/null
@@ -1,6 +0,0 @@
-package org.eclipse.sensinact.gateway.nthbnd.test.jsonpath;
-
-public abstract class BaseTestJson {
- public static final String JSON_BOOK_DOCUMENT = "{ " + " \"category\" : \"reference\",\n" + " \"author\" : \"Nigel Rees\",\n" + " \"title\" : \"Sayings of the Century\",\n" + " \"display-price\" : 8.95\n" + "}";
- public static final String JSON_DOCUMENT = "{\n" + " \"string-property\" : \"string-value\", \n" + " \"int-max-property\" : " + Integer.MAX_VALUE + ", \n" + " \"long-max-property\" : " + Long.MAX_VALUE + ", \n" + " \"boolean-property\" : true, \n" + " \"null-property\" : null, \n" + " \"int-small-property\" : 1, \n" + " \"max-price\" : 10, \n" + " \"store\" : {\n" + " \"book\" : [\n" + " {\n" + " \"category\" : \"reference\",\n" + " \"author\" : \"Nigel Rees\",\n" + " \"title\" : \"Sayings of the Century\",\n" + " \"display-price\" : 8.95\n" + " },\n" + " {\n" + " \"category\" : \"fiction\",\n" + " \"author\" : \"Evelyn Waugh\",\n" + " \"title\" : \"Sword of Honour\",\n" + " \"display-price\" : 12.99\n" + " },\n" + " {\n" + " \"category\" : \"fiction\",\n" + " \"author\" : \"Herman Melville\",\n" + " \"title\" : \"Moby Dick\",\n" + " \"isbn\" : \"0-553-21311-3\",\n" + " \"display-price\" : 8.99\n" + " },\n" + " {\n" + " \"category\" : \"fiction\",\n" + " \"author\" : \"J. R. R. Tolkien\",\n" + " \"title\" : \"The Lord of the Rings\",\n" + " \"isbn\" : \"0-395-19395-8\",\n" + " \"display-price\" : 22.99\n" + " }\n" + " ],\n" + " \"bicycle\" : {\n" + " \"foo\" : \"baz\",\n" + " \"escape\" : \"Esc\\b\\f\\n\\r\\t\\n\\t\\u002A\",\n" + " \"color\" : \"red\",\n" + " \"display-price\" : 19.95,\n" + " \"foo:bar\" : \"fooBar\",\n" + " \"dot.notation\" : \"new\",\n" + " \"dash-notation\" : \"dashes\"\n" + " }\n" + " },\n" + " \"foo\" : \"bar\",\n" + " \"@id\" : \"ID\"\n" + "}";
-}
diff --git a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/DeepScanTest.java b/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/DeepScanTest.java
deleted file mode 100644
index 03e4aaf..0000000
--- a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/DeepScanTest.java
+++ /dev/null
@@ -1,302 +0,0 @@
-package org.eclipse.sensinact.gateway.nthbnd.test.jsonpath;
-
-import com.jayway.jsonpath.Configuration;
-import com.jayway.jsonpath.JsonPath;
-import com.jayway.jsonpath.Option;
-import com.jayway.jsonpath.PathNotFoundException;
-import org.junit.Test;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import static com.jayway.jsonpath.JsonPath.parse;
-import static com.jayway.jsonpath.JsonPath.using;
-import static java.util.Collections.singletonMap;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.eclipse.sensinact.gateway.nthbnd.test.jsonpath.TestUtils.assertEvaluationThrows;
-
-/**
- * Deep scan is indefinite, so certain "illegal" actions become a no-op instead of a path evaluation exception.
- */
-public class DeepScanTest {
- @Test
- public void when_deep_scanning_non_array_subscription_is_ignored() {
- Object result = JsonPath.parse("{\"x\": [0,1,[0,1,2,3,null],null]}").read("$..[2][3]");
- assertThat(result).asList().containsOnly(3);
- result = JsonPath.parse("{\"x\": [0,1,[0,1,2,3,null],null], \"y\": [0,1,2]}").read("$..[2][3]");
- assertThat(result).asList().containsOnly(3);
- result = JsonPath.parse("{\"x\": [0,1,[0,1,2],null], \"y\": [0,1,2]}").read("$..[2][3]");
- assertThat(result).asList().isEmpty();
- }
-
- @Test
- public void when_deep_scanning_null_subscription_is_ignored() {
- Object result = JsonPath.parse("{\"x\": [null,null,[0,1,2,3,null],null]}").read("$..[2][3]");
- assertThat(result).asList().containsOnly(3);
- result = JsonPath.parse("{\"x\": [null,null,[0,1,2,3,null],null], \"y\": [0,1,null]}").read("$..[2][3]");
- assertThat(result).asList().containsOnly(3);
- }
-
- @Test
- public void when_deep_scanning_array_index_oob_is_ignored() {
- Object result = JsonPath.parse("{\"x\": [0,1,[0,1,2,3,10],null]}").read("$..[4]");
- assertThat(result).asList().containsOnly(10);
- result = JsonPath.parse("{\"x\": [null,null,[0,1,2,3]], \"y\": [null,null,[0,1]]}").read("$..[2][3]");
- assertThat(result).asList().containsOnly(3);
- }
-
- @Test
- public void definite_upstream_illegal_array_access_throws() {
- assertEvaluationThrows("{\"foo\": {\"bar\": null}}", "$.foo.bar.[5]", PathNotFoundException.class);
- assertEvaluationThrows("{\"foo\": {\"bar\": null}}", "$.foo.bar.[5, 10]", PathNotFoundException.class);
- assertEvaluationThrows("{\"foo\": {\"bar\": 4}}", "$.foo.bar.[5]", PathNotFoundException.class);
- assertEvaluationThrows("{\"foo\": {\"bar\": 4}}", "$.foo.bar.[5, 10]", PathNotFoundException.class);
- assertEvaluationThrows("{\"foo\": {\"bar\": []}}", "$.foo.bar.[5]", PathNotFoundException.class);
- }
-
- @Test
- public void when_deep_scanning_illegal_property_access_is_ignored() {
- Object result = JsonPath.parse("{\"x\": {\"foo\": {\"bar\": 4}}, \"y\": {\"foo\": 1}}").read("$..foo");
- assertThat(result).asList().hasSize(2);
- result = JsonPath.parse("{\"x\": {\"foo\": {\"bar\": 4}}, \"y\": {\"foo\": 1}}").read("$..foo.bar");
- assertThat(result).asList().containsOnly(4);
- result = JsonPath.parse("{\"x\": {\"foo\": {\"bar\": 4}}, \"y\": {\"foo\": 1}}").read("$..[*].foo.bar");
- assertThat(result).asList().containsOnly(4);
- result = JsonPath.parse("{\"x\": {\"foo\": {\"baz\": 4}}, \"y\": {\"foo\": 1}}").read("$..[*].foo.bar");
- assertThat(result).asList().isEmpty();
- }
-
- @Test
- public void when_deep_scanning_illegal_predicate_is_ignored() {
- Object result = JsonPath.parse("{\"x\": {\"foo\": {\"bar\": 4}}, \"y\": {\"foo\": 1}}").read("$..foo[?(@.bar)].bar");
- assertThat(result).asList().containsOnly(4);
- result = JsonPath.parse("{\"x\": {\"foo\": {\"bar\": 4}}, \"y\": {\"foo\": 1}}").read("$..[*]foo[?(@.bar)].bar");
- assertThat(result).asList().containsOnly(4);
- }
-
- @Test
- public void when_deep_scanning_require_properties_is_ignored_on_scan_target() {
- final Configuration conf = Configuration.defaultConfiguration().addOptions(Option.REQUIRE_PROPERTIES);
- Object result = JsonPath.parse("[{\"x\": {\"foo\": {\"x\": 4}, \"x\": null}, \"y\": {\"x\": 1}}, {\"x\": []}]").read("$..x");
- assertThat(result).asList().hasSize(5);
- List<Integer> result1 = JsonPath.using(conf).parse("{\"foo\": {\"bar\": 4}}", false).read("$..foo.bar");
- assertThat(result1).containsExactly(4);
- assertEvaluationThrows("{\"foo\": {\"baz\": 4}}", "$..foo.bar", PathNotFoundException.class, conf);
- }
-
- @Test
- public void when_deep_scanning_require_properties_is_ignored_on_scan_target_but_not_on_children() {
- final Configuration conf = Configuration.defaultConfiguration().addOptions(Option.REQUIRE_PROPERTIES);
- assertEvaluationThrows("{\"foo\": {\"baz\": 4}}", "$..foo.bar", PathNotFoundException.class, conf);
- }
-
- @Test
- @SuppressWarnings("unchecked")
- public void when_deep_scanning_leaf_multi_props_work() {
- Object result = JsonPath.parse("[{\"a\": \"a-val\", \"b\": \"b-val\", \"c\": \"c-val\"}, [1, 5], {\"a\": \"a-val\"}]").read("$..['a', 'c']");
- // This is current deep scan semantics: only objects containing all properties specified in multiprops token are
- // considered.
- assertThat(result).asList().hasSize(1);
- result = ((List) result).get(0);
- assertThat(result).isInstanceOf(Map.class);
- assertThat((Map) result).hasSize(2).containsEntry("a", "a-val").containsEntry("c", "c-val");
- // But this semantics changes when DEFAULT_PATH_LEAF_TO_NULL comes into play.
- Configuration conf = Configuration.defaultConfiguration().addOptions(Option.DEFAULT_PATH_LEAF_TO_NULL);
- result = using(conf).parse("[{\"a\": \"a-val\", \"b\": \"b-val\", \"c\": \"c-val\"}, [1, 5], {\"a\": \"a-val\"}]", false).read("$..['a', 'c']");
- // todo: deep equality test, but not tied to any json provider
- assertThat(result).asList().hasSize(2);
- for (final Object node : (List) result) {
- assertThat(node).isInstanceOf(Map.class);
- assertThat((Map) node).hasSize(2).containsEntry("a", "a-val");
- }
- }
-
- @Test
- @SuppressWarnings({"unchecked", "rawtypes", "serial"})
- public void require_single_property_ok() {
- List json = new ArrayList() {{
- add(singletonMap("a", "a0"));
- add(singletonMap("a", "a1"));
- }};
- Configuration configuration = BaseTestConfiguration.JSON_ORG_CONFIGURATION.addOptions(Option.REQUIRE_PROPERTIES);
- Object result = JsonPath.using(configuration).parse(json, false).read("$..a");
- assertThat(result).asList().containsExactly("a0", "a1");
- }
-
- @Test
- @SuppressWarnings({"unchecked", "rawtypes", "serial"})
- public void require_single_property() {
- List json = new ArrayList() {{
- add(singletonMap("a", "a0"));
- add(singletonMap("b", "b2"));
- }};
- Configuration configuration = BaseTestConfiguration.JSON_ORG_CONFIGURATION.addOptions(Option.REQUIRE_PROPERTIES);
- Object result = JsonPath.using(configuration).parse(json, false).read("$..a");
- assertThat(result).asList().containsExactly("a0");
- }
-
- @Test
- @SuppressWarnings({"unchecked", "rawtypes", "serial"})
- public void require_multi_property_all_match() {
- final Map ab = new HashMap() {{
- put("a", "aa");
- put("b", "bb");
- }};
- List json = new ArrayList() {{
- add(ab);
- add(ab);
- }};
- Configuration configuration = BaseTestConfiguration.JSON_ORG_CONFIGURATION.addOptions(Option.REQUIRE_PROPERTIES);
- List<Map<String, String>> result = JsonPath.using(configuration).parse(json, false).read("$..['a', 'b']");
- assertThat(result).containsExactly(ab, ab);
- }
-
- @Test
- @SuppressWarnings({"rawtypes", "serial", "unchecked"})
- public void require_multi_property_some_match() {
- final Map ab = new HashMap() {{
- put("a", "aa");
- put("b", "bb");
- }};
- final Map ad = new HashMap() {{
- put("a", "aa");
- put("d", "dd");
- }};
- List json = new ArrayList() {{
- add(ab);
- add(ad);
- }};
- Configuration configuration = BaseTestConfiguration.JSON_ORG_CONFIGURATION.addOptions(Option.REQUIRE_PROPERTIES);
- List<Map<String, String>> result = JsonPath.using(configuration).parse(json, false).read("$..['a', 'b']");
- assertThat(result).containsExactly(ab);
- }
-
- @Test
- @SuppressWarnings({"rawtypes", "serial", "unchecked"})
- public void scan_for_single_property() {
- final Map a = new HashMap() {{
- put("a", "aa");
- }};
- final Map b = new HashMap() {{
- put("b", "bb");
- }};
- final Map ab = new HashMap() {{
- put("a", a);
- put("b", b);
- }};
- final Map b_ab = new HashMap() {{
- put("b", b);
- put("ab", ab);
- }};
- List json = new ArrayList() {{
- add(a);
- add(b);
- add(b_ab);
- }};
- assertThat(parse(json).read("$..['a']", List.class)).containsExactly("aa", a, "aa");
- }
-
- @Test
- @SuppressWarnings({"rawtypes", "serial", "unchecked"})
- public void scan_for_property_path() {
- final Map a = new HashMap() {{
- put("a", "aa");
- }};
- final Map x = new HashMap() {{
- put("x", "xx");
- }};
- final Map y = new HashMap() {{
- put("a", x);
- }};
- final Map z = new HashMap() {{
- put("z", y);
- }};
- List json = new ArrayList() {{
- add(a);
- add(x);
- add(y);
- add(z);
- }};
- assertThat(parse(json).read("$..['a'].x", List.class)).containsExactly("xx", "xx");
- }
-
- @Test
- @SuppressWarnings({"rawtypes", "serial", "unchecked"})
- public void scan_for_property_path_missing_required_property() {
- final Map a = new HashMap() {{
- put("a", "aa");
- }};
- final Map x = new HashMap() {{
- put("x", "xx");
- }};
- final Map y = new HashMap() {{
- put("a", x);
- }};
- final Map z = new HashMap() {{
- put("z", y);
- }};
- List json = new ArrayList() {{
- add(a);
- add(x);
- add(y);
- add(z);
- }};
- assertThat(using(BaseTestConfiguration.JSON_ORG_CONFIGURATION.addOptions(Option.REQUIRE_PROPERTIES)).parse(json, false).read("$..['a'].x", List.class)).containsExactly("xx", "xx");
- }
-
- @Test
- @SuppressWarnings({"rawtypes", "serial", "unchecked"})
- public void scans_can_be_filtered() {
- final Map brown = singletonMap("val", "brown");
- final Map white = singletonMap("val", "white");
- final Map cow = new HashMap() {{
- put("mammal", true);
- put("color", brown);
- }};
- final Map dog = new HashMap() {{
- put("mammal", true);
- put("color", white);
- }};
- final Map frog = new HashMap() {{
- put("mammal", false);
- }};
- List animals = new ArrayList() {{
- add(cow);
- add(dog);
- add(frog);
- }};
- assertThat(using(BaseTestConfiguration.JSON_ORG_CONFIGURATION.addOptions(Option.REQUIRE_PROPERTIES)).parse(animals, false).read("$..[?(@.mammal == true)].color", List.class)).containsExactly(brown, white);
- }
-
- @Test
- @SuppressWarnings({"rawtypes", "unchecked"})
- public void scan_with_a_function_filter() {
- List result = JsonPath.parse(BaseTestJson.JSON_DOCUMENT).read("$..*[?(@.length() > 5)]");
- assertThat(result).hasSize(1);
- }
-
- @Test
- public void deepScanPathDefault() {
- executeScanPath();
- }
-
- @Test
- public void deepScanPathRequireProperties() {
- executeScanPath(Option.REQUIRE_PROPERTIES);
- }
-
- @SuppressWarnings({"serial"})
- private void executeScanPath(Option... options) {
- String json = "{'index': 'index', 'data': {'array': [{ 'object1': { 'name': 'robert'} }]}}";
- Map<String, Object> expected = new HashMap<String, Object>() {{
- put("object1", new HashMap<String, String>() {{
- put("name", "robert");
- }});
- }};
- Configuration configuration = Configuration.builder().options(options).build();
- List<Map<String, Object>> result = JsonPath.using(configuration).parse(json, false).read("$..array[0]");
- assertThat(result.get(0)).isEqualTo(expected);
- }
-}
diff --git a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/EvaluationListenerTest.java b/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/EvaluationListenerTest.java
deleted file mode 100644
index ecb9a49..0000000
--- a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/EvaluationListenerTest.java
+++ /dev/null
@@ -1,101 +0,0 @@
-package org.eclipse.sensinact.gateway.nthbnd.test.jsonpath;
-
-import com.jayway.jsonpath.Configuration;
-import com.jayway.jsonpath.EvaluationListener;
-import com.jayway.jsonpath.EvaluationListener.EvaluationContinuation;
-import com.jayway.jsonpath.EvaluationListener.FoundResult;
-import com.jayway.jsonpath.JsonPath;
-import org.junit.Test;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class EvaluationListenerTest extends BaseTestConfiguration {
- @Test
- public void an_evaluation_listener_can_abort_after_one_result_using_fluent_api() {
- EvaluationListener firstResultListener = new EvaluationListener() {
- @Override
- public EvaluationContinuation resultFound(FoundResult found) {
- return EvaluationContinuation.ABORT;
- }
- };
- List<String> title = JsonPath.parse(BaseTestJson.JSON_DOCUMENT).withListeners(firstResultListener).read("$..title", List.class);
- assertThat(title).containsExactly("Sayings of the Century");
- }
-
- @Test
- public void an_evaluation_listener_can_abort_after_one_result_using_configuration() {
- EvaluationListener firstResultListener = new EvaluationListener() {
- @Override
- public EvaluationContinuation resultFound(FoundResult found) {
- return EvaluationContinuation.ABORT;
- }
- };
- Configuration configuration = Configuration.builder().evaluationListener(firstResultListener).build();
- List<String> title = JsonPath.using(configuration).parse(BaseTestJson.JSON_DOCUMENT, false).read("$..title", List.class);
- assertThat(title).containsExactly("Sayings of the Century");
- }
-
- @Test
- public void an_evaluation_lister_can_continue() {
- final List<Integer> idxs = new ArrayList<Integer>();
- EvaluationListener firstResultListener = new EvaluationListener() {
- @Override
- public EvaluationContinuation resultFound(FoundResult found) {
- idxs.add(found.index());
- return EvaluationContinuation.CONTINUE;
- }
- };
- List<String> title = JsonPath.parse(BaseTestJson.JSON_DOCUMENT).withListeners(firstResultListener).read("$..title", List.class);
- assertThat(title).containsExactly("Sayings of the Century", "Sword of Honour", "Moby Dick", "The Lord of the Rings");
- assertThat(idxs).containsExactly(0, 1, 2, 3);
- }
-
- @Test
- public void evaluation_results_can_be_limited() {
- List<String> res = JsonPath.parse(BaseTestJson.JSON_DOCUMENT).limit(1).read("$..title", List.class);
- assertThat(res).containsExactly("Sayings of the Century");
- res = JsonPath.parse(BaseTestJson.JSON_DOCUMENT).limit(2).read("$..title", List.class);
- assertThat(res).containsExactly("Sayings of the Century", "Sword of Honour");
- }
-
- @Test
- public void multiple_evaluation_listeners_can_be_added() {
- final List<Integer> idxs1 = new ArrayList<Integer>();
- final List<Integer> idxs2 = new ArrayList<Integer>();
- EvaluationListener listener1 = new EvaluationListener() {
- @Override
- public EvaluationContinuation resultFound(FoundResult found) {
- idxs1.add(found.index());
- return EvaluationContinuation.CONTINUE;
- }
- };
- EvaluationListener listener2 = new EvaluationListener() {
- @Override
- public EvaluationContinuation resultFound(FoundResult found) {
- idxs2.add(found.index());
- return EvaluationContinuation.CONTINUE;
- }
- };
- List<String> title = JsonPath.parse(BaseTestJson.JSON_DOCUMENT).withListeners(listener1, listener2).read("$..title", List.class);
- assertThat(title).containsExactly("Sayings of the Century", "Sword of Honour", "Moby Dick", "The Lord of the Rings");
- assertThat(idxs1).containsExactly(0, 1, 2, 3);
- assertThat(idxs2).containsExactly(0, 1, 2, 3);
- }
-
- @Test
- public void evaluation_listeners_can_be_cleared() {
- EvaluationListener listener = new EvaluationListener() {
- @Override
- public EvaluationContinuation resultFound(FoundResult found) {
- return EvaluationContinuation.CONTINUE;
- }
- };
- Configuration configuration1 = Configuration.builder().evaluationListener(listener).build();
- Configuration configuration2 = configuration1.setEvaluationListeners();
- assertThat(configuration1.getEvaluationListeners()).hasSize(1);
- assertThat(configuration2.getEvaluationListeners()).hasSize(0);
- }
-}
diff --git a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/FilterTest.java b/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/FilterTest.java
deleted file mode 100644
index 2264fdb..0000000
--- a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/FilterTest.java
+++ /dev/null
@@ -1,495 +0,0 @@
-package org.eclipse.sensinact.gateway.nthbnd.test.jsonpath;
-
-import com.jayway.jsonpath.Configuration;
-import com.jayway.jsonpath.Criteria;
-import com.jayway.jsonpath.Filter;
-import com.jayway.jsonpath.JsonPath;
-import com.jayway.jsonpath.Predicate;
-import com.jayway.jsonpath.Predicate.PredicateContext;
-import com.jayway.jsonpath.spi.builder.NodeBuilder;
-import org.assertj.core.util.Lists;
-import org.junit.Test;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.regex.Pattern;
-
-import static com.jayway.jsonpath.Filter.filter;
-import static com.jayway.jsonpath.Filter.parse;
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class FilterTest extends BaseTestConfiguration {
- Configuration configuration = Configuration.defaultConfiguration();
- NodeBuilder builder = configuration.nodeBuilder();
- Object json = configuration.jsonProvider().parse("{" + " \"int-key\" : 1, " + " \"long-key\" : 3000000000, " + " \"double-key\" : 10.1, " + " \"boolean-key\" : true, " + " \"null-key\" : null, " + " \"string-key\" : \"string\", " + " \"string-key-empty\" : \"\", " + " \"char-key\" : \"c\", " + " \"arr-empty\" : [], " + " \"int-arr\" : [0,1,2,3,4], " + " \"string-arr\" : [\"a\",\"b\",\"c\",\"d\",\"e\"] " + "}");
-
- //----------------------------------------------------------------------------
- //
- // EQ
- //
- //----------------------------------------------------------------------------
- @Test
- public void int_eq_evals() {
- assertThat(filter(builder.where("int-key").eq(1)).apply(createPredicateContext(json))).isEqualTo(true);
- assertThat(filter(builder.where("int-key").eq(666)).apply(createPredicateContext(json))).isEqualTo(false);
- }
-
- @Test
- public void int_eq_string_evals() {
- assertThat(filter(builder.where("int-key").eq("1")).apply(createPredicateContext(json))).isEqualTo(true);
- assertThat(filter(builder.where("int-key").eq("666")).apply(createPredicateContext(json))).isEqualTo(false);
- assertThat(Filter.parse("[?(1 == '1')]").apply(createPredicateContext(json))).isEqualTo(true);
- assertThat(Filter.parse("[?('1' == 1)]").apply(createPredicateContext(json))).isEqualTo(true);
- assertThat(Filter.parse("[?(1 === '1')]").apply(createPredicateContext(json))).isEqualTo(false);
- assertThat(Filter.parse("[?('1' === 1)]").apply(createPredicateContext(json))).isEqualTo(false);
- assertThat(Filter.parse("[?(1 === 1)]").apply(createPredicateContext(json))).isEqualTo(true);
- }
-
- @Test
- public void long_eq_evals() {
- assertThat(filter(builder.where("long-key").eq(3000000000L)).apply(createPredicateContext(json))).isEqualTo(true);
- assertThat(filter(builder.where("long-key").eq(666L)).apply(createPredicateContext(json))).isEqualTo(false);
- }
-
- @Test
- public void double_eq_evals() {
- assertThat(filter(builder.where("double-key").eq(10.1D)).apply(createPredicateContext(json))).isEqualTo(true);
- assertThat(filter(builder.where("double-key").eq(10.10D)).apply(createPredicateContext(json))).isEqualTo(true);
- assertThat(filter(builder.where("double-key").eq(10.11D)).apply(createPredicateContext(json))).isEqualTo(false);
- }
-
- @Test
- public void string_eq_evals() {
- assertThat(filter(builder.where("string-key").eq("string")).apply(createPredicateContext(json))).isEqualTo(true);
- assertThat(filter(builder.where("string-key").eq("666")).apply(createPredicateContext(json))).isEqualTo(false);
- }
-
- @Test
- public void boolean_eq_evals() {
- assertThat(filter(builder.where("boolean-key").eq(true)).apply(createPredicateContext(json))).isEqualTo(true);
- assertThat(filter(builder.where("boolean-key").eq(false)).apply(createPredicateContext(json))).isEqualTo(false);
- }
-
- @Test
- public void null_eq_evals() {
- assertThat(filter(builder.where("null-key").eq(null)).apply(createPredicateContext(json))).isEqualTo(true);
- assertThat(filter(builder.where("null-key").eq("666")).apply(createPredicateContext(json))).isEqualTo(false);
- assertThat(filter(builder.where("string-key").eq(null)).apply(createPredicateContext(json))).isEqualTo(false);
- }
-
- @Test
- public void arr_eq_evals() {
- assertThat(filter(builder.where("arr-empty").eq("[]")).apply(createPredicateContext(json))).isEqualTo(true);
- assertThat(filter(builder.where("int-arr").eq("[0,1,2,3,4]")).apply(createPredicateContext(json))).isEqualTo(true);
- assertThat(filter(builder.where("int-arr").eq("[0,1,2,3]")).apply(createPredicateContext(json))).isEqualTo(false);
- assertThat(filter(builder.where("int-arr").eq("[0,1,2,3,4,5]")).apply(createPredicateContext(json))).isEqualTo(false);
- }
-
- //----------------------------------------------------------------------------
- //
- // NE
- //
- //----------------------------------------------------------------------------
- @Test
- public void int_ne_evals() {
- assertThat(filter(builder.where("int-key").ne(1)).apply(createPredicateContext(json))).isEqualTo(false);
- assertThat(filter(builder.where("int-key").ne(666)).apply(createPredicateContext(json))).isEqualTo(true);
- }
-
- @Test
- public void long_ne_evals() {
- assertThat(filter(builder.where("long-key").ne(3000000000L)).apply(createPredicateContext(json))).isEqualTo(false);
- assertThat(filter(builder.where("long-key").ne(666L)).apply(createPredicateContext(json))).isEqualTo(true);
- }
-
- @Test
- public void double_ne_evals() {
- assertThat(filter(builder.where("double-key").ne(10.1D)).apply(createPredicateContext(json))).isEqualTo(false);
- assertThat(filter(builder.where("double-key").ne(10.10D)).apply(createPredicateContext(json))).isEqualTo(false);
- assertThat(filter(builder.where("double-key").ne(10.11D)).apply(createPredicateContext(json))).isEqualTo(true);
- }
-
- @Test
- public void string_ne_evals() {
- assertThat(filter(builder.where("string-key").ne("string")).apply(createPredicateContext(json))).isEqualTo(false);
- assertThat(filter(builder.where("string-key").ne("666")).apply(createPredicateContext(json))).isEqualTo(true);
- }
-
- @Test
- public void boolean_ne_evals() {
- assertThat(filter(builder.where("boolean-key").ne(true)).apply(createPredicateContext(json))).isEqualTo(false);
- assertThat(filter(builder.where("boolean-key").ne(false)).apply(createPredicateContext(json))).isEqualTo(true);
- }
-
- @Test
- public void null_ne_evals() {
- assertThat(filter(builder.where("null-key").ne(null)).apply(createPredicateContext(json))).isEqualTo(false);
- assertThat(filter(builder.where("null-key").ne("666")).apply(createPredicateContext(json))).isEqualTo(true);
- assertThat(filter(builder.where("string-key").ne(null)).apply(createPredicateContext(json))).isEqualTo(true);
- }
-
- //----------------------------------------------------------------------------
- //
- // LT
- //
- //----------------------------------------------------------------------------
- @Test
- public void int_lt_evals() {
- assertThat(filter(builder.where("int-key").lt(10)).apply(createPredicateContext(json))).isEqualTo(true);
- assertThat(filter(builder.where("int-key").lt(0)).apply(createPredicateContext(json))).isEqualTo(false);
- }
-
- @Test
- public void long_lt_evals() {
- assertThat(filter(builder.where("long-key").lt(4000000000L)).apply(createPredicateContext(json))).isEqualTo(true);
- assertThat(filter(builder.where("long-key").lt(666L)).apply(createPredicateContext(json))).isEqualTo(false);
- }
-
- @Test
- public void double_lt_evals() {
- assertThat(filter(builder.where("double-key").lt(100.1D)).apply(createPredicateContext(json))).isEqualTo(true);
- assertThat(filter(builder.where("double-key").lt(1.1D)).apply(createPredicateContext(json))).isEqualTo(false);
- }
-
- @Test
- public void string_lt_evals() {
- assertThat(filter(builder.where("char-key").lt("x")).apply(createPredicateContext(json))).isEqualTo(true);
- assertThat(filter(builder.where("char-key").lt("a")).apply(createPredicateContext(json))).isEqualTo(false);
- }
-
- //----------------------------------------------------------------------------
- //
- // LTE
- //
- //----------------------------------------------------------------------------
- @Test
- public void int_lte_evals() {
- assertThat(filter(builder.where("int-key").lte(10)).apply(createPredicateContext(json))).isEqualTo(true);
- assertThat(filter(builder.where("int-key").lte(1)).apply(createPredicateContext(json))).isEqualTo(true);
- assertThat(filter(builder.where("int-key").lte(0)).apply(createPredicateContext(json))).isEqualTo(false);
- }
-
- @Test
- public void long_lte_evals() {
- assertThat(filter(builder.where("long-key").lte(4000000000L)).apply(createPredicateContext(json))).isEqualTo(true);
- assertThat(filter(builder.where("long-key").lte(3000000000L)).apply(createPredicateContext(json))).isEqualTo(true);
- assertThat(filter(builder.where("long-key").lte(666L)).apply(createPredicateContext(json))).isEqualTo(false);
- }
-
- @Test
- public void double_lte_evals() {
- assertThat(filter(builder.where("double-key").lte(100.1D)).apply(createPredicateContext(json))).isEqualTo(true);
- assertThat(filter(builder.where("double-key").lte(10.1D)).apply(createPredicateContext(json))).isEqualTo(true);
- assertThat(filter(builder.where("double-key").lte(1.1D)).apply(createPredicateContext(json))).isEqualTo(false);
- }
-
- //----------------------------------------------------------------------------
- //
- // GT
- //
- //----------------------------------------------------------------------------
- @Test
- public void int_gt_evals() {
- assertThat(filter(builder.where("int-key").gt(10)).apply(createPredicateContext(json))).isEqualTo(false);
- assertThat(filter(builder.where("int-key").gt(0)).apply(createPredicateContext(json))).isEqualTo(true);
- }
-
- @Test
- public void long_gt_evals() {
- assertThat(filter(builder.where("long-key").gt(4000000000L)).apply(createPredicateContext(json))).isEqualTo(false);
- assertThat(filter(builder.where("long-key").gt(666L)).apply(createPredicateContext(json))).isEqualTo(true);
- }
-
- @Test
- public void double_gt_evals() {
- assertThat(filter(builder.where("double-key").gt(100.1D)).apply(createPredicateContext(json))).isEqualTo(false);
- assertThat(filter(builder.where("double-key").gt(1.1D)).apply(createPredicateContext(json))).isEqualTo(true);
- }
-
- @Test
- public void string_gt_evals() {
- assertThat(filter(builder.where("char-key").gt("x")).apply(createPredicateContext(json))).isEqualTo(false);
- assertThat(filter(builder.where("char-key").gt("a")).apply(createPredicateContext(json))).isEqualTo(true);
- }
-
- //----------------------------------------------------------------------------
- //
- // GTE
- //
- //----------------------------------------------------------------------------
- @Test
- public void int_gte_evals() {
- assertThat(filter(builder.where("int-key").gte(10)).apply(createPredicateContext(json))).isEqualTo(false);
- assertThat(filter(builder.where("int-key").gte(1)).apply(createPredicateContext(json))).isEqualTo(true);
- assertThat(filter(builder.where("int-key").gte(0)).apply(createPredicateContext(json))).isEqualTo(true);
- }
-
- @Test
- public void long_gte_evals() {
- assertThat(filter(builder.where("long-key").gte(4000000000L)).apply(createPredicateContext(json))).isEqualTo(false);
- assertThat(filter(builder.where("long-key").gte(3000000000L)).apply(createPredicateContext(json))).isEqualTo(true);
- assertThat(filter(builder.where("long-key").gte(666L)).apply(createPredicateContext(json))).isEqualTo(true);
- }
-
- @Test
- public void double_gte_evals() {
- assertThat(filter(builder.where("double-key").gte(100.1D)).apply(createPredicateContext(json))).isEqualTo(false);
- assertThat(filter(builder.where("double-key").gte(10.1D)).apply(createPredicateContext(json))).isEqualTo(true);
- assertThat(filter(builder.where("double-key").gte(1.1D)).apply(createPredicateContext(json))).isEqualTo(true);
- }
-
- //----------------------------------------------------------------------------
- //
- // Regex
- //
- //----------------------------------------------------------------------------
- @Test
- public void string_regex_evals() {
- assertThat(filter(builder.where("string-key").regex(Pattern.compile("^string$"))).apply(createPredicateContext(json))).isEqualTo(true);
- assertThat(filter(builder.where("string-key").regex(Pattern.compile("^tring$"))).apply(createPredicateContext(json))).isEqualTo(false);
- assertThat(filter(builder.where("null-key").regex(Pattern.compile("^string$"))).apply(createPredicateContext(json))).isEqualTo(false);
- assertThat(filter(builder.where("int-key").regex(Pattern.compile("^string$"))).apply(createPredicateContext(json))).isEqualTo(false);
- }
-
- //----------------------------------------------------------------------------
- //
- // JSON equality
- //
- //----------------------------------------------------------------------------
- @Test
- public void json_evals() {
- String nest = "{\"a\":true}";
- String arr = "[1,2]";
- String json = "{\"foo\":" + arr + ", \"bar\":" + nest + "}";
- Object tree = Configuration.defaultConfiguration().jsonProvider().parse(json);
- Predicate.PredicateContext context = createPredicateContext(tree);
- Filter farr = parse("[?(@.foo == " + arr + ")]");
- //Filter fobjF = parse("[?(@.foo == " + nest + ")]");
- //Filter fobjT = parse("[?(@.bar == " + nest + ")]");
- assertThat(farr.apply(context)).isEqualTo(true);
- //assertThat(fobjF.apply(context)).isEqualTo(false);
- //assertThat(fobjT.apply(context)).isEqualTo(true);
- }
-
- //----------------------------------------------------------------------------
- //
- // IN
- //
- //----------------------------------------------------------------------------
- @Test
- public void string_in_evals() {
- assertThat(filter(builder.where("string-key").in("a", null, "string")).apply(createPredicateContext(json))).isEqualTo(true);
- assertThat(filter(builder.where("string-key").in("a", null)).apply(createPredicateContext(json))).isEqualTo(false);
- assertThat(filter(builder.where("null-key").in("a", null)).apply(createPredicateContext(json))).isEqualTo(true);
- assertThat(filter(builder.where("null-key").in("a", "b")).apply(createPredicateContext(json))).isEqualTo(false);
- assertThat(filter(builder.where("string-arr").in("a")).apply(createPredicateContext(json))).isEqualTo(false);
- }
-
- //----------------------------------------------------------------------------
- //
- // NIN
- //
- //----------------------------------------------------------------------------
- @Test
- public void string_nin_evals() {
- assertThat(filter(builder.where("string-key").nin("a", null, "string")).apply(createPredicateContext(json))).isEqualTo(false);
- assertThat(filter(builder.where("string-key").nin("a", null)).apply(createPredicateContext(json))).isEqualTo(true);
- assertThat(filter(builder.where("null-key").nin("a", null)).apply(createPredicateContext(json))).isEqualTo(false);
- assertThat(filter(builder.where("null-key").nin("a", "b")).apply(createPredicateContext(json))).isEqualTo(true);
- assertThat(filter(builder.where("string-arr").nin("a")).apply(createPredicateContext(json))).isEqualTo(true);
- }
-
- //----------------------------------------------------------------------------
- //
- // ALL
- //
- //----------------------------------------------------------------------------
- @Test
- public void int_all_evals() {
- assertThat(filter(builder.where("int-arr").all(0, 1)).apply(createPredicateContext(json))).isEqualTo(true);
- assertThat(filter(builder.where("int-arr").all(0, 7)).apply(createPredicateContext(json))).isEqualTo(false);
- }
-
- @Test
- public void string_all_evals() {
- assertThat(filter(builder.where("string-arr").all("a", "b")).apply(createPredicateContext(json))).isEqualTo(true);
- assertThat(filter(builder.where("string-arr").all("a", "x")).apply(createPredicateContext(json))).isEqualTo(false);
- }
-
- @Test
- public void not_array_all_evals() {
- assertThat(filter(builder.where("string-key").all("a", "b")).apply(createPredicateContext(json))).isEqualTo(false);
- }
-
- //----------------------------------------------------------------------------
- //
- // SIZE
- //
- //----------------------------------------------------------------------------
- @Test
- public void array_size_evals() {
- assertThat(filter(builder.where("string-arr").size(5)).apply(createPredicateContext(json))).isEqualTo(true);
- assertThat(filter(builder.where("string-arr").size(7)).apply(createPredicateContext(json))).isEqualTo(false);
- }
-
- @Test
- public void string_size_evals() {
- assertThat(filter(builder.where("string-key").size(6)).apply(createPredicateContext(json))).isEqualTo(true);
- assertThat(filter(builder.where("string-key").size(7)).apply(createPredicateContext(json))).isEqualTo(false);
- }
-
- @Test
- public void other_size_evals() {
- assertThat(filter(builder.where("int-key").size(6)).apply(createPredicateContext(json))).isEqualTo(false);
- }
-
- @Test
- public void null_size_evals() {
- assertThat(filter(builder.where("null-key").size(6)).apply(createPredicateContext(json))).isEqualTo(false);
- }
-
- //----------------------------------------------------------------------------
- //
- // SUBSETOF
- //
- //----------------------------------------------------------------------------
- @Test
- public void array_subsetof_evals() {
- // list is a superset
- List<String> list = Lists.newArrayList("a", "b", "c", "d", "e", "f", "g");
- assertThat(filter(builder.where("string-arr").subsetof(list)).apply(createPredicateContext(json))).isEqualTo(true);
- // list is exactly the same set (but in a different order)
- list = Lists.newArrayList("e", "d", "b", "c", "a");
- assertThat(filter(builder.where("string-arr").subsetof(list)).apply(createPredicateContext(json))).isEqualTo(true);
- // list is missing one element
- list = Lists.newArrayList("a", "b", "c", "d");
- assertThat(filter(builder.where("string-arr").subsetof(list)).apply(createPredicateContext(json))).isEqualTo(false);
- }
-
- //----------------------------------------------------------------------------
- //
- // EXISTS
- //
- //----------------------------------------------------------------------------
- @Test
- public void exists_evals() {
- assertThat(filter(builder.where("string-key").exists(true)).apply(createPredicateContext(json))).isEqualTo(true);
- assertThat(filter(builder.where("string-key").exists(false)).apply(createPredicateContext(json))).isEqualTo(false);
- assertThat(filter(builder.where("missing-key").exists(true)).apply(createPredicateContext(json))).isEqualTo(false);
- assertThat(filter(builder.where("missing-key").exists(false)).apply(createPredicateContext(json))).isEqualTo(true);
- }
-
- //----------------------------------------------------------------------------
- //
- // TYPE
- //
- //----------------------------------------------------------------------------
- @Test
- public void type_evals() {
- assertThat(filter(builder.where("string-key").type(String.class)).apply(createPredicateContext(json))).isEqualTo(true);
- assertThat(filter(builder.where("string-key").type(Number.class)).apply(createPredicateContext(json))).isEqualTo(false);
- assertThat(filter(builder.where("int-key").type(String.class)).apply(createPredicateContext(json))).isEqualTo(false);
- assertThat(filter(builder.where("int-key").type(Number.class)).apply(createPredicateContext(json))).isEqualTo(true);
- assertThat(filter(builder.where("null-key").type(String.class)).apply(createPredicateContext(json))).isEqualTo(false);
- assertThat(filter(builder.where("int-arr").type(List.class)).apply(createPredicateContext(json))).isEqualTo(true);
- }
-
- //----------------------------------------------------------------------------
- //
- // NOT EMPTY
- //
- //----------------------------------------------------------------------------
- @Test
- public void not_empty_evals() {
- assertThat(filter(builder.where("string-key").notEmpty()).apply(createPredicateContext(json))).isEqualTo(true);
- assertThat(filter(builder.where("string-key-empty").notEmpty()).apply(createPredicateContext(json))).isEqualTo(false);
- assertThat(filter(builder.where("int-arr").notEmpty()).apply(createPredicateContext(json))).isEqualTo(true);
- assertThat(filter(builder.where("arr-empty").notEmpty()).apply(createPredicateContext(json))).isEqualTo(false);
- assertThat(filter(builder.where("null-key").notEmpty()).apply(createPredicateContext(json))).isEqualTo(false);
- }
-
- //----------------------------------------------------------------------------
- //
- // EMPTY
- //
- //----------------------------------------------------------------------------
- @Test
- public void empty_evals() {
- assertThat(filter(builder.where("string-key").empty(false)).apply(createPredicateContext(json))).isEqualTo(true);
- assertThat(filter(builder.where("string-key").empty(true)).apply(createPredicateContext(json))).isEqualTo(false);
- assertThat(filter(builder.where("string-key-empty").empty(true)).apply(createPredicateContext(json))).isEqualTo(true);
- assertThat(filter(builder.where("string-key-empty").empty(false)).apply(createPredicateContext(json))).isEqualTo(false);
- assertThat(filter(builder.where("int-arr").empty(false)).apply(createPredicateContext(json))).isEqualTo(true);
- assertThat(filter(builder.where("int-arr").empty(true)).apply(createPredicateContext(json))).isEqualTo(false);
- assertThat(filter(builder.where("arr-empty").empty(true)).apply(createPredicateContext(json))).isEqualTo(true);
- assertThat(filter(builder.where("arr-empty").empty(false)).apply(createPredicateContext(json))).isEqualTo(false);
- assertThat(filter(builder.where("null-key").empty(true)).apply(createPredicateContext(json))).isEqualTo(false);
- assertThat(filter(builder.where("null-key").empty(false)).apply(createPredicateContext(json))).isEqualTo(false);
- }
-
- //----------------------------------------------------------------------------
- //
- // MATCHES
- //
- //----------------------------------------------------------------------------
- @Test
- public void matches_evals() {
- Predicate p = new Predicate() {
- @Override
- public boolean apply(PredicateContext ctx) {
- Map<String, Object> t = (Map<String, Object>) ctx.item();
- Object o = t.get("int-key");
- Integer i = (Integer) o;
- return i == 1;
- }
- };
- assertThat(filter(builder.where("string-key").eq("string").and("$").matches(p)).apply(createPredicateContext(json))).isEqualTo(true);
- }
-
- //----------------------------------------------------------------------------
- //
- // OR
- //
- //----------------------------------------------------------------------------
- @Test
- public void or_and_filters_evaluates() {
- Map<String, Object> model = new HashMap<String, Object>();
- model.put("foo", true);
- model.put("bar", false);
- Filter isFoo = filter(builder.where("foo").is(true));
- Filter isBar = filter(builder.where("bar").is(true));
- Filter fooOrBar = filter(builder.where("foo").is(true)).or(builder.where("bar").is(true));
- Filter fooAndBar = filter(builder.where("foo").is(true)).and(builder.where("bar").is(true));
- assertThat(isFoo.or(isBar).apply(createPredicateContext(model))).isTrue();
- assertThat(isFoo.and(isBar).apply(createPredicateContext(model))).isFalse();
- assertThat(fooOrBar.apply(createPredicateContext(model))).isTrue();
- assertThat(fooAndBar.apply(createPredicateContext(model))).isFalse();
- }
-
- @Test
- public void testFilterWithOrShortCircuit1() throws Exception {
- Object json = Configuration.defaultConfiguration().jsonProvider().parse("{\"firstname\":\"Bob\",\"surname\":\"Smith\",\"age\":30}");
- assertThat(Filter.parse("[?((@.firstname == 'Bob' || @.firstname == 'Jane') && @.surname == 'Doe')]").apply(createPredicateContext(json))).isFalse();
- }
-
- @Test
- public void testFilterWithOrShortCircuit2() throws Exception {
- Object json = Configuration.defaultConfiguration().jsonProvider().parse("{\"firstname\":\"Bob\",\"surname\":\"Smith\",\"age\":30}");
- assertThat(Filter.parse("[?((@.firstname == 'Bob' || @.firstname == 'Jane') && @.surname == 'Smith')]").apply(createPredicateContext(json))).isTrue();
- }
-
- @Test
- public void criteria_can_be_parsed() {
- Criteria criteria = Configuration.defaultConfiguration().nodeBuilder().parse("@.foo == 'baar'");
- assertThat(criteria.toString()).isEqualTo("@['foo'] == 'baar'");
- criteria = Configuration.defaultConfiguration().nodeBuilder().parse("@.foo");
- assertThat(criteria.toString()).isEqualTo("@['foo']");
- }
-
- @Test
- public void inline_in_criteria_evaluates() {
- List list = JsonPath.read(BaseTestJson.JSON_DOCUMENT, "$.store.book[?(@.category in ['reference', 'fiction'])]");
- assertThat(list).hasSize(4);
- }
-}
diff --git a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/InlineFilterTest.java b/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/InlineFilterTest.java
deleted file mode 100644
index 3c77eb4..0000000
--- a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/InlineFilterTest.java
+++ /dev/null
@@ -1,181 +0,0 @@
-package org.eclipse.sensinact.gateway.nthbnd.test.jsonpath;
-
-import com.jayway.jsonpath.Configuration;
-import com.jayway.jsonpath.JsonPath;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import static com.jayway.jsonpath.JsonPath.using;
-import static java.util.Arrays.asList;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.eclipse.sensinact.gateway.nthbnd.test.jsonpath.TestUtils.assertHasNoResults;
-import static org.eclipse.sensinact.gateway.nthbnd.test.jsonpath.TestUtils.assertHasOneResult;
-
-@RunWith(Parameterized.class)
-public class InlineFilterTest {
- @Parameterized.Parameters
- public static Iterable<Configuration> configurations() {
- return BaseTestConfiguration.configurations();
- }
-
- private static int bookCount = 4;
- private Configuration conf = BaseTestConfiguration.JSON_ORG_CONFIGURATION;
-
- public InlineFilterTest(Configuration conf) {
- this.conf = conf;
- }
-
- @Test
- public void root_context_can_be_referred_in_predicate() {
- List<Double> prices = using(conf).parse(BaseTestJson.JSON_DOCUMENT, false).read("store.book[?(@.display-price <= $.max-price)].display-price", List.class);
- assertThat(prices).containsAll(asList(8.95D, 8.99D));
- }
-
- @Test
- public void multiple_context_object_can_be_refered() {
- List all = using(conf).parse(BaseTestJson.JSON_DOCUMENT, false).read("store.book[ ?(@.category == @.category) ]", List.class);
- assertThat(all.size()).isEqualTo(bookCount);
- List all2 = using(conf).parse(BaseTestJson.JSON_DOCUMENT, false).read("store.book[ ?(@.category == @['category']) ]", List.class);
- assertThat(all2.size()).isEqualTo(bookCount);
- List all3 = using(conf).parse(BaseTestJson.JSON_DOCUMENT, false).read("store.book[ ?(@ == @) ]", List.class);
- assertThat(all3.size()).isEqualTo(bookCount);
- List none = using(conf).parse(BaseTestJson.JSON_DOCUMENT, false).read("store.book[ ?(@.category != @.category) ]", List.class);
- assertThat(none.size()).isEqualTo(0);
- List none2 = using(conf).parse(BaseTestJson.JSON_DOCUMENT, false).read("store.book[ ?(@.category != @) ]", List.class);
- assertThat(none2.size()).isEqualTo(4);
- }
-
- @Test
- public void simple_inline_or_statement_evaluates() {
- List a = using(conf).parse(BaseTestJson.JSON_DOCUMENT, false).read("store.book[ ?(@.author == 'Nigel Rees' || @.author == 'Evelyn Waugh') ].author", List.class);
- assertThat(a).containsExactly("Nigel Rees", "Evelyn Waugh");
- List b = using(conf).parse(BaseTestJson.JSON_DOCUMENT, false).read("store.book[ ?((@.author == 'Nigel Rees' || @.author == 'Evelyn Waugh') && @.display-price < 15) ].author", List.class);
- assertThat(b).containsExactly("Nigel Rees", "Evelyn Waugh");
- List c = using(conf).parse(BaseTestJson.JSON_DOCUMENT, false).read("store.book[ ?((@.author == 'Nigel Rees' || @.author == 'Evelyn Waugh') && @.category == 'reference') ].author", List.class);
- assertThat(c).containsExactly("Nigel Rees");
- List d = using(conf).parse(BaseTestJson.JSON_DOCUMENT, false).read("store.book[ ?((@.author == 'Nigel Rees') || (@.author == 'Evelyn Waugh' && @.category != 'fiction')) ].author", List.class);
- assertThat(d).containsExactly("Nigel Rees");
- }
-
- @Test
- public void no_path_ref_in_filter_hit_all() {
- List<String> res = JsonPath.parse(BaseTestJson.JSON_DOCUMENT).read("$.store.book[?('a' == 'a')].author");
- assertThat(res).containsExactly("Nigel Rees", "Evelyn Waugh", "Herman Melville", "J. R. R. Tolkien");
- }
-
- @Test
- public void no_path_ref_in_filter_hit_none() {
- List<String> res = JsonPath.parse(BaseTestJson.JSON_DOCUMENT).read("$.store.book[?('a' == 'b')].author");
- assertThat(res).isEmpty();
- }
-
- @Test
- public void path_can_be_on_either_side_of_operator() {
- List<String> resLeft = JsonPath.parse(BaseTestJson.JSON_DOCUMENT).read("$.store.book[?(@.category == 'reference')].author");
- List<String> resRight = JsonPath.parse(BaseTestJson.JSON_DOCUMENT).read("$.store.book[?('reference' == @.category)].author");
- assertThat(resLeft).containsExactly("Nigel Rees");
- assertThat(resRight).containsExactly("Nigel Rees");
- }
-
- @Test
- public void path_can_be_on_both_side_of_operator() {
- List<String> res = JsonPath.parse(BaseTestJson.JSON_DOCUMENT).read("$.store.book[?(@.category == @.category)].author");
- assertThat(res).containsExactly("Nigel Rees", "Evelyn Waugh", "Herman Melville", "J. R. R. Tolkien");
- }
-
- @Test
- public void patterns_can_be_evaluated() {
- List<String> resLeft = JsonPath.parse(BaseTestJson.JSON_DOCUMENT).read("$.store.book[?(@.category =~ /reference/)].author");
- assertThat(resLeft).containsExactly("Nigel Rees");
- resLeft = JsonPath.parse(BaseTestJson.JSON_DOCUMENT).read("$.store.book[?(/reference/ =~ @.category)].author");
- assertThat(resLeft).containsExactly("Nigel Rees");
- }
-
- @Test
- public void patterns_can_be_evaluated_with_ignore_case() {
- List<String> resLeft = JsonPath.parse(BaseTestJson.JSON_DOCUMENT).read("$.store.book[?(@.category =~ /REFERENCE/)].author");
- assertThat(resLeft).isEmpty();
- resLeft = JsonPath.parse(BaseTestJson.JSON_DOCUMENT).read("$.store.book[?(@.category =~ /REFERENCE/i)].author");
- assertThat(resLeft).containsExactly("Nigel Rees");
- }
-
- @Test
- public void negate_exists_check() {
- List<String> hasIsbn = JsonPath.parse(BaseTestJson.JSON_DOCUMENT).read("$.store.book[?(@.isbn)].author");
- assertThat(hasIsbn).containsExactly("Herman Melville", "J. R. R. Tolkien");
- List<String> noIsbn = JsonPath.parse(BaseTestJson.JSON_DOCUMENT).read("$.store.book[?(!@.isbn)].author");
- assertThat(noIsbn).containsExactly("Nigel Rees", "Evelyn Waugh");
- }
-
- @Test
- public void negate_exists_check_primitive() {
- List<Integer> ints = new ArrayList<Integer>();
- ints.add(0);
- ints.add(1);
- ints.add(null);
- ints.add(2);
- ints.add(3);
- List<Integer> hits = JsonPath.parse(ints).read("$[?(@)]");
- assertThat(hits).containsExactly(0, 1, null, 2, 3);
- hits = JsonPath.parse(ints).read("$[?(@ != null)]");
- assertThat(hits).containsExactly(0, 1, 2, 3);
- List<Integer> isNull = JsonPath.parse(ints).read("$[?(!@)]");
- assertThat(isNull).containsExactly(new Integer[]{});
- assertThat(isNull).containsExactly(new Integer[]{});
- }
-
- @Test
- public void equality_check_does_not_break_evaluation() {
- assertHasOneResult("[{\"value\":\"5\"}]", "$[?(@.value=='5')]", conf);
- assertHasOneResult("[{\"value\":5}]", "$[?(@.value==5)]", conf);
- assertHasOneResult("[{\"value\":\"5.1.26\"}]", "$[?(@.value=='5.1.26')]", conf);
- assertHasNoResults("[{\"value\":\"5\"}]", "$[?(@.value=='5.1.26')]", conf);
- assertHasNoResults("[{\"value\":5}]", "$[?(@.value=='5.1.26')]", conf);
- assertHasNoResults("[{\"value\":5.1}]", "$[?(@.value=='5.1.26')]", conf);
- assertHasNoResults("[{\"value\":\"5.1.26\"}]", "$[?(@.value=='5')]", conf);
- assertHasNoResults("[{\"value\":\"5.1.26\"}]", "$[?(@.value==5)]", conf);
- assertHasNoResults("[{\"value\":\"5.1.26\"}]", "$[?(@.value==5.1)]", conf);
- }
-
- @Test
- public void lt_check_does_not_break_evaluation() {
- assertHasOneResult("[{\"value\":\"5\"}]", "$[?(@.value<'7')]", conf);
- assertHasNoResults("[{\"value\":\"7\"}]", "$[?(@.value<'5')]", conf);
- assertHasOneResult("[{\"value\":5}]", "$[?(@.value<7)]", conf);
- assertHasNoResults("[{\"value\":7}]", "$[?(@.value<5)]", conf);
- assertHasOneResult("[{\"value\":5}]", "$[?(@.value<7.1)]", conf);
- assertHasNoResults("[{\"value\":7}]", "$[?(@.value<5.1)]", conf);
- assertHasOneResult("[{\"value\":5.1}]", "$[?(@.value<7)]", conf);
- assertHasNoResults("[{\"value\":7.1}]", "$[?(@.value<5)]", conf);
- }
-
- @Test
- public void escaped_literals() {
- if (conf.jsonProvider().getClass().getSimpleName().startsWith("Jackson")) {
- return;
- }
- assertHasOneResult("[\"\\'foo\"]", "$[?(@ == '\\'foo')]", conf);
- }
-
- @Test
- public void escaped_literals2() {
- if (conf.jsonProvider().getClass().getSimpleName().startsWith("Jackson")) {
- return;
- }
- assertHasOneResult("[\"\\\\'foo\"]", "$[?(@ == \"\\\\'foo\")]", conf);
- }
-
- @Test
- public void escape_pattern() {
- assertHasOneResult("[\"x\"]", "$[?(@ =~ /\\/|x/)]", conf);
- }
-
- @Test
- public void filter_evaluation_does_not_break_path_evaluation() {
- assertHasOneResult("[{\"s\": \"fo\", \"expected_size\": \"m\"}, {\"s\": \"lo\", \"expected_size\": 2}]", "$[?(@.s size @.expected_size)]", conf);
- }
-}
diff --git a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/JsonOrgJsonProviderTest.java b/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/JsonOrgJsonProviderTest.java
deleted file mode 100644
index 0178557..0000000
--- a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/JsonOrgJsonProviderTest.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package org.eclipse.sensinact.gateway.nthbnd.test.jsonpath;
-
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-import org.junit.Test;
-
-import java.util.List;
-import java.util.Map;
-
-import static com.jayway.jsonpath.JsonPath.using;
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class JsonOrgJsonProviderTest extends BaseTestConfiguration {
- @Test
- public void an_object_can_be_read() throws JSONException {
- JSONObject book = using(JSON_ORG_CONFIGURATION).parse(BaseTestJson.JSON_DOCUMENT, false).read("$.store.book[0]");
- assertThat(book.get("author").toString()).isEqualTo("Nigel Rees");
- }
-
- @Test
- public void a_property_can_be_read() {
- String category = using(JSON_ORG_CONFIGURATION).parse(BaseTestJson.JSON_DOCUMENT, false).read("$.store.book[0].category");
- assertThat(category).isEqualTo("reference");
- }
-
- @Test
- public void a_filter_can_be_applied() {
- JSONArray fictionBooks = using(JSON_ORG_CONFIGURATION).parse(BaseTestJson.JSON_DOCUMENT, false).read("$.store.book[?(@.category == 'fiction')]");
- assertThat(fictionBooks.length()).isEqualTo(3);
- }
-
- @Test
- public void result_can_be_mapped_to_object() {
- List<Map<String, Object>> books = using(JSON_ORG_CONFIGURATION).parse(BaseTestJson.JSON_DOCUMENT, false).read("$.store.book", List.class);
- assertThat(books.size()).isEqualTo(4);
- }
-
- @Test
- public void read_books_with_isbn() {
- JSONArray books = using(JSON_ORG_CONFIGURATION).parse(BaseTestJson.JSON_DOCUMENT, false).read("$..book[?(@.isbn)]");
- assertThat(books.length()).isEqualTo(2);
- }
-}
diff --git a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/JsonProviderTest.java b/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/JsonProviderTest.java
deleted file mode 100644
index 671be53..0000000
--- a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/JsonProviderTest.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package org.eclipse.sensinact.gateway.nthbnd.test.jsonpath;
-
-import com.jayway.jsonpath.Configuration;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import static org.assertj.core.api.Assertions.assertThat;
-import static com.jayway.jsonpath.JsonPath.using;
-
-@RunWith(Parameterized.class)
-public class JsonProviderTest extends BaseTestConfiguration {
- @Parameterized.Parameters
- public static Iterable<Configuration> configurations() {
- return BaseTestConfiguration.configurations();
- }
-
- private final Configuration conf;
-
- public JsonProviderTest(Configuration conf) {
- this.conf = conf;
- }
-
- @Test
- public void strings_are_unwrapped() {
- assertThat(using(conf).parse(BaseTestJson.JSON_DOCUMENT, false).read("$.string-property", String.class)).isEqualTo("string-value");
- }
-
- @Test
- public void integers_are_unwrapped() {
- assertThat(using(conf).parse(BaseTestJson.JSON_DOCUMENT, false).read("$.int-max-property", Integer.class)).isEqualTo(Integer.MAX_VALUE);
- }
-
- @Test
- public void ints_are_unwrapped() {
- assertThat(using(conf).parse(BaseTestJson.JSON_DOCUMENT, false).read("$.int-max-property", int.class)).isEqualTo(Integer.MAX_VALUE);
- }
-}
diff --git a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/JsonProviderTestObjectMapping.java b/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/JsonProviderTestObjectMapping.java
deleted file mode 100644
index 4c2ef1a..0000000
--- a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/JsonProviderTestObjectMapping.java
+++ /dev/null
@@ -1,55 +0,0 @@
-package org.eclipse.sensinact.gateway.nthbnd.test.jsonpath;
-
-import com.jayway.jsonpath.Configuration;
-import com.jayway.jsonpath.TypeRef;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-
-import java.io.IOException;
-import java.util.List;
-import static org.assertj.core.api.Assertions.assertThat;
-import static com.jayway.jsonpath.JsonPath.using;
-
-@RunWith(Parameterized.class)
-public class JsonProviderTestObjectMapping extends BaseTestConfiguration {
- @Parameterized.Parameters
- public static Iterable<Configuration> configurations() {
- return BaseTestConfiguration.objectMappingConfigurations();
- }
-
- private static final String JSON = "[" + "{\n" + " \"foo\" : \"foo0\",\n" + " \"bar\" : 0,\n" + " \"baz\" : true,\n" + " \"gen\" : {\"prop\" : \"yepp0\"}" + "}," + "{\n" + " \"foo\" : \"foo1\",\n" + " \"bar\" : 1,\n" + " \"baz\" : true,\n" + " \"gen\" : {\"prop\" : \"yepp1\"}" + "}," + "{\n" + " \"foo\" : \"foo2\",\n" + " \"bar\" : 2,\n" + " \"baz\" : true,\n" + " \"gen\" : {\"prop\" : \"yepp2\"}" + "}" + "]";
- private final Configuration conf;
-
- public JsonProviderTestObjectMapping(Configuration conf) {
- this.conf = conf;
- }
-
- @Ignore
- @Test
- public void list_of_numbers() {
- TypeRef<List<Double>> typeRef = new TypeRef<List<Double>>() {
- };
- assertThat(using(conf).parse(BaseTestJson.JSON_DOCUMENT, false).read("$.store.book[*].display-price", typeRef)).containsExactly(8.95D, 12.99D, 8.99D, 22.99D);
- }
-
- @Ignore
- @Test
- public void test_type_ref() throws IOException {
- TypeRef<List<FooBarBaz<Sub>>> typeRef = new TypeRef<List<FooBarBaz<Sub>>>() {
- };
- assertThat(using(conf).parse(JSON, false).read("$", typeRef)).extracting("foo").containsExactly("foo0", "foo1", "foo2");
- }
-
- public static class FooBarBaz<T> {
- public T gen;
- public String foo;
- public Long bar;
- public boolean baz;
- }
-
- public static class Sub {
- public String prop;
- }
-}
diff --git a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/MapperTest.java b/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/MapperTest.java
deleted file mode 100644
index 2b8d1dc..0000000
--- a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/MapperTest.java
+++ /dev/null
@@ -1,58 +0,0 @@
-package org.eclipse.sensinact.gateway.nthbnd.test.jsonpath;
-
-import org.junit.Test;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.util.Date;
-import static org.assertj.core.api.Assertions.assertThat;
-import static com.jayway.jsonpath.JsonPath.parse;
-
-public class MapperTest extends BaseTestConfiguration {
- @Test
- public void an_Integer_can_be_converted_to_a_Long() {
- assertThat(parse("{\"val\": 1}").read("val", Long.class)).isEqualTo(1L);
- }
-
- @Test
- public void an_String_can_be_converted_to_a_Long() {
- assertThat(parse("{\"val\": 1}").read("val", Long.class)).isEqualTo(1L);
- }
-
- @Test
- public void an_Integer_can_be_converted_to_a_String() {
- assertThat(parse("{\"val\": 1}").read("val", String.class)).isEqualTo("1");
- }
-
- @Test
- public void an_Integer_can_be_converted_to_a_Double() {
- assertThat(parse("{\"val\": 1}").read("val", Double.class)).isEqualTo(1D);
- }
-
- @Test
- public void a_BigDecimal_can_be_converted_to_a_Long() {
- assertThat(parse("{\"val\": 1.5}").read("val", Long.class)).isEqualTo(1L);
- }
-
- @Test
- public void a_Long_can_be_converted_to_a_Date() {
- Date now = new Date();
- assertThat(parse("{\"val\": " + now.getTime() + "}").read("val", Date.class)).isEqualTo(now);
- }
-
- @Test
- public void a_String_can_be_converted_to_a_BigInteger() {
- assertThat(parse("{\"val\": \"1\"}").read("val", BigInteger.class)).isEqualTo(BigInteger.valueOf(1));
- }
-
- @Test
- public void a_String_can_be_converted_to_a_BigDecimal() {
- assertThat(parse("{\"val\": \"1.5\"}").read("val", BigDecimal.class)).isEqualTo(BigDecimal.valueOf(1.5d));
- }
-
- @Test
- public void a_Boolean_can_be_converted_to_a_primitive_boolean() {
- assertThat(parse("{\"val\": true}").read("val", boolean.class)).isTrue();
- assertThat(parse("{\"val\": false}").read("val", boolean.class)).isFalse();
- }
-}
diff --git a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/OptionsTest.java b/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/OptionsTest.java
deleted file mode 100644
index a1f2140..0000000
--- a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/OptionsTest.java
+++ /dev/null
@@ -1,128 +0,0 @@
-package org.eclipse.sensinact.gateway.nthbnd.test.jsonpath;
-
-import com.jayway.jsonpath.Configuration;
-import com.jayway.jsonpath.JsonPath;
-import com.jayway.jsonpath.Option;
-import com.jayway.jsonpath.PathNotFoundException;
-import org.junit.Test;
-
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import static com.jayway.jsonpath.JsonPath.using;
-import static com.jayway.jsonpath.Option.*;
-import static java.util.Arrays.asList;
-import static java.util.Collections.singletonMap;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.fail;
-
-public class OptionsTest extends BaseTestConfiguration {
- @Test(expected = PathNotFoundException.class)
- public void a_leafs_is_not_defaulted_to_null() {
- Configuration conf = Configuration.defaultConfiguration();
- assertThat(using(conf).parse("{\"foo\" : \"bar\"}", false).read("$.baz")).isNull();
- }
-
- @Test
- public void a_leafs_can_be_defaulted_to_null() {
- Configuration conf = Configuration.builder().options(DEFAULT_PATH_LEAF_TO_NULL).build();
- assertThat(using(conf).parse("{\"foo\" : \"bar\"}", false).read("$.baz", Object.class)).isNull();
- }
-
- @Test
- public void a_definite_path_is_not_returned_as_list_by_default() {
- Configuration conf = Configuration.defaultConfiguration();
- assertThat(using(conf).parse("{\"foo\" : \"bar\"}", false).read("$.foo")).isInstanceOf(String.class);
- }
-
- @Test
- public void a_definite_path_can_be_returned_as_list() {
- Configuration conf = Configuration.builder().options(ALWAYS_RETURN_LIST).build();
- assertThat(using(conf).parse("{\"foo\" : \"bar\"}", false).read("$.foo")).isInstanceOf(List.class);
- assertThat(using(conf).parse("{\"foo\": null}", false).read("$.foo")).isInstanceOf(List.class);
- assertThat(using(conf).parse("{\"foo\": [1, 4, 8]}", false).read("$.foo")).asList().containsExactly(Arrays.asList(1, 4, 8));
- }
-
- @Test
- public void an_indefinite_path_can_be_returned_as_list() {
- Configuration conf = Configuration.builder().options(ALWAYS_RETURN_LIST).build();
- List<Object> result = using(conf).parse("{\"bar\": {\"foo\": null}}", false).read("$..foo");
- assertThat(result).hasSize(1);
- assertThat(result.get(0)).isNull();
- assertThat(using(conf).parse("{\"bar\": {\"foo\": [1, 4, 8]}}", false).read("$..foo")).asList().containsExactly(Arrays.asList(1, 4, 8));
- }
-
- @Test
- public void a_path_evaluation_is_returned_as_VALUE_by_default() {
- Configuration conf = Configuration.defaultConfiguration();
- assertThat(using(conf).parse("{\"foo\" : \"bar\"}", false).read("$.foo")).isEqualTo("bar");
- }
-
- @Test
- public void a_path_evaluation_can_be_returned_as_PATH_LIST() {
- Configuration conf = Configuration.builder().options(AS_PATH_LIST).build();
- List<String> pathList = using(conf).parse("{\"foo\" : \"bar\"}", false).read("$.foo");
- assertThat(pathList).containsOnly("$['foo']");
- }
-
- @Test
- public void multi_properties_are_merged_by_default() {
- Map<String, Object> model = new HashMap<String, Object>();
- model.put("a", "a");
- model.put("b", "b");
- model.put("c", "c");
- Configuration conf = Configuration.defaultConfiguration();
- Map<String, Object> result = using(conf).parse(model, false).read("$.['a', 'b']");
- //assertThat(result).isInstanceOf(List.class);
- //assertThat((List)result).containsOnly("a", "b");
- assertThat(result).containsEntry("a", "a").containsEntry("b", "b");
- }
-
- @Test
- public void when_property_is_required_exception_is_thrown() {
- List<Map<String, String>> model = asList(singletonMap("a", "a-val"), singletonMap("b", "b-val"));
- Configuration conf = Configuration.defaultConfiguration();
- assertThat(using(conf).parse(model, false).read("$[*].a", List.class)).containsExactly("a-val");
- conf = conf.addOptions(Option.REQUIRE_PROPERTIES);
- try {
- using(conf).parse(model, false).read("$[*].a", List.class);
- fail("Should throw PathNotFoundException");
- } catch (PathNotFoundException pnf) {
- }
- }
-
- @Test
- public void when_property_is_required_exception_is_thrown_2() {
- Map<String, Object> model = new HashMap<String, Object>();
- model.put("a", singletonMap("a-key", "a-val"));
- model.put("b", singletonMap("b-key", "b-val"));
- Configuration conf = Configuration.defaultConfiguration();
- assertThat(using(conf).parse(model, false).read("$.*.a-key", List.class)).containsExactly("a-val");
- conf = conf.addOptions(Option.REQUIRE_PROPERTIES);
- try {
- using(conf).parse(model, false).read("$.*.a-key", List.class);
- fail("Should throw PathNotFoundException");
- } catch (PathNotFoundException pnf) {
- }
- }
-
- @Test
- public void issue_suppress_exceptions_does_not_break_indefinite_evaluation() {
- Configuration conf = Configuration.builder().options(SUPPRESS_EXCEPTIONS).build();
- assertThat(using(conf).parse("{\"foo2\": [5]}", false).read("$..foo2[0]")).asList().containsOnly(5);
- assertThat(using(conf).parse("{\"foo\" : {\"foo2\": [5]}}", false).read("$..foo2[0]")).asList().containsOnly(5);
- assertThat(using(conf).parse("[null, [{\"foo\" : {\"foo2\": [5]}}]]", false).read("$..foo2[0]")).asList().containsOnly(5);
- assertThat(using(conf).parse("[null, [{\"foo\" : {\"foo2\": [5]}}]]", false).read("$..foo.foo2[0]")).asList().containsOnly(5);
- assertThat(using(conf).parse("{\"aoo\" : {}, \"foo\" : {\"foo2\": [5]}, \"zoo\" : {}}", false).read("$[*].foo2[0]")).asList().containsOnly(5);
- }
-
- @Test
- public void isbn_is_defaulted_when_option_is_provided() {
- List<String> result1 = JsonPath.using(JSON_ORG_CONFIGURATION).parse(BaseTestJson.JSON_DOCUMENT, false).read("$.store.book.*.isbn");
- assertThat(result1).containsExactly("0-553-21311-3", "0-395-19395-8");
- List<String> result2 = JsonPath.using(JSON_ORG_CONFIGURATION.addOptions(Option.DEFAULT_PATH_LEAF_TO_NULL)).parse(BaseTestJson.JSON_DOCUMENT, false).read("$.store.book.*.isbn");
- assertThat(result2).containsExactly(null, null, "0-553-21311-3", "0-395-19395-8");
- }
-}
diff --git a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/PredicateTest.java b/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/PredicateTest.java
deleted file mode 100644
index b9ddf3f..0000000
--- a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/PredicateTest.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package org.eclipse.sensinact.gateway.nthbnd.test.jsonpath;
-
-import com.jayway.jsonpath.Predicate;
-import com.jayway.jsonpath.Predicate.PredicateContext;
-import com.jayway.jsonpath.ReadContext;
-import org.junit.Test;
-
-import java.util.List;
-import java.util.Map;
-
-import static com.jayway.jsonpath.JsonPath.using;
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class PredicateTest extends BaseTestConfiguration {
- private static ReadContext reader = using(JSON_ORG_CONFIGURATION).parse(BaseTestJson.JSON_DOCUMENT, false);
-
- @Test
- public void predicates_filters_can_be_applied() {
- Predicate booksWithISBN = new Predicate() {
- @Override
- public boolean apply(PredicateContext ctx) {
- return ctx.item(Map.class).containsKey("isbn");
- }
- };
- assertThat(reader.read("$.store.book[?].isbn", List.class, booksWithISBN)).containsOnly("0-395-19395-8", "0-553-21311-3");
- }
-}
diff --git a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/ProviderInTest.java b/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/ProviderInTest.java
deleted file mode 100644
index ba742c0..0000000
--- a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/ProviderInTest.java
+++ /dev/null
@@ -1,36 +0,0 @@
-package org.eclipse.sensinact.gateway.nthbnd.test.jsonpath;
-
-import com.jayway.jsonpath.Configuration;
-import com.jayway.jsonpath.DocumentContext;
-import com.jayway.jsonpath.JsonPath;
-import org.eclipse.sensinact.gateway.nthbnd.jsonpath.json.JsonOrgJsonProvider;
-import org.eclipse.sensinact.gateway.nthbnd.jsonpath.mapper.JsonOrgMappingProvider;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-
-public class ProviderInTest {
- private final String JSON = "[{\"foo\": \"bar\"}, {\"foo\": \"baz\"}]";
- private final String EQUALS_FILTER = "$.[?(@.foo == %s)].foo";
- private final String IN_FILTER = "$.[?(@.foo in [%s])].foo";
- private final String DOUBLE_QUOTES = "\"bar\"";
- private final String DOUBLE_QUOTES_EQUALS_FILTER = String.format(EQUALS_FILTER, DOUBLE_QUOTES);
- private final String DOUBLE_QUOTES_IN_FILTER = String.format(IN_FILTER, DOUBLE_QUOTES);
- private final String SINGLE_QUOTES = "'bar'";
- private final String SINGLE_QUOTES_EQUALS_FILTER = String.format(EQUALS_FILTER, SINGLE_QUOTES);
- private final String SINGLE_QUOTES_IN_FILTER = String.format(IN_FILTER, SINGLE_QUOTES);
-
- @Test
- public void testJsonPathQuotesJsonOrg() throws Exception {
- final Configuration jsonOrg = Configuration.builder().jsonProvider(new JsonOrgJsonProvider()).mappingProvider(new JsonOrgMappingProvider()).build();
- final DocumentContext ctx = JsonPath.using(jsonOrg).parse(JSON, false);
- final org.json.JSONArray doubleQuoteEqualsResult = ctx.read(DOUBLE_QUOTES_EQUALS_FILTER);
- assertEquals("bar", doubleQuoteEqualsResult.get(0));
- final org.json.JSONArray singleQuoteEqualsResult = ctx.read(SINGLE_QUOTES_EQUALS_FILTER);
- assertEquals(doubleQuoteEqualsResult.get(0), singleQuoteEqualsResult.get(0));
- final org.json.JSONArray doubleQuoteInResult = ctx.read(DOUBLE_QUOTES_IN_FILTER);
- assertEquals(doubleQuoteInResult.get(0), doubleQuoteEqualsResult.get(0));
- final org.json.JSONArray singleQuoteInResult = ctx.read(SINGLE_QUOTES_IN_FILTER);
- assertEquals(doubleQuoteInResult.get(0), singleQuoteInResult.get(0));
- }
-}
\ No newline at end of file
diff --git a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/ReadContextTest.java b/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/ReadContextTest.java
deleted file mode 100644
index f9ff402..0000000
--- a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/ReadContextTest.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package org.eclipse.sensinact.gateway.nthbnd.test.jsonpath;
-
-import org.assertj.core.api.Assertions;
-import org.json.JSONException;
-import org.json.JSONObject;
-import org.junit.Test;
-
-import static com.jayway.jsonpath.JsonPath.using;
-
-public class ReadContextTest extends BaseTestConfiguration {
- @Test
- public void json_can_be_fetched_as_string() throws JSONException {
- String expected = new JSONObject("{\"category\":\"reference\",\"author\":\"Nigel Rees\",\"title\":\"Sayings of the Century\",\"display-price\":8.95}").toString();
- String jsonString1 = using(JSON_ORG_CONFIGURATION).parse(BaseTestJson.JSON_BOOK_DOCUMENT, false).jsonString();
-
- Assertions.assertThat(jsonString1).isEqualTo(expected);
- }
-}
diff --git a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/ReturnTypeTest.java b/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/ReturnTypeTest.java
deleted file mode 100644
index 3efa4ca..0000000
--- a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/ReturnTypeTest.java
+++ /dev/null
@@ -1,70 +0,0 @@
-package org.eclipse.sensinact.gateway.nthbnd.test.jsonpath;
-
-import com.jayway.jsonpath.Configuration;
-import com.jayway.jsonpath.ReadContext;
-import org.junit.Test;
-
-import java.util.List;
-import java.util.Map;
-
-import static com.jayway.jsonpath.JsonPath.parse;
-import static com.jayway.jsonpath.JsonPath.using;
-import static com.jayway.jsonpath.Option.AS_PATH_LIST;
-import static org.assertj.core.api.Assertions.assertThat;
-
-@SuppressWarnings("ALL")
-public class ReturnTypeTest extends BaseTestConfiguration {
- private static ReadContext reader = parse(BaseTestJson.JSON_DOCUMENT);
-
- @Test
- public void assert_strings_can_be_read() {
- assertThat(reader.read("$.string-property")).isEqualTo("string-value");
- }
-
- @Test
- public void assert_ints_can_be_read() {
- assertThat(reader.read("$.int-max-property", Integer.class)).isEqualTo(Integer.MAX_VALUE);
- }
-
- @Test
- public void assert_longs_can_be_read() {
- assertThat(reader.read("$.long-max-property")).isEqualTo(Long.MAX_VALUE);
- }
-
- @Test
- public void assert_boolean_values_can_be_read() {
- assertThat(reader.read("$.boolean-property")).isEqualTo(true);
- }
-
- @Test
- public void assert_null_values_can_be_read() {
- assertThat(reader.read("$.null-property")).isNull();
- }
-
- @Test
- public void assert_arrays_can_be_read() {
- /*
- Object result = reader.read("$.store.book");
- assertThat(reader.configuration().jsonProvider().isArray(result)).isTrue();
- assertThat(reader.configuration().jsonProvider().length(result)).isEqualTo(4);
- */
- assertThat(reader.read("$.store.book", List.class)).hasSize(4);
- }
-
- @Test
- public void assert_maps_can_be_read() {
- assertThat(reader.read("$.store.book[0]", Map.class)).containsEntry("category", "reference").containsEntry("author", "Nigel Rees").containsEntry("title", "Sayings of the Century").containsEntry("display-price", 8.95D);
- }
-
- @Test
- public void a_path_evaluation_can_be_returned_as_PATH_LIST() {
- Configuration conf = Configuration.builder().options(AS_PATH_LIST).build();
- List<String> pathList = using(conf).parse(BaseTestJson.JSON_DOCUMENT, false).read("$..author");
- assertThat(pathList).containsExactly("$['store']['book'][0]['author']", "$['store']['book'][1]['author']", "$['store']['book'][2]['author']", "$['store']['book'][3]['author']");
- }
-
- @Test(expected = ClassCastException.class)
- public void class_cast_exception_is_thrown_when_return_type_is_not_expected() {
- List<String> list = reader.read("$.store.book[0].author");
- }
-}
diff --git a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/TestUtils.java b/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/TestUtils.java
deleted file mode 100644
index f9cde46..0000000
--- a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/TestUtils.java
+++ /dev/null
@@ -1,68 +0,0 @@
-package org.eclipse.sensinact.gateway.nthbnd.test.jsonpath;
-
-import com.jayway.jsonpath.Configuration;
-import com.jayway.jsonpath.JsonPath;
-import com.jayway.jsonpath.JsonPathException;
-import static org.assertj.core.api.Assertions.assertThat;
-import static com.jayway.jsonpath.JsonPath.using;
-import static org.assertj.core.api.Assertions.fail;
-
-public final class TestUtils {
- private TestUtils() {
- }
-
- public static void assertEvaluationThrows(final String json, final String path, Class<? extends JsonPathException> expected) {
- assertEvaluationThrows(json, path, expected, Configuration.defaultConfiguration());
- }
-
- /**
- * Shortcut for expected exception testing during path evaluation.
- *
- * @param json json to parse
- * @param path jsonpath do evaluate
- * @param expected expected exception class (reference comparison, not an instanceof)
- * @param conf conf to use during evaluation
- */
- public static void assertEvaluationThrows(final String json, final String path, Class<? extends JsonPathException> expected, final Configuration conf) {
- try {
- using(conf).parse(json, false).read(path);
- fail("Should throw " + expected.getName());
- } catch (JsonPathException exc) {
- if (exc.getClass() != expected) throw exc;
- }
- }
-
- /**
- * Assertion which requires empty list as a result of indefinite path search.
- *
- * @param json json to be parsed
- * @param path path to be evaluated
- * @param conf conf to use during evaluation
- */
- public static void assertHasNoResults(final String json, final String path, Configuration conf) {
- assertHasResults(json, path, 0, conf);
- }
-
- /**
- * Assertion which requires list of one element as a result of indefinite path search.
- *
- * @param json json to be parsed
- * @param path path to be evaluated
- */
- public static void assertHasOneResult(final String json, final String path, Configuration conf) {
- assertHasResults(json, path, 1, conf);
- }
-
- /**
- * Shortcut for counting found nodes.
- *
- * @param json json to be parsed
- * @param path path to be evaluated
- * @param expectedResultCount expected number of nodes to be found
- * @param conf conf to use during evaluation
- */
- public static void assertHasResults(final String json, final String path, final int expectedResultCount, Configuration conf) {
- Object result = JsonPath.using(conf).parse(json, false).read(path);
- assertThat(conf.jsonProvider().length(result)).isEqualTo(expectedResultCount);
- }
-}
diff --git a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/WriteTest.java b/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/WriteTest.java
deleted file mode 100644
index 79bb457..0000000
--- a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/WriteTest.java
+++ /dev/null
@@ -1,271 +0,0 @@
-package org.eclipse.sensinact.gateway.nthbnd.test.jsonpath;
-
-import com.jayway.jsonpath.Configuration;
-import com.jayway.jsonpath.DocumentContext;
-import com.jayway.jsonpath.InvalidModificationException;
-import com.jayway.jsonpath.JsonPath;
-import com.jayway.jsonpath.MapFunction;
-import com.jayway.jsonpath.PathNotFoundException;
-import org.junit.Test;
-
-import java.io.InputStream;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-import static com.jayway.jsonpath.JsonPath.parse;
-import static java.util.Collections.emptyMap;
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class WriteTest {
- private static final Map<String, Object> EMPTY_MAP = emptyMap();
-
- @Test
- public void an_array_child_property_can_be_updated() {
- Object o = parse(BaseTestJson.JSON_DOCUMENT).set("$.store.book[*].display-price", 1).json();
- List<Integer> result = parse(o).read("$.store.book[*].display-price");
- assertThat(result).containsExactly(1, 1, 1, 1);
- }
-
- @Test
- public void an_root_property_can_be_updated() {
- Object o = parse(BaseTestJson.JSON_DOCUMENT).set("$.int-max-property", 1).json();
- Integer result = parse(o).read("$.int-max-property");
- assertThat(result).isEqualTo(1);
- }
-
- @Test
- public void an_deep_scan_can_update() {
- Object o = parse(BaseTestJson.JSON_DOCUMENT).set("$..display-price", 1).json();
- List<Integer> result = parse(o).read("$..display-price");
- assertThat(result).containsExactly(1, 1, 1, 1, 1);
- }
-
- @Test
- public void an_filter_can_update() {
- Object o = parse(BaseTestJson.JSON_DOCUMENT).set("$.store.book[?(@.display-price)].display-price", 1).json();
- List<Integer> result = parse(o).read("$.store.book[?(@.display-price)].display-price");
- assertThat(result).containsExactly(1, 1, 1, 1);
- }
-
- @Test
- public void a_path_can_be_deleted() {
- Object o = parse(BaseTestJson.JSON_DOCUMENT).delete("$.store.book[*].display-price").json();
- List<Integer> result = parse(o).read("$.store.book[*].display-price");
- assertThat(result).isEmpty();
- }
-
- @Test
- public void operations_can_chained() {
- Object o = parse(BaseTestJson.JSON_DOCUMENT).delete("$.store.book[*].display-price").set("$.store.book[*].category", "A").json();
- List<Integer> prices = parse(o).read("$.store.book[*].display-price");
- List<String> categories = parse(o).read("$.store.book[*].category");
- assertThat(prices).isEmpty();
- assertThat(categories).containsExactly("A", "A", "A", "A");
- }
-
- @Test
- public void an_array_can_be_updated() {
- List<Integer> result = parse("[0,1,2,3]").set("$[?(@ == 1)]", 9).json();
- assertThat(result).containsExactly(0, 9, 2, 3);
- }
-
- @Test
- public void an_array_index_can_be_updated() {
- String res = parse(BaseTestJson.JSON_DOCUMENT).set("$.store.book[0]", "a").read("$.store.book[0]");
- assertThat(res).isEqualTo("a");
- }
-
- @Test
- public void an_array_slice_can_be_updated() {
- List<String> result = parse(BaseTestJson.JSON_DOCUMENT).set("$.store.book[0:2]", "a").read("$.store.book[0:2]");
- assertThat(result).containsExactly("a", "a");
- }
-
- @Test
- public void an_array_criteria_can_be_updated() {
- List<String> result = parse(BaseTestJson.JSON_DOCUMENT).set("$.store.book[?(@.category == 'fiction')]", "a").read("$.store.book[?(@ == 'a')]");
- assertThat(result).containsExactly("a", "a", "a");
- }
-
- @Test
- public void an_array_criteria_can_be_deleted() {
- List<String> result = parse(BaseTestJson.JSON_DOCUMENT).delete("$.store.book[?(@.category == 'fiction')]").read("$.store.book[*].category");
- assertThat(result).containsExactly("reference");
- }
-
- @Test
- public void an_array_criteria_with_multiple_results_can_be_deleted() {
- InputStream stream = this.getClass().getResourceAsStream("/json_array_multiple_delete.json");
- String deletePath = "$._embedded.mandates[?(@.count=~/0/)]";
- DocumentContext documentContext = JsonPath.parse(stream);
- documentContext.delete(deletePath);
- List<Object> result = documentContext.read(deletePath);
- assertThat(result.size()).isEqualTo(0);
- }
-
- @Test
- public void multi_prop_delete() {
- List<Map<String, Object>> res = parse(BaseTestJson.JSON_DOCUMENT).delete("$.store.book[*]['author', 'category']").read("$.store.book[*]['author', 'category']");
- assertThat(res).containsExactly(EMPTY_MAP, EMPTY_MAP, EMPTY_MAP, EMPTY_MAP);
- }
-
- @Test
- public void multi_prop_update() {
- Map<String, Object> expected = new HashMap<String, Object>() {{
- put("author", "a");
- put("category", "a");
- }};
- List<Map<String, Object>> res = parse(BaseTestJson.JSON_DOCUMENT).set("$.store.book[*]['author', 'category']", "a").read("$.store.book[*]['author', 'category']");
- assertThat(res).containsExactly(expected, expected, expected, expected);
- }
-
- @Test
- @SuppressWarnings("unchecked")
- public void multi_prop_update_not_all_defined() {
- Map<String, Object> expected = new HashMap<String, Object>() {{
- put("author", "a");
- put("isbn", "a");
- }};
- List<Map<String, Object>> res = parse(BaseTestJson.JSON_DOCUMENT).set("$.store.book[*]['author', 'isbn']", "a").read("$.store.book[*]['author', 'isbn']");
- assertThat(res).containsExactly(expected, expected, expected, expected);
- }
-
- @Test
- public void add_to_array() {
- Object res = parse(BaseTestJson.JSON_DOCUMENT).add("$.store.book", 1).read("$.store.book[4]");
- assertThat(res).isEqualTo(1);
- }
-
- @Test
- public void add_to_object() {
- Object res = parse(BaseTestJson.JSON_DOCUMENT).put("$.store.book[0]", "new-key", "new-value").read("$.store.book[0].new-key");
- assertThat(res).isEqualTo("new-value");
- }
-
- @Test
- public void item_can_be_added_to_root_array() {
- List<Integer> model = new LinkedList<Integer>();
- model.add(1);
- model.add(2);
- List<Integer> ints = parse(model).add("$", 3).read("$");
- assertThat(ints).containsExactly(1, 2, 3);
- }
-
- @Test
- public void key_val_can_be_added_to_root_object() {
- Map model = new HashMap();
- model.put("a", "a-val");
- String newVal = parse(model).put("$", "new-key", "new-val").read("$.new-key");
- assertThat(newVal).isEqualTo("new-val");
- }
-
- @Test(expected = InvalidModificationException.class)
- public void add_to_object_on_array() {
- parse(BaseTestJson.JSON_DOCUMENT).put("$.store.book", "new-key", "new-value");
- }
-
- @Test(expected = InvalidModificationException.class)
- public void add_to_array_on_object() {
- parse(BaseTestJson.JSON_DOCUMENT).add("$.store.book[0]", "new-value");
- }
-
- @Test(expected = InvalidModificationException.class)
- public void root_object_can_not_be_updated() {
- Map model = new HashMap();
- model.put("a", "a-val");
- parse(model).set("$[?(@.a == 'a-val')]", 1);
- }
-
- @Test
- public void a_path_can_be_renamed() {
- Object o = parse(BaseTestJson.JSON_DOCUMENT).renameKey("$.store", "book", "updated-book").json();
- List<Object> result = parse(o).read("$.store.updated-book");
- assertThat(result).isNotEmpty();
- }
-
- @Test
- public void keys_in_root_containing_map_can_be_renamed() {
- Object o = parse(BaseTestJson.JSON_DOCUMENT).renameKey("$", "store", "new-store").json();
- List<Object> result = parse(o).read("$.new-store[*]");
- assertThat(result).isNotEmpty();
- }
-
- @Test
- public void map_array_items_can_be_renamed() {
- Object o = parse(BaseTestJson.JSON_DOCUMENT).renameKey("$.store.book[*]", "category", "renamed-category").json();
- List<Object> result = parse(o).read("$.store.book[*].renamed-category");
- assertThat(result).isNotEmpty();
- }
-
- @Test(expected = InvalidModificationException.class)
- public void non_map_array_items_cannot_be_renamed() {
- List<Integer> model = new LinkedList<Integer>();
- model.add(1);
- model.add(2);
- parse(model).renameKey("$[*]", "oldKey", "newKey");
- }
-
- @Test(expected = InvalidModificationException.class)
- public void multiple_properties_cannot_be_renamed() {
- parse(BaseTestJson.JSON_DOCUMENT).renameKey("$.store.book[*]['author', 'category']", "old-key", "new-key");
- }
-
- @Test(expected = PathNotFoundException.class)
- public void non_existent_key_rename_not_allowed() {
- Object o = parse(BaseTestJson.JSON_DOCUMENT).renameKey("$", "fake", "new-fake").json();
- }
-
- @Test(expected = InvalidModificationException.class)
- public void rootCannotBeMapped() {
- MapFunction mapFunction = new MapFunction() {
- @Override
- public Object map(Object currentValue, Configuration configuration) {
- return currentValue.toString() + "converted";
- }
- };
- Object o = parse(BaseTestJson.JSON_DOCUMENT).map("$", mapFunction).json();
- }
-
- @Test
- public void single_match_value_can_be_mapped() {
- MapFunction mapFunction = new ToStringMapFunction();
- String stringResult = parse(BaseTestJson.JSON_DOCUMENT).map("$.string-property", mapFunction).read("$.string-property");
- assertThat(stringResult.endsWith("converted")).isTrue();
- }
-
- // @Test
-// public void object_can_be_mapped(){
-// TypeRef<List<String>> typeRef = new TypeRef<List<String>>() {};
-// MapFunction mapFunction = new ToStringMapFunction();
-// DocumentContext documentContext = JsonPath.using(BaseTestConfiguration.JSON_ORG_CONFIGURATION
-// ).parse(BaseTestJson.JSON_DOCUMENT);
-// Object list = documentContext.read("$..book");
-// assertThat(list).isInstanceOf(List.class);
-// String result = documentContext.map("$..book", mapFunction).read("$..book", typeRef).get(0);
-// assertThat(result).isInstanceOf(String.class);
-// assertThat(result).endsWith("converted");
-// }
- @Test
- public void multi_match_path_can_be_mapped() {
- MapFunction mapFunction = new ToStringMapFunction();
- List<Double> doubleResult = parse(BaseTestJson.JSON_DOCUMENT).read("$..display-price");
- for (Double dRes : doubleResult) {
- assertThat(dRes).isInstanceOf(Double.class);
- }
- List<String> stringResult = parse(BaseTestJson.JSON_DOCUMENT).map("$..display-price", mapFunction).read("$..display-price");
- for (String sRes : stringResult) {
- assertThat(sRes).isInstanceOf(String.class);
- assertThat(sRes.endsWith("converted")).isTrue();
- }
- }
-
- // Helper converter implementation for test cases.
- private class ToStringMapFunction implements MapFunction {
- @Override
- public Object map(Object currentValue, Configuration configuration) {
- return currentValue.toString() + "converted";
- }
- }
-}
\ No newline at end of file
diff --git a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/internal/JsonContextTest.java b/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/internal/JsonContextTest.java
deleted file mode 100644
index 2c38ff3..0000000
--- a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/internal/JsonContextTest.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package org.eclipse.sensinact.gateway.nthbnd.test.jsonpath.internal;
-
-import com.jayway.jsonpath.DocumentContext;
-import com.jayway.jsonpath.Filter;
-import com.jayway.jsonpath.JsonPath;
-import org.assertj.core.api.Assertions;
-import org.eclipse.sensinact.gateway.nthbnd.jsonpath.builder.JsonOrgNodeBuilder;
-import org.eclipse.sensinact.gateway.nthbnd.test.jsonpath.BaseTestConfiguration;
-import org.eclipse.sensinact.gateway.nthbnd.test.jsonpath.BaseTestJson;
-import org.junit.Test;
-
-import java.util.List;
-
-public class JsonContextTest extends BaseTestConfiguration {
- JsonOrgNodeBuilder builder = new JsonOrgNodeBuilder();
-
- @Test
- public void cached_path_with_predicates() {
- Filter feq = Filter.filter(builder.where("category").eq("reference"));
- Filter fne = Filter.filter(builder.where("category").ne("reference"));
-
- DocumentContext JsonDoc = JsonPath.parse(BaseTestJson.JSON_DOCUMENT);
- List<String> eq = JsonDoc.read("$.store.book[?].category", feq);
- List<String> ne = JsonDoc.read("$.store.book[?].category", fne);
- Assertions.assertThat(eq).contains("reference");
- Assertions.assertThat(ne).doesNotContain("reference");
- }
-}
diff --git a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/internal/filter/RegexpEvaluatorTest.java b/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/internal/filter/RegexpEvaluatorTest.java
deleted file mode 100644
index b4d7ed4..0000000
--- a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/internal/filter/RegexpEvaluatorTest.java
+++ /dev/null
@@ -1,67 +0,0 @@
-package org.eclipse.sensinact.gateway.nthbnd.test.jsonpath.internal.filter;
-
-import com.jayway.jsonpath.Predicate;
-import com.jayway.jsonpath.internal.Path;
-import com.jayway.jsonpath.internal.filter.Evaluator;
-import com.jayway.jsonpath.internal.filter.EvaluatorFactory;
-import com.jayway.jsonpath.internal.filter.RelationalOperator;
-import com.jayway.jsonpath.internal.filter.ValueNode;
-import com.jayway.jsonpath.internal.path.CompiledPath;
-import com.jayway.jsonpath.internal.path.PathTokenFactory;
-import com.jayway.jsonpath.spi.builder.NodeBuilder;
-import org.assertj.core.util.Maps;
-import org.eclipse.sensinact.gateway.nthbnd.jsonpath.builder.JsonOrgNodeBuilder;
-import org.eclipse.sensinact.gateway.nthbnd.test.jsonpath.BaseTestConfiguration;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-
-import java.util.Arrays;
-
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-@RunWith(Parameterized.class)
-public class RegexpEvaluatorTest {
- private static NodeBuilder builder = new JsonOrgNodeBuilder();
-
- @Parameterized.Parameters()
- public static Iterable data() {
- return Arrays.asList(new Object[][]{{"/true|false/", builder.createStringNode("true", true), true}, {"/9.*9/", builder.createNumberNode("9979"), true}, {"/fa.*se/", builder.createBooleanNode("false"), true}, {"/Eval.*or/", builder.createClassNode(String.class), false}, {"/JsonNode/", builder.createJsonNode(json()), false}, {"/PathNode/", builder.createPathNode(path()), false}, {"/Undefined/", builder.createUndefinedNode(), false}, {"/NullNode/", builder.createNullNode(), false}});
- }
-
- private String regexp;
- private ValueNode valueNode;
- private boolean expectedResult;
-
- public RegexpEvaluatorTest(String regexp, ValueNode valueNode, boolean expectedResult) {
- this.regexp = regexp;
- this.valueNode = valueNode;
- this.expectedResult = expectedResult;
- }
-
- @Test
- public void should_evaluate_regular_expression() {
- //given
- Evaluator evaluator = EvaluatorFactory.createEvaluator(RelationalOperator.REGEX);
- ValueNode patternNode = builder.createPatternNode(regexp);
- Predicate.PredicateContext ctx = createPredicateContext();
- //when
- boolean result = evaluator.evaluate(patternNode, valueNode, ctx);
- //then
- assertThat(result, is(equalTo(expectedResult)));
- }
-
- private static Path path() {
- return new CompiledPath(PathTokenFactory.createRootPathToken('$'), true);
- }
-
- private static String json() {
- return "{ 'some': 'JsonNode' }";
- }
-
- private Predicate.PredicateContext createPredicateContext() {
- return BaseTestConfiguration.createPredicateContext(Maps.newHashMap());
- }
-}
diff --git a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/internal/function/BaseFunctionTest.java b/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/internal/function/BaseFunctionTest.java
deleted file mode 100644
index 2b2fae2..0000000
--- a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/internal/function/BaseFunctionTest.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package org.eclipse.sensinact.gateway.nthbnd.test.jsonpath.internal.function;
-
-import com.jayway.jsonpath.Configuration;
-
-import java.io.IOException;
-import java.util.Scanner;
-import static org.assertj.core.api.Assertions.assertThat;
-import static com.jayway.jsonpath.JsonPath.using;
-
-/**
- * Created by mattg on 6/27/15.
- */
-public class BaseFunctionTest {
- protected static final String NUMBER_SERIES = "{\"empty\": [], \"numbers\" : [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]}";
- protected static final String TEXT_SERIES = "{\"urls\": [\"http://api.worldbank.org/countries/all/?format=json\", \"http://api.worldbank.org/countries/all/?format=json\"], \"text\" : [ \"a\", \"b\", \"c\", \"d\", \"e\", \"f\" ]}";
-
- /**
- * Verify the function returns the correct result based on the input expectedValue
- *
- * @param pathExpr The path expression to execute
- * @param json The json document (actual content) to parse
- * @param expectedValue The expected value to be returned from the test
- */
- protected void verifyFunction(Configuration conf, String pathExpr, String json, Object expectedValue) {
- Object result = using(conf).parse(json, false).read(pathExpr);
- assertThat(conf.jsonProvider().unwrap(result)).isEqualTo(expectedValue);
- }
-
- protected void verifyMathFunction(Configuration conf, String pathExpr, Object expectedValue) {
- verifyFunction(conf, pathExpr, NUMBER_SERIES, expectedValue);
- }
-
- protected void verifyTextFunction(Configuration conf, String pathExpr, Object expectedValue) {
- verifyFunction(conf, pathExpr, TEXT_SERIES, expectedValue);
- }
-
- protected String getResourceAsText(String resourceName) throws IOException {
- return new Scanner(BaseFunctionTest.class.getResourceAsStream(resourceName), "UTF-8").useDelimiter("\\A").next();
- }
-}
diff --git a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/internal/function/Issue191.java b/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/internal/function/Issue191.java
deleted file mode 100644
index c3575e2..0000000
--- a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/internal/function/Issue191.java
+++ /dev/null
@@ -1,61 +0,0 @@
-package org.eclipse.sensinact.gateway.nthbnd.test.jsonpath.internal.function;
-
-import com.jayway.jsonpath.Configuration;
-import com.jayway.jsonpath.JsonPath;
-import org.eclipse.sensinact.gateway.nthbnd.test.jsonpath.BaseTestConfiguration;
-import org.junit.Test;
-
-import java.io.InputStream;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- * TDD for Issue 191
- * <p>
- * Shows aggregation across fields rather than within a single entity.
- */
-public class Issue191 {
- private Configuration conf = BaseTestConfiguration.JSON_ORG_CONFIGURATION;
-
- @Test
- public void testResultSetNumericComputation() {
- InputStream stream = ClassLoader.getSystemResourceAsStream("issue_191.json");
- Long value = JsonPath.parse(stream).read("$.sum($..timestamp)", Long.class);
- assertEquals("Expected the max function to consume the aggregation parameters and calculate the max over the result set", Long.valueOf(35679716813L), value);
- }
-
- @Test
- public void testResultSetNumericComputationTail() {
- InputStream stream = ClassLoader.getSystemResourceAsStream("issue_191.json");
- Long value = JsonPath.parse(stream).read("$..timestamp.sum()", Long.class);
- assertEquals("Expected the max function to consume the aggregation parameters and calculate the max over the result set", Long.valueOf(35679716813L), value);
- }
-
- @Test
- public void testResultSetNumericComputationRecursiveReplacement() {
- InputStream stream = ClassLoader.getSystemResourceAsStream("issue_191.json");
- Long value = JsonPath.parse(stream).read("$.max($..timestamp.avg(), $..timestamp.stddev())", Long.class);
- assertEquals("Expected the max function to consume the aggregation parameters and calculate the max over the result set", Long.valueOf(1427188672L), value);
- }
-
- @Test
- public void testMultipleResultSetSums() {
- InputStream stream = ClassLoader.getSystemResourceAsStream("issue_191.json");
- Long value = JsonPath.parse(stream).read("$.sum($..timestamp, $..cpus)", Long.class);
- assertEquals("Expected the max function to consume the aggregation parameters and calculate the max over the result set", Long.valueOf(35679716835L), value);
- }
-
- @Test
- public void testConcatResultSet() {
- InputStream stream = ClassLoader.getSystemResourceAsStream("issue_191.json");
- String concatResult = JsonPath.parse(stream).read("$.concat($..state)", String.class);
- assertEquals("Expected a string length to be a concat of all of the states", concatResult.length(), 806);
- }
-
- @Test
- public void testConcatWithNumericValueAsString() {
- InputStream stream = ClassLoader.getSystemResourceAsStream("issue_191.json");
- String concatResult = JsonPath.parse(stream).read("$.concat($..cpus)", String.class);
- assertEquals("Expected a string length to be a concat of all of the cpus", concatResult.length(), 489);
- }
-}
diff --git a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/internal/function/JSONEntityPathFunctionTest.java b/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/internal/function/JSONEntityPathFunctionTest.java
deleted file mode 100644
index f9b24d6..0000000
--- a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/internal/function/JSONEntityPathFunctionTest.java
+++ /dev/null
@@ -1,70 +0,0 @@
-package org.eclipse.sensinact.gateway.nthbnd.test.jsonpath.internal.function;
-
-import com.jayway.jsonpath.Configuration;
-import org.eclipse.sensinact.gateway.nthbnd.test.jsonpath.BaseTestConfiguration;
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.junit.Test;
-
-/**
- * Verifies methods that are helper implementations of functions for manipulating JSON entities, i.e.
- * length, etc.
- * <p>
- * Created by mattg on 6/27/15.
- */
-public class JSONEntityPathFunctionTest extends BaseFunctionTest {
- private static final String BATCH_JSON = "{\n" + " \"batches\": {\n" + " \"minBatchSize\": 10,\n" + " \"results\": [\n" + " {\n" + " \"productId\": 23,\n" + " \"values\": [\n" + " 2,\n" + " 45,\n" + " 34,\n" + " 23,\n" + " 3,\n" + " 5,\n" + " 4,\n" + " 3,\n" + " 2,\n" + " 1,\n" + " ]\n" + " },\n" + " {\n" + " \"productId\": 23,\n" + " \"values\": [\n" + " 52,\n" + " 3,\n" + " 12,\n" + " 11,\n" + " 18,\n" + " 22,\n" + " 1\n" + " ]\n" + " }\n" + " ]\n" + " }\n" + "}";
- private Configuration conf = BaseTestConfiguration.JSON_ORG_CONFIGURATION;
-
- @Test
- public void testLengthOfTextArray() {
- // The length of JSONArray is an integer
- verifyFunction(conf, "$['text'].length()", TEXT_SERIES, 6);
- verifyFunction(conf, "$['text'].size()", TEXT_SERIES, 6);
- }
-
- @Test
- public void testLengthOfNumberArray() {
- // The length of JSONArray is an integer
- verifyFunction(conf, "$.numbers.length()", NUMBER_SERIES, 10);
- verifyFunction(conf, "$.numbers.size()", NUMBER_SERIES, 10);
- }
-
- @Test
- public void testLengthOfStructure() {
- verifyFunction(conf, "$.batches.length()", BATCH_JSON, 2);
- }
-
- /**
- * The fictitious use-case/story - is we have a collection of batches with values indicating some quality metric.
- * We want to determine the average of the values for only the batch's values where the number of items in the batch
- * is greater than the min batch size which is encoded in the JSON document.
- * <p>
- * We use the length function in the predicate to determine the number of values in each batch and then for those
- * batches where the count is greater than min we calculate the average batch value.
- * <p>
- * Its completely contrived example, however, this test exercises functions within predicates.
- *
- * @throws JSONException
- */
- @Test
- public void testPredicateWithFunctionCallSingleMatch() throws JSONException {
- String path = "$.batches.results[?(@.values.length() >= $.batches.minBatchSize)].values.avg()";
- // Its an array because in some use-cases the min size might match more than one batch and thus we'll get
- // the average out for each collection
- JSONArray values = new JSONArray();
- values.put(12.2d);
- verifyFunction(conf, path, BATCH_JSON, values);
- }
-
- @Test
- public void testPredicateWithFunctionCallTwoMatches() throws JSONException {
- String path = "$.batches.results[?(@.values.length() >= 3)].values.avg()";
- // Its an array because in some use-cases the min size might match more than one batch and thus we'll get
- // the average out for each collection
- JSONArray values = new JSONArray();
- values.put(12.2d);
- values.put(17d);
- verifyFunction(conf, path, BATCH_JSON, values);
- }
-}
diff --git a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/internal/function/NestedFunctionTest.java b/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/internal/function/NestedFunctionTest.java
deleted file mode 100644
index 3d8e321..0000000
--- a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/internal/function/NestedFunctionTest.java
+++ /dev/null
@@ -1,112 +0,0 @@
-package org.eclipse.sensinact.gateway.nthbnd.test.jsonpath.internal.function;
-
-import com.jayway.jsonpath.Configuration;
-import org.eclipse.sensinact.gateway.nthbnd.test.jsonpath.BaseTestConfiguration;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import static com.jayway.jsonpath.JsonPath.using;
-import static org.junit.Assert.assertTrue;
-
-/**
- * Created by matt@mjgreenwood.net on 12/10/15.
- */
-@RunWith(Parameterized.class)
-public class NestedFunctionTest extends BaseFunctionTest {
- @Parameterized.Parameters
- public static Iterable<Configuration> configurations() {
- return BaseTestConfiguration.configurations();
- }
-
- private static final Logger logger = LoggerFactory.getLogger(NumericPathFunctionTest.class);
- private Configuration conf = BaseTestConfiguration.JSON_ORG_CONFIGURATION;
-
- public NestedFunctionTest(Configuration conf) {
- logger.debug("Testing with configuration {}", conf.getClass().getName());
- this.conf = conf;
- }
-
- @Test
- public void testParameterAverageFunctionCall() {
- verifyMathFunction(conf, "$.avg($.numbers.min(), $.numbers.max())", 5.5);
- }
-
- @Test
- public void testArrayAverageFunctionCall() {
- verifyMathFunction(conf, "$.numbers.avg()", 5.5);
- }
-
- /**
- * This test calculates the following:
- * <p>
- * For each number in $.numbers 1 -> 10 add each number up,
- * then add 1 (min), 10 (max)
- * <p>
- * Alternatively 1+2+3+4+5+6+7+8+9+10+1+10 == 66
- */
- @Test
- public void testArrayAverageFunctionCallWithParameters() {
- verifyMathFunction(conf, "$.numbers.sum($.numbers.min(), $.numbers.max())", 66.0);
- }
-
- @Test
- public void testJsonInnerArgumentArray() {
- verifyMathFunction(conf, "$.sum(5, 3, $.numbers.max(), 2)", 20.0);
- }
-
- @Test
- public void testStringConcat() {
- verifyTextFunction(conf, "$.text.concat()", "abcdef");
- }
-
- @Test
- public void testStringConcatWithJSONParameter() {
- verifyTextFunction(conf, "$.text.concat(\"-\", \"ghijk\")", "abcdef-ghijk");
- }
-
- @Test
- public void testAppendNumber() {
- verifyMathFunction(conf, "$.numbers.append(11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 0).avg()", 10.0);
- }
-
- /**
- * Aggregation function should ignore text values
- */
- @Test
- public void testAppendTextAndNumberThenSum() {
- verifyMathFunction(conf, "$.numbers.append(\"0\", \"11\").sum()", 55.0);
- }
-
- @Test
- public void testErrantCloseBraceNegative() {
- try {
- using(conf).parse(BaseFunctionTest.NUMBER_SERIES, false).read("$.numbers.append(0, 1, 2}).avg()");
- assert (false);
- } catch (Exception e) {
- assertTrue(e.getMessage().startsWith("Unexpected close brace"));
- }
- }
-
- @Test
- public void testErrantCloseBracketNegative() {
- try {
- using(conf).parse(BaseFunctionTest.NUMBER_SERIES, false).read("$.numbers.append(0, 1, 2]).avg()");
- assert (false);
- } catch (Exception e) {
- assertTrue(e.getMessage().startsWith("Unexpected close bracket"));
- }
- }
-
- @Test
- public void testUnclosedFunctionCallNegative() {
- try {
- using(conf).parse(BaseFunctionTest.NUMBER_SERIES, false).read("$.numbers.append(0, 1, 2");
- assert (false);
- } catch (Exception e) {
- assertTrue(e.getMessage().startsWith("Arguments to function: 'append'"));
- }
- }
-}
diff --git a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/internal/function/NumericPathFunctionTest.java b/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/internal/function/NumericPathFunctionTest.java
deleted file mode 100644
index f7ee205..0000000
--- a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/internal/function/NumericPathFunctionTest.java
+++ /dev/null
@@ -1,120 +0,0 @@
-package org.eclipse.sensinact.gateway.nthbnd.test.jsonpath.internal.function;
-
-import com.jayway.jsonpath.Configuration;
-import com.jayway.jsonpath.JsonPathException;
-import org.eclipse.sensinact.gateway.nthbnd.test.jsonpath.BaseTestConfiguration;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-
-/**
- * Defines functional tests around executing:
- * <p>
- * - sum
- * - avg
- * - stddev
- * <p>
- * for each of the above, executes the test and verifies that the results are as expected based on a static input
- * and static output.
- * <p>
- * Created by mattg on 6/26/15.
- */
-@RunWith(Parameterized.class)
-public class NumericPathFunctionTest extends BaseFunctionTest {
- @Parameterized.Parameters
- public static Iterable<Configuration> configurations() {
- return BaseTestConfiguration.configurations();
- }
-
- private static final Logger logger = LoggerFactory.getLogger(NumericPathFunctionTest.class);
- private Configuration conf = BaseTestConfiguration.JSON_ORG_CONFIGURATION;
-
- public NumericPathFunctionTest(Configuration conf) {
- logger.debug("Testing with configuration {}", conf.getClass().getName());
- this.conf = conf;
- }
-
- @Test
- public void testAverageOfDoubles() {
- verifyMathFunction(conf, "$.numbers.avg()", 5.5);
- }
-
- @Test
- public void testAverageOfEmptyListNegative() {
- try {
- verifyMathFunction(conf, "$.empty.avg()", null);
- } catch (JsonPathException e) {
- assertEquals(e.getMessage(), "Aggregation function attempted to calculate value using empty array");
- }
- }
-
- @Test
- public void testSumOfDouble() {
- verifyMathFunction(conf, "$.numbers.sum()", (10d * (10d + 1d)) / 2d);
- }
-
- @Test
- public void testSumOfEmptyListNegative() {
- try {
- verifyMathFunction(conf, "$.empty.sum()", null);
- } catch (JsonPathException e) {
- assertEquals(e.getMessage(), "Aggregation function attempted to calculate value using empty array");
- }
- }
-
- @Test
- public void testMaxOfDouble() {
- verifyMathFunction(conf, "$.numbers.max()", 10d);
- }
-
- @Test
- public void testMaxOfEmptyListNegative() {
- try {
- verifyMathFunction(conf, "$.empty.max()", null);
- } catch (JsonPathException e) {
- assertEquals(e.getMessage(), "Aggregation function attempted to calculate value using empty array");
- }
- }
-
- @Test
- public void testMinOfDouble() {
- verifyMathFunction(conf, "$.numbers.min()", 1d);
- }
-
- @Test
- public void testMinOfEmptyListNegative() {
- try {
- verifyMathFunction(conf, "$.empty.min()", null);
- } catch (JsonPathException e) {
- assertEquals(e.getMessage(), "Aggregation function attempted to calculate value using empty array");
- }
- }
-
- @Test
- public void testStdDevOfDouble() {
- verifyMathFunction(conf, "$.numbers.stddev()", 2.8722813232690143d);
- }
-
- @Test
- public void testStddevOfEmptyListNegative() {
- try {
- verifyMathFunction(conf, "$.empty.stddev()", null);
- } catch (JsonPathException e) {
- assertEquals(e.getMessage(), "Aggregation function attempted to calculate value using empty array");
- }
- }
- /**
- * Expect that for an invalid function name we'll get back the original input to the function
- */
-// @Test
-// @Ignore
-// public void testInvalidFunctionNameNegative() {
-// JSONArray numberSeries = new JSONArray();
-// numberSeries.addAll(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10));
-// assertThat(using(conf).parse(NUMBER_SERIES).read("$.numbers.foo()")).isEqualTo(numberSeries);
-// }
-}
diff --git a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/old/FilterTest.java b/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/old/FilterTest.java
deleted file mode 100644
index 374d743..0000000
--- a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/old/FilterTest.java
+++ /dev/null
@@ -1,310 +0,0 @@
-package org.eclipse.sensinact.gateway.nthbnd.test.jsonpath.old;
-
-import com.jayway.jsonpath.Configuration;
-import com.jayway.jsonpath.Filter;
-import com.jayway.jsonpath.JsonPath;
-import com.jayway.jsonpath.Predicate;
-import com.jayway.jsonpath.Predicate.PredicateContext;
-import com.jayway.jsonpath.spi.json.JsonProvider;
-import org.assertj.core.api.Assertions;
-import org.eclipse.sensinact.gateway.nthbnd.test.jsonpath.BaseTestConfiguration;
-import org.junit.Test;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.regex.Pattern;
-
-import static com.jayway.jsonpath.Filter.filter;
-import static java.util.Arrays.asList;
-import static junit.framework.Assert.*;
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-
-public class FilterTest extends BaseTestConfiguration {
- public final static String DOCUMENT = "{ \"store\": {\n" + " \"book\": [ \n" + " { \"category\": \"reference\",\n" + " \"author\": \"Nigel Rees\",\n" + " \"title\": \"Sayings of the Century\",\n" + " \"price\": 8.95\n" + " },\n" + " { \"category\": \"fiction\",\n" + " \"author\": \"Evelyn Waugh\",\n" + " \"title\": \"Sword of Honour\",\n" + " \"price\": 12.99\n" + " },\n" + " { \"category\": \"fiction\",\n" + " \"author\": \"Herman Melville\",\n" + " \"title\": \"Moby Dick\",\n" + " \"isbn\": \"0-553-21311-3\",\n" + " \"price\": 8.99\n" + " },\n" + " { \"category\": \"fiction\",\n" + " \"author\": \"J. R. R. Tolkien\",\n" + " \"title\": \"The Lord of the Rings\",\n" + " \"isbn\": \"0-395-19395-8\",\n" + " \"price\": 22.99\n" + " }\n" + " ],\n" + " \"bicycle\": {\n" + " \"color\": \"red\",\n" + " \"price\": 19.95,\n" + " \"foo:bar\": \"fooBar\",\n" + " \"dot.notation\": \"new\"\n" + " }\n" + " }\n" + "}";
- private static final Configuration conf = Configuration.defaultConfiguration();
- private static final JsonProvider jp = conf.jsonProvider();
-
- @SuppressWarnings("deprecation")
- public void is_filters_evaluates() throws Exception {
- final Map<String, Object> check = new HashMap<String, Object>();
- check.put("foo", "foo");
- check.put("bar", null);
- assertTrue(filter(conf.nodeBuilder().where("bar").is(null)).apply(createPredicateContext(check)));
- assertTrue(filter(conf.nodeBuilder().where("foo").is("foo")).apply(createPredicateContext(check)));
- assertFalse(filter(conf.nodeBuilder().where("foo").is("xxx")).apply(createPredicateContext(check)));
- assertFalse(filter(conf.nodeBuilder().where("bar").is("xxx")).apply(createPredicateContext(check)));
- }
-
- @SuppressWarnings("deprecation")
- @Test
- public void ne_filters_evaluates() throws Exception {
- final Map<String, Object> check = new HashMap<String, Object>();
- check.put("foo", "foo");
- check.put("bar", null);
- assertTrue(filter(conf.nodeBuilder().where("foo").ne(null)).apply(createPredicateContext(check)));
- assertTrue(filter(conf.nodeBuilder().where("foo").ne("not foo")).apply(createPredicateContext(check)));
- assertFalse(filter(conf.nodeBuilder().where("foo").ne("foo")).apply(createPredicateContext(check)));
- assertFalse(filter(conf.nodeBuilder().where("bar").ne(null)).apply(createPredicateContext(check)));
- }
-
- @Test
- @SuppressWarnings("deprecation")
- public void gt_filters_evaluates() throws Exception {
- final Map<String, Object> check = new HashMap<String, Object>();
- check.put("foo", 12.5D);
- check.put("foo_null", null);
- assertTrue(filter(conf.nodeBuilder().where("foo").gt(12D)).apply(createPredicateContext(check)));
- assertFalse(filter(conf.nodeBuilder().where("foo").gt(null)).apply(createPredicateContext(check)));
- assertFalse(filter(conf.nodeBuilder().where("foo").gt(20D)).apply(createPredicateContext(check)));
- assertFalse(filter(conf.nodeBuilder().where("foo_null").gt(20D)).apply(createPredicateContext(check)));
- }
-
- @Test
- @SuppressWarnings("deprecation")
- public void gte_filters_evaluates() throws Exception {
- Map<String, Object> check = new HashMap<String, Object>();
- check.put("foo", 12.5D);
- check.put("foo_null", null);
- assertTrue(filter(conf.nodeBuilder().where("foo").gte(12D)).apply(createPredicateContext(check)));
- assertTrue(filter(conf.nodeBuilder().where("foo").gte(12.5D)).apply(createPredicateContext(check)));
- assertFalse(filter(conf.nodeBuilder().where("foo").gte(null)).apply(createPredicateContext(check)));
- assertFalse(filter(conf.nodeBuilder().where("foo").gte(20D)).apply(createPredicateContext(check)));
- assertFalse(filter(conf.nodeBuilder().where("foo_null").gte(20D)).apply(createPredicateContext(check)));
- }
-
- @SuppressWarnings("deprecation")
- @Test
- public void lt_filters_evaluates() throws Exception {
- Map<String, Object> check = new HashMap<String, Object>();
- check.put("foo", 10.5D);
- check.put("foo_null", null);
- //assertTrue(filter(where("foo").lt(12D)).apply(createPredicateContext(check)));
- assertFalse(filter(conf.nodeBuilder().where("foo").lt(null)).apply(createPredicateContext(check)));
- //assertFalse(filter(where("foo").lt(5D)).apply(createPredicateContext(check)));
- //assertFalse(filter(where("foo_null").lt(5D)).apply(createPredicateContext(check)));
- }
-
- @SuppressWarnings("deprecation")
- @Test
- public void lte_filters_evaluates() throws Exception {
- Map<String, Object> check = new HashMap<String, Object>();
- check.put("foo", 12.5D);
- check.put("foo_null", null);
- assertTrue(filter(conf.nodeBuilder().where("foo").lte(13D)).apply(createPredicateContext(check)));
- assertFalse(filter(conf.nodeBuilder().where("foo").lte(null)).apply(createPredicateContext(check)));
- assertFalse(filter(conf.nodeBuilder().where("foo").lte(5D)).apply(createPredicateContext(check)));
- assertFalse(filter(conf.nodeBuilder().where("foo_null").lte(5D)).apply(createPredicateContext(check)));
- }
-
- @SuppressWarnings("deprecation")
- @Test
- public void in_filters_evaluates() throws Exception {
- Map<String, Object> check = new HashMap<String, Object>();
- check.put("item", 3);
- check.put("null_item", null);
- assertTrue(filter(conf.nodeBuilder().where("item").in(1, 2, 3)).apply(createPredicateContext(check)));
- assertTrue(filter(conf.nodeBuilder().where("item").in(asList(1, 2, 3))).apply(createPredicateContext(check)));
- assertFalse(filter(conf.nodeBuilder().where("item").in(4, 5, 6)).apply(createPredicateContext(check)));
- assertFalse(filter(conf.nodeBuilder().where("item").in(asList(4, 5, 6))).apply(createPredicateContext(check)));
- assertFalse(filter(conf.nodeBuilder().where("item").in(asList('A'))).apply(createPredicateContext(check)));
- assertFalse(filter(conf.nodeBuilder().where("item").in(asList((Object) null))).apply(createPredicateContext(check)));
- assertFalse(filter(conf.nodeBuilder().where("null_item").in(1, 2, 3)).apply(createPredicateContext(check)));
- assertTrue(filter(conf.nodeBuilder().where("null_item").in((Object) null)).apply(createPredicateContext(check)));
- }
-
- @SuppressWarnings("deprecation")
- @Test
- public void nin_filters_evaluates() throws Exception {
- Map<String, Object> check = new HashMap<String, Object>();
- check.put("item", 3);
- check.put("null_item", null);
- assertTrue(filter(conf.nodeBuilder().where("item").nin(4, 5)).apply(createPredicateContext(check)));
- assertTrue(filter(conf.nodeBuilder().where("item").nin(asList(4, 5))).apply(createPredicateContext(check)));
- assertTrue(filter(conf.nodeBuilder().where("item").nin(asList('A'))).apply(createPredicateContext(check)));
- assertTrue(filter(conf.nodeBuilder().where("null_item").nin(1, 2, 3)).apply(createPredicateContext(check)));
- assertTrue(filter(conf.nodeBuilder().where("item").nin(asList((Object) null))).apply(createPredicateContext(check)));
- assertFalse(filter(conf.nodeBuilder().where("item").nin(3)).apply(createPredicateContext(check)));
- assertFalse(filter(conf.nodeBuilder().where("item").nin(asList(3))).apply(createPredicateContext(check)));
- }
-
- @Test
- @SuppressWarnings("deprecation")
- public void all_filters_evaluates() throws Exception {
- Map<String, Object> check = new HashMap<String, Object>();
- check.put("items", asList(1, 2, 3));
- assertTrue(filter(conf.nodeBuilder().where("items").all(1, 2, 3)).apply(createPredicateContext(check)));
- assertFalse(filter(conf.nodeBuilder().where("items").all(1, 2, 3, 4)).apply(createPredicateContext(check)));
- }
-
- @Test
- @SuppressWarnings("deprecation")
- public void size_filters_evaluates() throws Exception {
- Map<String, Object> check = new HashMap<String, Object>();
- check.put("items", asList(1, 2, 3));
- check.put("items_empty", Collections.emptyList());
- assertTrue(filter(conf.nodeBuilder().where("items").size(3)).apply(createPredicateContext(check)));
- assertTrue(filter(conf.nodeBuilder().where("items_empty").size(0)).apply(createPredicateContext(check)));
- assertFalse(filter(conf.nodeBuilder().where("items").size(2)).apply(createPredicateContext(check)));
- }
-
- @Test
- @SuppressWarnings("deprecation")
- public void exists_filters_evaluates() throws Exception {
- Map<String, Object> check = new HashMap<String, Object>();
- check.put("foo", "foo");
- check.put("foo_null", null);
- assertTrue(filter(conf.nodeBuilder().where("foo").exists(true)).apply(createPredicateContext(check)));
- assertFalse(filter(conf.nodeBuilder().where("foo").exists(false)).apply(createPredicateContext(check)));
- assertTrue(filter(conf.nodeBuilder().where("foo_null").exists(true)).apply(createPredicateContext(check)));
- assertFalse(filter(conf.nodeBuilder().where("foo_null").exists(false)).apply(createPredicateContext(check)));
- assertTrue(filter(conf.nodeBuilder().where("bar").exists(false)).apply(createPredicateContext(check)));
- assertFalse(filter(conf.nodeBuilder().where("bar").exists(true)).apply(createPredicateContext(check)));
- }
-
- @Test
- @SuppressWarnings("deprecation")
- public void type_filters_evaluates() throws Exception {
- Map<String, Object> check = new HashMap<String, Object>();
- check.put("string", "foo");
- check.put("string_null", null);
- check.put("int", 1);
- check.put("long", 1L);
- check.put("double", 1.12D);
- check.put("boolean", true);
- assertFalse(filter(conf.nodeBuilder().where("string_null").type(String.class)).apply(createPredicateContext(check)));
- assertTrue(filter(conf.nodeBuilder().where("string").type(String.class)).apply(createPredicateContext(check)));
- assertFalse(filter(conf.nodeBuilder().where("string").type(Number.class)).apply(createPredicateContext(check)));
- assertTrue(filter(conf.nodeBuilder().where("int").type(Number.class)).apply(createPredicateContext(check)));
- assertFalse(filter(conf.nodeBuilder().where("int").type(String.class)).apply(createPredicateContext(check)));
- assertTrue(filter(conf.nodeBuilder().where("long").type(Number.class)).apply(createPredicateContext(check)));
- assertFalse(filter(conf.nodeBuilder().where("long").type(String.class)).apply(createPredicateContext(check)));
- assertTrue(filter(conf.nodeBuilder().where("double").type(Number.class)).apply(createPredicateContext(check)));
- assertFalse(filter(conf.nodeBuilder().where("double").type(String.class)).apply(createPredicateContext(check)));
- assertTrue(filter(conf.nodeBuilder().where("boolean").type(Boolean.class)).apply(createPredicateContext(check)));
- assertFalse(filter(conf.nodeBuilder().where("boolean").type(String.class)).apply(createPredicateContext(check)));
- }
-
- @Test
- public void pattern_filters_evaluates() throws Exception {
- Map<String, Object> check = new HashMap<String, Object>();
- check.put("name", "kalle");
- check.put("name_null", null);
- assertFalse(filter(conf.nodeBuilder().where("name_null").regex(Pattern.compile(".alle"))).apply(createPredicateContext(check)));
- assertTrue(filter(conf.nodeBuilder().where("name").regex(Pattern.compile(".alle"))).apply(createPredicateContext(check)));
- assertFalse(filter(conf.nodeBuilder().where("name").regex(Pattern.compile("KALLE"))).apply(createPredicateContext(check)));
- assertTrue(filter(conf.nodeBuilder().where("name").regex(Pattern.compile("KALLE", Pattern.CASE_INSENSITIVE))).apply(createPredicateContext(check)));
- }
-
- @Test
- public void combine_filter_deep_criteria() {
- String json = "[\n" + " {\n" + " \"first-name\" : \"John\",\n" + " \"last-name\" : \"Irving\",\n" + " \"address\" : {\"state\" : \"Texas\"}\n" + " },\n" + " {\n" + " \"first-name\" : \"Jock\",\n" + " \"last-name\" : \"Ewing\",\n" + " \"address\" : {\"state\" : \"Texas\"}\n" + " },\n" + " {\n" + " \"first-name\" : \"Jock\",\n" + " \"last-name\" : \"Barnes\",\n" + " \"address\" : {\"state\" : \"Nevada\"}\n" + " } \n" + "]";
- Filter filter = filter(conf.nodeBuilder().where("first-name").is("Jock").and("address.state").is("Texas"));
- List<Map<String, Object>> jocksInTexas1 = JsonPath.read(json, "$[?]", filter);
- List<Map<String, Object>> jocksInTexas2 = JsonPath.read(json, "$[?(@.first-name == 'Jock' && @.address.state == 'Texas')]");
- JsonPath.parse(json).json();
- assertThat((String) JsonPath.read(jocksInTexas1, "$[0].address.state"), is("Texas"));
- assertThat((String) JsonPath.read(jocksInTexas1, "$[0].first-name"), is("Jock"));
- assertThat((String) JsonPath.read(jocksInTexas1, "$[0].last-name"), is("Ewing"));
- }
-
- //-------------------------------------------------
- //
- // Single filter tests
- //
- //-------------------------------------------------
- @Test
- public void filters_can_be_combined() throws Exception {
- Map<String, Object> check = new HashMap<String, Object>();
- check.put("string", "foo");
- check.put("string_null", null);
- check.put("int", 10);
- check.put("long", 1L);
- check.put("double", 1.12D);
- Filter shouldMarch = filter(conf.nodeBuilder().where("string").is("foo").and("int").lt(11));
- Filter shouldNotMarch = filter(conf.nodeBuilder().where("string").is("foo").and("int").gt(11));
- assertTrue(shouldMarch.apply(createPredicateContext(check)));
- assertFalse(shouldNotMarch.apply(createPredicateContext(check)));
- }
-
- @Test
- public void arrays_of_maps_can_be_filtered() throws Exception {
- Map<String, Object> rootGrandChild_A = new HashMap<String, Object>();
- rootGrandChild_A.put("name", "rootGrandChild_A");
- Map<String, Object> rootGrandChild_B = new HashMap<String, Object>();
- rootGrandChild_B.put("name", "rootGrandChild_B");
- Map<String, Object> rootGrandChild_C = new HashMap<String, Object>();
- rootGrandChild_C.put("name", "rootGrandChild_C");
- Map<String, Object> rootChild_A = new HashMap<String, Object>();
- rootChild_A.put("name", "rootChild_A");
- rootChild_A.put("children", asList(rootGrandChild_A, rootGrandChild_B, rootGrandChild_C));
- Map<String, Object> rootChild_B = new HashMap<String, Object>();
- rootChild_B.put("name", "rootChild_B");
- rootChild_B.put("children", asList(rootGrandChild_A, rootGrandChild_B, rootGrandChild_C));
- Map<String, Object> rootChild_C = new HashMap<String, Object>();
- rootChild_C.put("name", "rootChild_C");
- rootChild_C.put("children", asList(rootGrandChild_A, rootGrandChild_B, rootGrandChild_C));
- Map<String, Object> root = new HashMap<String, Object>();
- root.put("children", asList(rootChild_A, rootChild_B, rootChild_C));
- Predicate customFilter = new Predicate() {
- @Override
- public boolean apply(PredicateContext ctx) {
- if (ctx.configuration().jsonProvider().getMapValue(ctx.item(), "name").equals("rootGrandChild_A")) {
- return true;
- }
- return false;
- }
- };
- Filter rootChildFilter = filter(conf.nodeBuilder().where("name").regex(Pattern.compile("rootChild_[A|B]")));
- Filter rootGrandChildFilter = filter(conf.nodeBuilder().where("name").regex(Pattern.compile("rootGrandChild_[A|B]")));
- List read = JsonPath.read(root, "children[?].children[?, ?]", rootChildFilter, rootGrandChildFilter, customFilter);
- }
-
- @Test
- public void arrays_of_objects_can_be_filtered() throws Exception {
- Map<String, Object> doc = new HashMap<String, Object>();
- doc.put("items", asList(1, 2, 3));
- Predicate customFilter = new Predicate() {
- @Override
- public boolean apply(PredicateContext ctx) {
- return 1 == (Integer) ctx.item();
- }
- };
- List<Integer> res = JsonPath.read(doc, "$.items[?]", customFilter);
- assertEquals(1, res.get(0).intValue());
- }
-
- @Test
- public void filters_can_contain_json_path_expressions() throws Exception {
- Object doc = Configuration.defaultConfiguration().jsonProvider().parse(DOCUMENT);
- assertFalse(filter(conf.nodeBuilder().where("$.store.bicycle.color").ne("red")).apply(createPredicateContext(doc)));
- }
-
- @Test
- public void not_empty_filter_evaluates() {
- String json = "{\n" + " \"fields\": [\n" + " {\n" + " \"errors\": [], \n" + " \"name\": \"\", \n" + " \"empty\": true \n" + " }, \n" + " {\n" + " \"errors\": [], \n" + " \"name\": \"foo\"\n" + " }, \n" + " {\n" + " \"errors\": [\n" + " \"first\", \n" + " \"second\"\n" + " ], \n" + " \"name\": \"invalid\"\n" + " }\n" + " ]\n" + "}\n";
- Object doc = Configuration.defaultConfiguration().jsonProvider().parse(json);
- List<Map<String, Object>> result = JsonPath.read(doc, "$.fields[?]", filter(conf.nodeBuilder().where("errors").notEmpty()));
- assertEquals(1, result.size());
- List<Map<String, Object>> result2 = JsonPath.read(doc, "$.fields[?]", filter(conf.nodeBuilder().where("name").notEmpty()));
- assertEquals(2, result2.size());
- }
-
- @Test
- public void contains_filter_evaluates_on_array() {
- String json = "{\n" + "\"store\": {\n" + " \"book\": [\n" + " {\n" + " \"category\": \"reference\",\n" + " \"authors\" : [\n" + " {\n" + " \"firstName\" : \"Nigel\",\n" + " \"lastName\" : \"Rees\"\n" + " }\n" + " ],\n" + " \"title\": \"Sayings of the Century\",\n" + " \"price\": 8.95\n" + " },\n" + " {\n" + " \"category\": \"fiction\",\n" + " \"authors\": [\n" + " {\n" + " \"firstName\" : \"Evelyn\",\n" + " \"lastName\" : \"Waugh\"\n" + " },\n" + " {\n" + " \"firstName\" : \"Another\",\n" + " \"lastName\" : \"Author\"\n" + " }\n" + " ],\n" + " \"title\": \"Sword of Honour\",\n" + " \"price\": 12.99\n" + " }\n" + " ]\n" + " }\n" + "}";
- Filter filter = filter(conf.nodeBuilder().where("authors[*].lastName").contains("Waugh"));
- List<String> result = JsonPath.parse(json).read("$.store.book[?].title", filter);
- Assertions.assertThat(result).containsExactly("Sword of Honour");
- }
-
- @Test
- public void contains_filter_evaluates_on_string() {
- String json = "{\n" + "\"store\": {\n" + " \"book\": [\n" + " {\n" + " \"category\": \"reference\",\n" + " \"title\": \"Sayings of the Century\",\n" + " \"price\": 8.95\n" + " },\n" + " {\n" + " \"category\": \"fiction\",\n" + " \"title\": \"Sword of Honour\",\n" + " \"price\": 12.99\n" + " }\n" + " ]\n" + " }\n" + "}";
- Filter filter = filter(conf.nodeBuilder().where("category").contains("fic"));
- List<String> result = JsonPath.parse(json).read("$.store.book[?].title", filter);
- Assertions.assertThat(result).containsExactly("Sword of Honour");
- }
-}
diff --git a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/old/IssuesTest.java b/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/old/IssuesTest.java
deleted file mode 100644
index a6d6d45..0000000
--- a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/old/IssuesTest.java
+++ /dev/null
@@ -1,550 +0,0 @@
-package org.eclipse.sensinact.gateway.nthbnd.test.jsonpath.old;
-
-import com.jayway.jsonpath.Configuration;
-import com.jayway.jsonpath.DocumentContext;
-import com.jayway.jsonpath.Filter;
-import com.jayway.jsonpath.InvalidPathException;
-import com.jayway.jsonpath.JsonPath;
-import com.jayway.jsonpath.Option;
-import com.jayway.jsonpath.PathNotFoundException;
-import com.jayway.jsonpath.internal.Utils;
-import com.jayway.jsonpath.spi.builder.NodeBuilder;
-import com.jayway.jsonpath.spi.cache.LRUCache;
-import com.jayway.jsonpath.spi.json.JsonProvider;
-import com.jayway.jsonpath.spi.mapper.MappingException;
-import org.assertj.core.api.Assertions;
-import org.eclipse.sensinact.gateway.nthbnd.jsonpath.json.JsonOrgJsonProvider;
-import org.eclipse.sensinact.gateway.nthbnd.jsonpath.mapper.JsonOrgMappingProvider;
-import org.eclipse.sensinact.gateway.nthbnd.test.jsonpath.BaseTestConfiguration;
-import org.eclipse.sensinact.gateway.nthbnd.test.jsonpath.BaseTestJson;
-import org.hamcrest.Matchers;
-import org.json.JSONException;
-import org.json.JSONObject;
-import org.json.JSONTokener;
-import org.junit.Test;
-
-import java.io.InputStream;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import static com.jayway.jsonpath.Criteria.PredicateContext;
-import static com.jayway.jsonpath.Filter.filter;
-import static com.jayway.jsonpath.JsonPath.read;
-import static com.jayway.jsonpath.JsonPath.using;
-import static junit.framework.Assert.assertNull;
-import static junit.framework.Assert.assertTrue;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.failBecauseExceptionWasNotThrown;
-import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
-
-public class IssuesTest extends BaseTestConfiguration {
- private static final JsonProvider jp = Configuration.defaultConfiguration().jsonProvider();
- private static final NodeBuilder nb = Configuration.defaultConfiguration().nodeBuilder();
-
- @Test
- public void issue_143() {
- String json = "{ \"foo\": { \"bar\" : \"val\" }, \"moo\": { \"cow\" : \"val\" } }";
- Configuration configuration = Configuration.builder().options(Option.AS_PATH_LIST).build();
- List<String> pathList = JsonPath.using(configuration).parse(json, false).read(JsonPath.compile("$.*.bar"));
- assertThat(pathList).containsExactly("$['foo']['bar']");
- }
-
- @Test
- public void issue_114_a() {
- String json = "{ \"p\":{\n" + "\"s\": { \"u\": \"su\" }, \n" + "\"t\": { \"u\": \"tu\" }\n" + "}}";
- List<String> result = read(json, "$.p.['s', 't'].u");
- assertThat(result).containsExactly("su", "tu");
- }
-
- @Test
- public void issue_114_b() {
- String json = "{ \"p\": [\"valp\", \"valq\", \"valr\"] }";
- List<String> result = read(json, "$.p[?(@ == 'valp')]");
- assertThat(result).containsExactly("valp");
- }
-
- @Test
- public void issue_114_c() {
- String json = "{ \"p\": [\"valp\", \"valq\", \"valr\"] }";
- List<String> result = read(json, "$.p[?(@[0] == 'valp')]");
- assertThat(result).isEmpty();
- }
-
- @Test(expected = InvalidPathException.class)
- public void issue_114_d() {
- read(BaseTestJson.JSON_BOOK_DOCUMENT, "$..book[(@.length-1)] ");
- }
-
- @Test
- public void issue_151() {
- String json = "{\n" + "\"datas\": {\n" + " \"selling\": {\n" + " \"3\": [\n" + " 26452067,\n" + " 31625950\n" + " ],\n" + " \"206\": [\n" + " 32381852,\n" + " 32489262\n" + " ],\n" + " \"208\": [\n" + " 458\n" + " ],\n" + " \"217\": [\n" + " 27364892\n" + " ],\n" + " \"226\": [\n" + " 30474109\n" + " ]\n" + " }\n" + "},\n" + "\"status\": 0\n" + "}";
- List<Integer> result = read(json, "$.datas.selling['3','206'].*");
- assertThat(result).containsExactly(26452067, 31625950, 32381852, 32489262);
- }
-
- @Test
- public void full_ones_can_be_filtered() {
- String json = "[\n" + " {\"kind\" : \"full\"},\n" + " {\"kind\" : \"empty\"}\n" + "]";
- List<Map<String, String>> fullOnes = read(json, "$[?(@.kind == 'full')]");
- assertEquals(1, fullOnes.size());
- assertEquals("full", fullOnes.get(0).get("kind"));
- }
-
- @Test
- public void issue_36() {
- String json = "{\n" + "\n" + " \"arrayOfObjectsAndArrays\" : [ { \"k\" : [\"json\"] }, { \"k\":[\"path\"] }, { \"k\" : [\"is\"] }, { \"k\" : [\"cool\"] } ],\n" + "\n" + " \"arrayOfObjects\" : [{\"k\" : \"json\"}, {\"k\":\"path\"}, {\"k\" : \"is\"}, {\"k\" : \"cool\"}]\n" + "\n" + " }";
- Object o1 = read(json, "$.arrayOfObjectsAndArrays..k ");
- Object o2 = read(json, "$.arrayOfObjects..k ");
- assertEquals("[[\"json\"],[\"path\"],[\"is\"],[\"cool\"]]", jp.toJson(o1));
- assertEquals("[\"json\",\"path\",\"is\",\"cool\"]", jp.toJson(o2));
- }
-
- @Test
- public void issue_11() throws Exception {
- String json = "{ \"foo\" : [] }";
- List<String> result = read(json, "$.foo[?(@.rel == 'item')][0].uri");
- assertTrue(result.isEmpty());
- }
-
- @Test(expected = PathNotFoundException.class)
- public void issue_11b() throws Exception {
- String json = "{ \"foo\" : [] }";
- read(json, "$.foo[0].uri");
- }
-
- @Test
- public void issue_15() throws Exception {
- String json = "{ \"store\": {\n" + " \"book\": [ \n" + " { \"category\": \"reference\",\n" + " \"author\": \"Nigel Rees\",\n" + " \"title\": \"Sayings of the Century\",\n" + " \"price\": 8.95\n" + " },\n" + " { \"category\": \"fiction\",\n" + " \"author\": \"Herman Melville\",\n" + " \"title\": \"Moby Dick\",\n" + " \"isbn\": \"0-553-21311-3\",\n" + " \"price\": 8.99,\n" + " \"retailer\": null, \n" + " \"children\": true,\n" + " \"number\": -2.99\n" + " },\n" + " { \"category\": \"fiction\",\n" + " \"author\": \"J. R. R. Tolkien\",\n" + " \"title\": \"The Lord of the Rings\",\n" + " \"isbn\": \"0-395-19395-8\",\n" + " \"price\": 22.99,\n" + " \"number\":0,\n" + " \"children\": false\n" + " }\n" + " ]\n" + " }\n" + "}";
- List<String> titles = read(json, "$.store.book[?(@.children==true)].title");
- assertThat(titles, Matchers.contains("Moby Dick"));
- assertEquals(1, titles.size());
- }
-
- @Test
- public void issue_24() {
- InputStream is = null;
- try {
- is = this.getClass().getResourceAsStream("/issue_24.json");
- //Object o = JsonPath.read(is, "$.project[?(@.template.@key == 'foo')].field[*].@key");
- Object o = read(is, "$.project.field[*].@key");
- //Object o = JsonPath.read(is, "$.project.template[?(@.@key == 'foo')].field[*].@key");
- is.close();
- } catch (Exception e) {
- //e.printStackTrace();
- Utils.closeQuietly(is);
- }
- }
-
- @Test
- public void issue_28_string() {
- String json = "{\"contents\": [\"one\",\"two\",\"three\"]}";
- List<String> result = read(json, "$.contents[?(@ == 'two')]");
- assertThat(result, Matchers.contains("two"));
- assertEquals(1, result.size());
- }
-
- @Test
- public void issue_37() {
- String json = "[\n" + " {\n" + " \"id\": \"9\",\n" + " \"sku\": \"SKU-001\",\n" + " \"compatible\": false\n" + " },\n" + " {\n" + " \"id\": \"13\",\n" + " \"sku\": \"SKU-005\",\n" + " \"compatible\": true\n" + " },\n" + " {\n" + " \"id\": \"11\",\n" + " \"sku\": \"SKU-003\",\n" + " \"compatible\": true\n" + " }\n" + "]";
- List<String> result = read(json, "$[?(@.compatible == true)].sku");
- assertThat(result).containsExactly("SKU-005", "SKU-003");
- }
-
- @Test
- public void issue_38() {
- String json = "{\n" + " \"datapoints\":[\n" + " [\n" + " 10.1,\n" + " 13.0\n" + " ],\n" + " [\n" + " 21.0,\n" + " 22.0\n" + " ]\n" + " ]\n" + "}";
- List<Double> result = read(json, "$.datapoints.[*].[0]");
- assertThat(result.get(0), is(new Double(10.1)));
- assertThat(result.get(1), is(new Double(21.0)));
- }
-
- @Test
- public void issue_39() {
- String json = "{\n" + " \"obj1\": {\n" + " \"arr\": [\"1\", \"2\"]\n" + " },\n" + " \"obj2\": {\n" + " \"arr\": [\"3\", \"4\"]\n" + " }\n" + "}\n";
- List<String> result = read(json, "$..arr");
- assertThat(result.size(), is(2));
- }
-
- @Test
- public void issue_28_int() {
- String json = "{\"contents\": [1,2,3]}";
- List<Integer> result = read(json, "$.contents[?(@ == 2)]");
- assertThat(result, Matchers.contains(2));
- assertEquals(1, result.size());
- }
-
- @Test
- public void issue_28_boolean() {
- String json = "{\"contents\": [true, true, false]}";
- List<Boolean> result = read(json, "$.contents[?(@ == true)]");
- assertThat(result, Matchers.contains(true, true));
- assertEquals(2, result.size());
- }
-
- @Test(expected = PathNotFoundException.class)
- public void issue_22() throws Exception {
- Configuration configuration = Configuration.defaultConfiguration();
- String json = "{\"a\":{\"b\":1,\"c\":2}}";
- JsonPath.parse(json, configuration).read("a.d");
- }
-
- @Test
- public void issue_22c() throws Exception {
- //Configuration configuration = Configuration.builder().build();
- Configuration configuration = Configuration.builder().options(Option.SUPPRESS_EXCEPTIONS).build();
- String json = "{\"a\":{\"b\":1,\"c\":2}}";
- assertNull(JsonPath.parse(json, configuration).read("a.d"));
- }
-
- @Test
- public void issue_22b() throws Exception {
- String json = "{\"a\":[{\"b\":1,\"c\":2},{\"b\":5,\"c\":2}]}";
- List<Object> res = JsonPath.using(Configuration.defaultConfiguration().setOptions(Option.DEFAULT_PATH_LEAF_TO_NULL)).parse(json, false).read("a[?(@.b==5)].d");
- assertThat(res).hasSize(1).containsNull();
- }
-
- @Test(expected = PathNotFoundException.class)
- public void issue_26() throws Exception {
- String json = "[{\"a\":[{\"b\":1,\"c\":2}]}]";
- Object o = read(json, "$.a");
- }
-
- @Test
- public void issue_29_a() throws Exception {
- String json = "{\"list\": [ { \"a\":\"atext\", \"b.b-a\":\"batext2\", \"b\":{ \"b-a\":\"batext\", \"b-b\":\"bbtext\" } }, { \"a\":\"atext2\", \"b\":{ \"b-a\":\"batext2\", \"b-b\":\"bbtext2\" } } ] }";
- List<Map<String, Object>> result = read(json, "$.list[?(@['b.b-a']=='batext2')]");
- assertEquals(1, result.size());
- Object a = result.get(0).get("a");
- assertEquals("atext", a);
- result = read(json, "$.list[?(@.b.b-a=='batext2')]");
- assertEquals(1, result.size());
- assertEquals("atext2", result.get(0).get("a"));
- }
-
- @Test
- public void issue_29_b() throws Exception {
- String json = "{\"list\": [ { \"a\":\"atext\", \"b\":{ \"b-a\":\"batext\", \"b-b\":\"bbtext\" } }, { \"a\":\"atext2\", \"b\":{ \"b-a\":\"batext2\", \"b-b\":\"bbtext2\" } } ] }";
- List<String> result = read(json, "$.list[?]", filter(nb.where("b.b-a").eq("batext2")));
- assertTrue(result.size() == 1);
- }
-
- @Test
- public void issue_30() throws Exception {
- String json = "{\"foo\" : {\"@id\" : \"123\", \"$\" : \"hello\"}}";
- assertEquals("123", read(json, "foo.@id"));
- assertEquals("hello", read(json, "foo.$"));
- }
-
- @Test
- public void issue_32() {
- String json = "{\"text\" : \"skill: \\\"Heuristic Evaluation\\\"\", \"country\" : \"\"}";
- assertEquals("skill: \"Heuristic Evaluation\"", read(json, "$.text"));
- }
-
- @Test
- public void issue_33() {
- String json = "{ \"store\": {\n" + " \"book\": [ \n" + " { \"category\": \"reference\",\n" + " \"author\": {\n" + " \"name\": \"Author Name\",\n" + " \"age\": 36\n" + " },\n" + " \"title\": \"Sayings of the Century\",\n" + " \"price\": 8.95\n" + " },\n" + " { \"category\": \"fiction\",\n" + " \"author\": \"Evelyn Waugh\",\n" + " \"title\": \"Sword of Honour\",\n" + " \"price\": 12.99,\n" + " \"isbn\": \"0-553-21311-3\"\n" + " }\n" + " ],\n" + " \"bicycle\": {\n" + " \"color\": \"red\",\n" + " \"price\": 19.95\n" + " }\n" + " }\n" + "}";
- List<Map<String, Object>> result = read(json, "$.store.book[?(@.author.age == 36)]");
- assertThat(result).hasSize(1);
- assertThat(result.get(0)).containsEntry("title", "Sayings of the Century");
- }
-
- @Test
- public void array_root() {
- String json = "[\n" + " {\n" + " \"a\": 1,\n" + " \"b\": 2,\n" + " \"c\": 3\n" + " }\n" + "]";
- assertEquals(1, read(json, "$[0].a"));
- }
-
- @Test(expected = PathNotFoundException.class)
- public void a_test() {
- String json = "{\n" + " \"success\": true,\n" + " \"data\": {\n" + " \"user\": 3,\n" + " \"own\": null,\n" + " \"passes\": null,\n" + " \"completed\": null\n" + " },\n" + " \"version\": 1371160528774\n" + "}";
- Object read = read(json, "$.data.passes[0].id");
- }
-
- @SuppressWarnings("unchecked")
- @Test
- public void issue_42() {
- String json = "{" + " \"list\": [{" + " \"name\": \"My (String)\" " + " }] " + " }";
- List<Map<String, String>> result = read(json, "$.list[?(@.name == 'My (String)')]");
- assertThat(result).containsExactly(Collections.singletonMap("name", "My (String)"));
- }
-
- @Test
- public void issue_43() {
- String json = "{\"test\":null}";
- assertThat(read(json, "test")).isNull();
- assertThat(JsonPath.using(Configuration.defaultConfiguration().setOptions(Option.SUPPRESS_EXCEPTIONS)).parse(json, false).read("nonExistingProperty")).isNull();
- try {
- read(json, "nonExistingProperty");
- failBecauseExceptionWasNotThrown(PathNotFoundException.class);
- } catch (PathNotFoundException e) {
- }
- try {
- read(json, "nonExisting.property");
- failBecauseExceptionWasNotThrown(PathNotFoundException.class);
- } catch (PathNotFoundException e) {
- }
- }
-
- @Test
- public void issue_45() {
- String json = "{\"rootkey\":{\"sub.key\":\"value\"}}";
- assertThat(read(json, "rootkey['sub.key']")).isEqualTo("value");
- }
-
- @Test
- public void issue_46() {
- String json = "{\"a\": {}}";
- Configuration configuration = Configuration.defaultConfiguration().setOptions(Option.SUPPRESS_EXCEPTIONS);
- assertThat(JsonPath.using(configuration).parse(json, false).read("a.x")).isNull();
- try {
- read(json, "a.x");
- failBecauseExceptionWasNotThrown(PathNotFoundException.class);
- } catch (PathNotFoundException e) {
- assertThat(e).hasMessage("No results for path: $['a']['x']");
- }
- }
-
- @Test
- public void issue_x() {
- String json = "{\n" + " \"a\" : [\n" + " {},\n" + " { \"b\" : [ { \"c\" : \"foo\"} ] }\n" + " ]\n" + "}\n";
- List<String> result = read(json, "$.a.*.b.*.c");
- assertThat(result).containsExactly("foo");
- }
-
- @Test
- public void issue_60() {
- String json = "[\n" + "{\n" + " \"mpTransactionId\": \"542986eae4b001fd500fdc5b-coreDisc_50-title\",\n" + " \"resultType\": \"FAIL\",\n" + " \"narratives\": [\n" + " {\n" + " \"ruleProcessingDate\": \"Nov 2, 2014 7:30:20 AM\",\n" + " \"area\": \"Discovery\",\n" + " \"phase\": \"Validation\",\n" + " \"message\": \"Chain does not have a discovery event. Possible it was cut by the date that was picked\",\n" + " \"ruleName\": \"Validate chain\\u0027s discovery event existence\",\n" + " \"lastRule\": true\n" + " }\n" + " ]\n" + "},\n" + "{\n" + " \"mpTransactionId\": \"54298649e4b001fd500fda3e-fixCoreDiscovery_3-title\",\n" + " \"resultType\": \"FAIL\",\n" + " \"narratives\": [\n" + " {\n" + " \"ruleProcessingDate\": \"Nov 2, 2014 7:30:20 AM\",\n" + " \"area\": \"Discovery\",\n" + " \"phase\": \"Validation\",\n" + " \"message\": \"There is one and only discovery event ContentDiscoveredEvent(230) found.\",\n" + " \"ruleName\": \"Marks existence of discovery event (230)\",\n" + " \"lastRule\": false\n" + " },\n" + " {\n" + " \"ruleProcessingDate\": \"Nov 2, 2014 7:30:20 AM\",\n" + " \"area\": \"Discovery/Processing\",\n" + " \"phase\": \"Validation\",\n" + " \"message\": \"Chain does not have SLA start event (204) in Discovery or Processing. \",\n" + " \"ruleName\": \"Check if SLA start event is not present (204). \",\n" + " \"lastRule\": false\n" + " },\n" + " {\n" + " \"ruleProcessingDate\": \"Nov 2, 2014 7:30:20 AM\",\n" + " \"area\": \"Processing\",\n" + " \"phase\": \"Transcode\",\n" + " \"message\": \"No start transcoding events found\",\n" + " \"ruleName\": \"Start transcoding events missing (240)\",\n" + " \"lastRule\": true\n" + " }\n" + " ]\n" + "}]";
- List<String> problems = read(json, "$..narratives[?(@.lastRule==true)].message");
- assertThat(problems).containsExactly("Chain does not have a discovery event. Possible it was cut by the date that was picked", "No start transcoding events found");
- }
-
- //http://stackoverflow.com/questions/28596324/jsonpath-filtering-api
- @Test
- public void stack_overflow_question_1() {
- String json = "{\n" + "\"store\": {\n" + " \"book\": [\n" + " {\n" + " \"category\": \"reference\",\n" + " \"authors\" : [\n" + " {\n" + " \"firstName\" : \"Nigel\",\n" + " \"lastName\" : \"Rees\"\n" + " }\n" + " ],\n" + " \"title\": \"Sayings of the Century\",\n" + " \"price\": 8.95\n" + " },\n" + " {\n" + " \"category\": \"fiction\",\n" + " \"authors\": [\n" + " {\n" + " \"firstName\" : \"Evelyn\",\n" + " \"lastName\" : \"Waugh\"\n" + " },\n" + " {\n" + " \"firstName\" : \"Another\",\n" + " \"lastName\" : \"Author\"\n" + " }\n" + " ],\n" + " \"title\": \"Sword of Honour\",\n" + " \"price\": 12.99\n" + " }\n" + " ]\n" + " }\n" + "}";
- Filter filter = filter(nb.where("authors[*].lastName").contains("Waugh"));
- Object read = JsonPath.parse(json).read("$.store.book[?]", filter);
- }
-
- @Test
- public void issue_71() {
- String json = "{\n" + " \"logs\": [\n" + " {\n" + " \"message\": \"it's here\",\n" + " \"id\": 2\n" + " }\n" + " ]\n" + "}";
- List<String> result = read(json, "$.logs[?(@.message == 'it\\'s here')].message");
- assertThat(result).containsExactly("it's here");
- }
-
- @Test
- public void issue_76() throws Exception {
- String json = "{\n" + " \"cpus\": -8.88178419700125e-16,\n" + " \"disk\": 0,\n" + " \"mem\": 0\n" + "}";
- JSONTokener parser = new JSONTokener(json);
- JSONObject jsonModel = (JSONObject) parser.nextValue();
- jsonModel.toString();
- }
-
- @Test
- public void issue_79() throws Exception {
- String json = "{ \n" + " \"c\": {\n" + " \"d1\": {\n" + " \"url\": [ \"url1\", \"url2\" ]\n" + " },\n" + " \"d2\": {\n" + " \"url\": [ \"url3\", \"url4\",\"url5\" ]\n" + " }\n" + " }\n" + "}";
- List<String> res = read(json, "$.c.*.url[2]");
- assertThat(res).containsExactly("url5");
- }
-
- @Test
- public void issue_94_1() throws Exception {
- LRUCache cache = new LRUCache(200);
- JsonPath dummy = JsonPath.compile("$");
- for (int i = 0; i < 1000; ++i) {
- String key = String.valueOf(i);
- cache.get(key);
- cache.put(key, dummy);
- }
- assertThat(cache.size()).isEqualTo(200);
- }
-
- @Test
- public void issue_94_2() throws Exception {
- LRUCache cache = new LRUCache(5);
- JsonPath dummy = JsonPath.compile("$");
- cache.put("1", dummy);
- cache.put("2", dummy);
- cache.put("3", dummy);
- cache.put("4", dummy);
- cache.put("5", dummy);
- cache.put("6", dummy);
- cache.get("1");
- cache.get("2");
- cache.get("3");
- cache.get("4");
- cache.get("5");
- cache.get("6");
- cache.get("2");
- cache.get("3");
- cache.get("4");
- cache.get("5");
- cache.get("6");
- cache.get("3");
- cache.get("4");
- cache.get("5");
- cache.get("6");
- cache.get("4");
- cache.get("5");
- cache.get("6");
- cache.get("5");
- cache.get("6");
- cache.get("6");
- assertThat(cache.getSilent("6")).isNotNull();
- assertThat(cache.getSilent("5")).isNotNull();
- assertThat(cache.getSilent("4")).isNotNull();
- assertThat(cache.getSilent("3")).isNotNull();
- assertThat(cache.getSilent("2")).isNotNull();
- assertThat(cache.getSilent("1")).isNull();
- }
-
- @Test
- public void issue_97() throws Exception {
- String json = "{ \"books\": [ " + "{ \"category\": \"fiction\" }, " + "{ \"category\": \"reference\" }, " + "{ \"category\": \"fiction\" }, " + "{ \"category\": \"fiction\" }, " + "{ \"category\": \"reference\" }, " + "{ \"category\": \"fiction\" }, " + "{ \"category\": \"reference\" }, " + "{ \"category\": \"reference\" }, " + "{ \"category\": \"reference\" }, " + "{ \"category\": \"reference\" }, " + "{ \"category\": \"reference\" } ] }";
- Configuration conf = Configuration.builder().jsonProvider(new JsonOrgJsonProvider()).mappingProvider(new JsonOrgMappingProvider()).build();
- DocumentContext context = JsonPath.using(conf).parse(json, false);
- context.delete("$.books[?(@.category == 'reference')]");
- List<String> categories = context.read("$..category", List.class);
- assertThat(categories).containsOnly("fiction");
- }
-
- @Test
- public void issue_99() throws Exception {
- String json = "{\n" + " \"array1\": [\n" + " {\n" + " \"array2\": []\n" + " },\n" + " {\n" + " \"array2\": [\n" + " {\n" + " \"key\": \"test_key\"\n" + " }\n" + " ]\n" + " }\n" + " ]\n" + "}";
- Configuration configuration = Configuration.defaultConfiguration().addOptions(Option.DEFAULT_PATH_LEAF_TO_NULL);
- List<String> keys = JsonPath.using(configuration).parse(json, false).read("$.array1[*].array2[0].key");
- }
-
- @Test
- public void issue_129() throws Exception {
- final Map<String, Integer> match = new HashMap<String, Integer>();
- match.put("a", 1);
- match.put("b", 2);
- Map<String, Integer> noMatch = new HashMap<String, Integer>();
- noMatch.put("a", -1);
- noMatch.put("b", -2);
- Filter orig = filter(nb.where("a").eq(1).and("b").eq(2));
- String filterAsString = orig.toString();
- Filter parsed = Filter.parse(filterAsString);
- assertThat(orig.apply(createPredicateContext(match))).isTrue();
- assertThat(parsed.apply(createPredicateContext(match))).isTrue();
- assertThat(orig.apply(createPredicateContext(noMatch))).isFalse();
- assertThat(parsed.apply(createPredicateContext(noMatch))).isFalse();
- }
-
- private PredicateContext createPredicateContext(final Map<String, Integer> map) {
- return new PredicateContext() {
- @Override
- public Object item() {
- return map;
- }
-
- @Override
- public <T> T item(Class<T> clazz) throws MappingException {
- return (T) map;
- }
-
- @Override
- public Object root() {
- return map;
- }
-
- @Override
- public Configuration configuration() {
- return Configuration.defaultConfiguration();
- }
- };
- }
-
- @Test
- public void issue_131() {
- String json = "[\n" + " {\n" + " \"foo\": \"1\"\n" + " },\n" + " {\n" + " \"foo\": null\n" + " },\n" + " {\n" + " \"xxx\": null\n" + " }\n" + "]";
- List<Map<String, String>> result = read(json, "$[?(@.foo)]");
- assertThat(result).extracting("foo").containsExactly("1", null);
- }
-
- @Test
- public void issue_131_2() {
- String json = "[\n" + " {\n" + " \"foo\": { \"bar\" : \"0\"}\n" + " },\n" + " {\n" + " \"foo\": null\n" + " },\n" + " {\n" + " \"xxx\": null\n" + " }\n" + "]";
- List<String> result = read(json, "$[?(@.foo != null)].foo.bar");
- assertThat(result).containsExactly("0");
- result = read(json, "$[?(@.foo.bar)].foo.bar");
- assertThat(result).containsExactly("0");
- }
-
- @Test
- public void issue_131_3() {
- String json = "[\n" + " 1,\n" + " 2,\n" + " {\n" + " \"d\": {\n" + " \"random\": null,\n" + " \"date\": 1234\n" + " },\n" + " \"l\": \"filler\"\n" + " }\n" + "]";
- List<Integer> result = read(json, "$[2]['d'][?(@.random)]['date']");
- assertThat(result).containsExactly(1234);
- }
-
- //https://groups.google.com/forum/#!topic/jsonpath/Ojv8XF6LgqM
- @Test
- public void using_square_bracket_literal_path() {
- String json = "{ \"valid key[@num = 2]\" : \"value\" }";
- String result = read(json, "$['valid key[@num = 2]']");
- Assertions.assertThat(result).isEqualTo("value");
- }
-
- @Test
- public void issue_90() {
- String json = "{\n" + " \"store\": {\n" + " \"book\": [\n" + " {\n" + " \"price\": \"120\"\n" + " },\n" + " {\n" + " \"price\": 8.95\n" + " },\n" + " {\n" + " \"price\": 12.99\n" + " },\n" + " {\n" + " \"price\": 8.99\n" + " },\n" + " {\n" + " \"price\": 22.99\n" + " }\n" + " ]\n" + " },\n" + " \"expensive\": 10\n" + "}";
- List<Double> numbers = read(json, "$.store.book[?(@.price <= 90)].price");
- assertThat(numbers).containsExactly(8.95D, 12.99D, 8.99D, 22.99D);
- }
-
- @Test(expected = PathNotFoundException.class)
- public void github_89() throws JSONException {
- JSONObject json = new JSONObject();
- json.put("foo", "bar");
- JsonPath path = JsonPath.compile("$.foo");
- String object = path.read(json);
- }
-
- @Test
- public void issue_170() {
- String json = "{\n" + " \"array\": [\n" + " 0,\n" + " 1,\n" + " 2\n" + " ]\n" + "}";
- DocumentContext context = using(JSON_ORG_CONFIGURATION).parse(json, false);
- context = context.set("$.array[0]", null);
- context = context.set("$.array[2]", null);
- List<Integer> list = context.read("$.array", List.class);
- assertThat(list).containsExactly(null, 1, null);
- }
-
- @Test
- public void issue_171() throws JSONException {
- String json = "{\n" + " \"can delete\": \"this\",\n" + " \"can't delete\": \"this\"\n" + "}";
- DocumentContext context = using(JSON_ORG_CONFIGURATION).parse(json, false);
- context.set("$.['can delete']", null);
- context.set("$.['can\\'t delete']", null);
- JSONObject objectNode = context.read("$");
- assertThat(JSONObject.NULL.equals(objectNode.opt("can delete")));
- assertThat(JSONObject.NULL.equals(objectNode.opt("can't delete")));
- }
-
- @Test
- public void issue_309() {
- String json = "{\n" + "\"jsonArr\": [\n" + " {\n" + " \"name\":\"nOne\"\n" + " },\n" + " {\n" + " \"name\":\"nTwo\"\n" + " }\n" + " ]\n" + "}";
- DocumentContext doc = JsonPath.parse(json).set("$.jsonArr[1].name", "Jayway");
- assertThat(doc.read("$.jsonArr[0].name")).isEqualTo("nOne");
- assertThat(doc.read("$.jsonArr[1].name")).isEqualTo("Jayway");
- }
-
- @Test
- public void issue_378() {
- String json = "{\n" + " \"nodes\": {\n" + " \"unnamed1\": {\n" + " \"ntpServers\": [\n" + " \"1.2.3.4\"\n" + " ]\n" + " }\n" + " }\n" + "}";
- Configuration configuration = Configuration.builder().jsonProvider(new JsonOrgJsonProvider()).mappingProvider(new JsonOrgMappingProvider()).build();
-
- DocumentContext ctx = JsonPath.using(configuration).parse(json, false);
- String path = "$.nodes[*][?(!([\"1.2.3.4\"] subsetof @.ntpServers))].ntpServers";
- JsonPath jsonPath = JsonPath.compile(path);
- ctx.read(jsonPath);
- }
-}
diff --git a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/old/JsonPathTest.java b/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/old/JsonPathTest.java
deleted file mode 100644
index 35f1037..0000000
--- a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/old/JsonPathTest.java
+++ /dev/null
@@ -1,220 +0,0 @@
-package org.eclipse.sensinact.gateway.nthbnd.test.jsonpath.old;
-
-import com.jayway.jsonpath.Configuration;
-import com.jayway.jsonpath.InvalidPathException;
-import com.jayway.jsonpath.JsonPath;
-import com.jayway.jsonpath.Option;
-import com.jayway.jsonpath.PathNotFoundException;
-import com.jayway.jsonpath.internal.path.PathCompiler;
-import org.assertj.core.api.Assertions;
-import org.eclipse.sensinact.gateway.nthbnd.test.jsonpath.BaseTestConfiguration;
-import org.junit.Test;
-
-import java.util.List;
-import java.util.Map;
-
-import static org.hamcrest.Matchers.hasItems;
-import static org.hamcrest.Matchers.hasSize;
-import static org.junit.Assert.*;
-
-public class JsonPathTest extends BaseTestConfiguration {
- static {
- //JsonProviderFactory.setDefaultProvider(JacksonProvider.class);
- }
-
- public final static String ARRAY = "[{\"value\": 1},{\"value\": 2}, {\"value\": 3},{\"value\": 4}]";
- public final static String DOCUMENT = "{ \"store\": {\n" + " \"book\": [ \n" + " { \"category\": \"reference\",\n" + " \"author\": \"Nigel Rees\",\n" + " \"title\": \"Sayings of the Century\",\n" + " \"display-price\": 8.95\n" + " },\n" + " { \"category\": \"fiction\",\n" + " \"author\": \"Evelyn Waugh\",\n" + " \"title\": \"Sword of Honour\",\n" + " \"display-price\": 12.99\n" + " },\n" + " { \"category\": \"fiction\",\n" + " \"author\": \"Herman Melville\",\n" + " \"title\": \"Moby Dick\",\n" + " \"isbn\": \"0-553-21311-3\",\n" + " \"display-price\": 8.99\n" + " },\n" + " { \"category\": \"fiction\",\n" + " \"author\": \"J. R. R. Tolkien\",\n" + " \"title\": \"The Lord of the Rings\",\n" + " \"isbn\": \"0-395-19395-8\",\n" + " \"display-price\": 22.99\n" + " }\n" + " ],\n" + " \"bicycle\": {\n" + " \"color\": \"red\",\n" + " \"display-price\": 19.95,\n" + " \"foo:bar\": \"fooBar\",\n" + " \"dot.notation\": \"new\",\n" + " \"dash-notation\": \"dashes\"\n" + " }\n" + " }\n" + "}";
- public final static Object OBJ_DOCUMENT = JsonPath.parse(DOCUMENT).json();
- private final static String PRODUCT_JSON = "{\n" + "\t\"product\": [ {\n" + "\t \"version\": \"A\", \n" + "\t \"codename\": \"Seattle\", \n" + "\t \"attr.with.dot\": \"A\"\n" + "\t},\n" + "\t{\n" + "\t \"version\": \"4.0\", \n" + "\t \"codename\": \"Montreal\", \n" + "\t \"attr.with.dot\": \"B\"\n" + "\t}]\n" + "}";
- private final static String ARRAY_EXPAND = "[{\"parent\": \"ONE\", \"child\": {\"name\": \"NAME_ONE\"}}, [{\"parent\": \"TWO\", \"child\": {\"name\": \"NAME_TWO\"}}]]";
-
- @Test(expected = PathNotFoundException.class)
- public void missing_prop() {
- //Object read = JsonPath.using(Configuration.defaultConfiguration().setOptions(Option.THROW_ON_MISSING_PROPERTY)).parse(DOCUMENT).read("$.store.book[*].fooBar");
- //Object read = JsonPath.using(Configuration.defaultConfiguration()).parse(DOCUMENT).read("$.store.book[*].fooBar");
- Object read2 = JsonPath.using(Configuration.defaultConfiguration().addOptions(Option.REQUIRE_PROPERTIES)).parse(DOCUMENT, false).read("$.store.book[*].fooBar.not");
- }
-
- @Test
- public void bracket_notation_with_dots() {
- String json = "{\n" + " \"store\": {\n" + " \"book\": [\n" + " {\n" + " \"author.name\": \"Nigel Rees\", \n" + " \"category\": \"reference\", \n" + " \"price\": 8.95, \n" + " \"title\": \"Sayings of the Century\"\n" + " }\n" + " ]\n" + " }\n" + "}";
- assertEquals("Nigel Rees", JsonPath.read(json, "$.store.book[0]['author.name']"));
- }
-
- @Test
- public void null_object_in_path() {
- String json = "{\n" + " \"success\": true,\n" + " \"data\": {\n" + " \"user\": 3,\n" + " \"own\": null,\n" + " \"passes\": null,\n" + " \"completed\": null\n" + " },\n" + " \"data2\": {\n" + " \"user\": 3,\n" + " \"own\": null,\n" + " \"passes\": [{\"id\":\"1\"}],\n" + " \"completed\": null\n" + " },\n" + " \"version\": 1371160528774\n" + "}";
- try {
- JsonPath.read(json, "$.data.passes[0].id");
- Assertions.fail("Expected PathNotFoundException");
- } catch (PathNotFoundException e) {
- }
- Assertions.assertThat(JsonPath.read(json, "$.data2.passes[0].id")).isEqualTo("1");
- }
-
- @Test
- public void array_start_expands() throws Exception {
- //assertThat(JsonPath.<List<String>>read(ARRAY_EXPAND, "$[?(@.parent = 'ONE')].child.name"), hasItems("NAME_ONE"));
- assertThat(JsonPath.<List<String>>read(ARRAY_EXPAND, "$[?(@['parent'] == 'ONE')].child.name"), hasItems("NAME_ONE"));
- }
-
- @Test
- public void bracket_notation_can_be_used_in_path() throws Exception {
- assertEquals("new", JsonPath.read(DOCUMENT, "$.['store'].bicycle.['dot.notation']"));
- assertEquals("new", JsonPath.read(DOCUMENT, "$['store']['bicycle']['dot.notation']"));
- assertEquals("new", JsonPath.read(DOCUMENT, "$.['store']['bicycle']['dot.notation']"));
- assertEquals("new", JsonPath.read(DOCUMENT, "$.['store'].['bicycle'].['dot.notation']"));
- assertEquals("dashes", JsonPath.read(DOCUMENT, "$.['store'].bicycle.['dash-notation']"));
- assertEquals("dashes", JsonPath.read(DOCUMENT, "$['store']['bicycle']['dash-notation']"));
- assertEquals("dashes", JsonPath.read(DOCUMENT, "$.['store']['bicycle']['dash-notation']"));
- assertEquals("dashes", JsonPath.read(DOCUMENT, "$.['store'].['bicycle'].['dash-notation']"));
- }
-
- @Test
- public void filter_an_array() throws Exception {
- List<Object> matches = JsonPath.read(ARRAY, "$.[?(@.value == 1)]");
- assertEquals(1, matches.size());
- }
-
- @Test
- public void filter_an_array_on_index() throws Exception {
- Integer matches = JsonPath.read(ARRAY, "$.[1].value");
- assertEquals(new Integer(2), matches);
- }
-
- @Test
- public void read_path_with_colon() throws Exception {
- assertEquals(JsonPath.read(DOCUMENT, "$['store']['bicycle']['foo:bar']"), "fooBar");
- }
-
- @Test
- public void read_document_from_root() throws Exception {
- Map result = JsonPath.read(DOCUMENT, "$.store");
- assertEquals(2, result.values().size());
- }
-
- @Test
- public void read_store_book_1() throws Exception {
- JsonPath path = JsonPath.compile("$.store.book[1]");
- Map map = path.read(DOCUMENT);
- assertEquals("Evelyn Waugh", map.get("author"));
- }
-
- @Test
- public void read_store_book_wildcard() throws Exception {
- JsonPath path = JsonPath.compile("$.store.book[*]");
- List<Object> list = path.read(DOCUMENT);
- Assertions.assertThat(list.size()).isEqualTo(4);
- }
-
- @Test
- public void read_store_book_author() throws Exception {
- assertThat(JsonPath.<List<String>>read(DOCUMENT, "$.store.book[0,1].author"), hasItems("Nigel Rees", "Evelyn Waugh"));
- assertThat(JsonPath.<List<String>>read(DOCUMENT, "$.store.book[*].author"), hasItems("Nigel Rees", "Evelyn Waugh", "Herman Melville", "J. R. R. Tolkien"));
- assertThat(JsonPath.<List<String>>read(DOCUMENT, "$.['store'].['book'][*].['author']"), hasItems("Nigel Rees", "Evelyn Waugh", "Herman Melville", "J. R. R. Tolkien"));
- assertThat(JsonPath.<List<String>>read(DOCUMENT, "$['store']['book'][*]['author']"), hasItems("Nigel Rees", "Evelyn Waugh", "Herman Melville", "J. R. R. Tolkien"));
- assertThat(JsonPath.<List<String>>read(DOCUMENT, "$['store'].book[*]['author']"), hasItems("Nigel Rees", "Evelyn Waugh", "Herman Melville", "J. R. R. Tolkien"));
- }
-
- @Test
- public void all_authors() throws Exception {
- assertThat(JsonPath.<List<String>>read(DOCUMENT, "$..author"), hasItems("Nigel Rees", "Evelyn Waugh", "Herman Melville", "J. R. R. Tolkien"));
- }
-
- @Test
- public void all_store_properties() throws Exception {
- /*
- List<Object> itemsInStore = JsonPath.read(DOCUMENT, "$.store.*");
- assertEquals(JsonPath.read(itemsInStore, "$.[0].[0].author"), "Nigel Rees");
- assertEquals(JsonPath.read(itemsInStore, "$.[0][0].author"), "Nigel Rees");
- */
- List<String> result = PathCompiler.compile("$.store.*").evaluate(OBJ_DOCUMENT, OBJ_DOCUMENT, Configuration.defaultConfiguration()).getPathList();
- Assertions.assertThat(result).containsOnly("$['store']['bicycle']", "$['store']['book']");
- }
-
- @Test
- public void all_prices_in_store() throws Exception {
- assertThat(JsonPath.<List<Double>>read(DOCUMENT, "$.store..['display-price']"), hasItems(8.95D, 12.99D, 8.99D, 19.95D));
- }
-
- @Test
- public void access_array_by_index_from_tail() throws Exception {
- assertThat(JsonPath.<List<String>>read(DOCUMENT, "$..book[1:].author"), hasItems("Evelyn Waugh", "Herman Melville", "J. R. R. Tolkien"));
- }
-
- @Test
- public void read_store_book_index_0_and_1() throws Exception {
- assertThat(JsonPath.<List<String>>read(DOCUMENT, "$.store.book[0,1].author"), hasItems("Nigel Rees", "Evelyn Waugh"));
- assertTrue(JsonPath.<List>read(DOCUMENT, "$.store.book[0,1].author").size() == 2);
- }
-
- @Test
- public void read_store_book_pull_first_2() throws Exception {
- assertThat(JsonPath.<List<String>>read(DOCUMENT, "$.store.book[:2].author"), hasItems("Nigel Rees", "Evelyn Waugh"));
- assertTrue(JsonPath.<List>read(DOCUMENT, "$.store.book[:2].author").size() == 2);
- }
-
- @Test
- public void read_store_book_filter_by_isbn() throws Exception {
- assertThat(JsonPath.<List<String>>read(DOCUMENT, "$.store.book[?(@.isbn)].isbn"), hasItems("0-553-21311-3", "0-395-19395-8"));
- assertTrue(JsonPath.<List>read(DOCUMENT, "$.store.book[?(@.isbn)].isbn").size() == 2);
- assertTrue(JsonPath.<List>read(DOCUMENT, "$.store.book[?(@['isbn'])].isbn").size() == 2);
- }
-
- @Test
- public void all_books_cheaper_than_10() throws Exception {
- assertThat(JsonPath.<List<String>>read(DOCUMENT, "$..book[?(@['display-price'] < 10)].title"), hasItems("Sayings of the Century", "Moby Dick"));
- assertThat(JsonPath.<List<String>>read(DOCUMENT, "$..book[?(@.display-price < 10)].title"), hasItems("Sayings of the Century", "Moby Dick"));
- }
-
- @Test
- public void all_books() throws Exception {
- Assertions.assertThat(JsonPath.<List<Object>>read(DOCUMENT, "$..book")).hasSize(1);
- }
-
- @Test
- public void dot_in_predicate_works() throws Exception {
- assertThat(JsonPath.<List<String>>read(PRODUCT_JSON, "$.product[?(@.version=='4.0')].codename"), hasItems("Montreal"));
- }
-
- @Test
- public void dots_in_predicate_works() throws Exception {
- assertThat(JsonPath.<List<String>>read(PRODUCT_JSON, "$.product[?(@.['attr.with.dot']=='A')].codename"), hasItems("Seattle"));
- }
-
- @Test
- public void all_books_with_category_reference() throws Exception {
- assertThat(JsonPath.<List<String>>read(DOCUMENT, "$..book[?(@.category=='reference')].title"), hasItems("Sayings of the Century"));
- assertThat(JsonPath.<List<String>>read(DOCUMENT, "$.store.book[?(@.category=='reference')].title"), hasItems("Sayings of the Century"));
- }
-
- @Test
- public void all_members_of_all_documents() throws Exception {
- List<String> all = JsonPath.read(DOCUMENT, "$..*");
- }
-
- @Test(expected = PathNotFoundException.class)
- public void access_index_out_of_bounds_does_not_throw_exception() throws Exception {
- JsonPath.read(DOCUMENT, "$.store.book[100].author");
- }
-
- @Test
- public void exists_filter_with_nested_path() throws Exception {
- assertThat(JsonPath.<List<String>>read(DOCUMENT, "$..[?(@.bicycle.color)]"), hasSize(1));
- assertThat(JsonPath.<List<String>>read(DOCUMENT, "$..[?(@.bicycle.numberOfGears)]"), hasSize(0));
- }
-
- @Test
- // see https://code.google.com/p/json-path/issues/detail?id=58
- public void invalid_paths_throw_invalid_path_exception() throws Exception {
- for (String path : new String[]{"$.", "$.results[?"}) {
- try {
- JsonPath.compile(path);
- } catch (InvalidPathException e) {
- // that's expected
- } catch (Exception e) {
- fail("Expected an InvalidPathException trying to compile '" + path + "', but got a " + e.getClass().getName());
- }
- }
- }
-}
diff --git a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/old/JsonProviderTest.java b/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/old/JsonProviderTest.java
deleted file mode 100644
index 05be431..0000000
--- a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/java/org/eclipse/sensinact/gateway/nthbnd/test/jsonpath/old/JsonProviderTest.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package org.eclipse.sensinact.gateway.nthbnd.test.jsonpath.old;
-
-import org.eclipse.sensinact.gateway.nthbnd.jsonpath.json.JsonOrgJsonProvider;
-import org.junit.Test;
-
-public class JsonProviderTest {
- public final static String ARRAY = "[{\"value\": 1},{\"value\": 2}, {\"value\": 3},{\"value\": 4}]";
- public final static String DOCUMENT = "{ \"store\": {\n" + " \"book\": [ \n" + " { \"category\": \"reference\",\n" + " \"author\": \"Nigel Rees\",\n" + " \"title\": \"Sayings of the Century\",\n" + " \"price\": 8.95\n" + " },\n" + " { \"category\": \"fiction\",\n" + " \"author\": \"Evelyn Waugh\",\n" + " \"title\": \"Sword of Honour\",\n" + " \"price\": 12.99\n" + " },\n" + " { \"category\": \"fiction\",\n" + " \"author\": \"Herman Melville\",\n" + " \"title\": \"Moby Dick\",\n" + " \"isbn\": \"0-553-21311-3\",\n" + " \"price\": 8.99\n" + " },\n" + " { \"category\": \"fiction\",\n" + " \"author\": \"J. R. R. Tolkien\",\n" + " \"title\": \"The Lord of the Rings\",\n" + " \"isbn\": \"0-395-19395-8\",\n" + " \"price\": 22.99\n" + " }\n" + " ],\n" + " \"bicycle\": {\n" + " \"color\": \"red\",\n" + " \"price\": 19.95,\n" + " \"foo:bar\": \"fooBar\",\n" + " \"dot.notation\": \"new\"\n" + " }\n" + " }\n" + "}";
-
- @Test
- public void parse_document() throws Exception {
- JsonOrgJsonProvider provider = new JsonOrgJsonProvider();
- Object o = provider.parse(DOCUMENT);
- }
-
- @Test
- public void parse_array() throws Exception {
- JsonOrgJsonProvider provider = new JsonOrgJsonProvider();
- Object o = provider.parse(ARRAY);
- }
-}
diff --git a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/resources/issue_191.json b/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/resources/issue_191.json
deleted file mode 100644
index 934026a..0000000
--- a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/resources/issue_191.json
+++ /dev/null
@@ -1,1258 +0,0 @@
-{
- "activated_slaves": 5,
- "build_date": "2015-01-09 02:25:21",
- "build_time": 1420770321,
- "build_user": "root",
- "completed_frameworks": [
- {
- "active": true,
- "checkpoint": true,
- "completed_tasks": [
- {
- "executor_id": "",
- "framework_id": "20150225-172738-2049997834-5050-23289-0433",
- "id": "mesos-jenkins-172c6f74-12bc-44fe-849a-ad902ddc2b64",
- "name": "task mesos-jenkins-172c6f74-12bc-44fe-849a-ad902ddc2b64",
- "resources": {
- "cpus": 0.2,
- "disk": 0,
- "mem": 704
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S19",
- "state": "TASK_KILLED",
- "statuses": [
- {
- "state": "TASK_RUNNING",
- "timestamp": 1427206149.38254
- },
- {
- "state": "TASK_KILLED",
- "timestamp": 1427207981.47819
- }
- ]
- }
- ],
- "failover_timeout": 0,
- "hostname": "ip-10-124-48-147.ec2.internal",
- "id": "20150225-172738-2049997834-5050-23289-0433",
- "name": "Jenkins Scheduler",
- "offered_resources": {
- "cpus": -2.22044604925031e-16,
- "disk": 0,
- "mem": 0
- },
- "offers": [],
- "registered_time": 1427207787.01579,
- "reregistered_time": 1427207787.0158,
- "resources": {
- "cpus": -2.22044604925031e-16,
- "disk": 0,
- "mem": 0
- },
- "role": "*",
- "tasks": [],
- "unregistered_time": 1427207981.47898,
- "used_resources": {
- "cpus": 0,
- "disk": 0,
- "mem": 0
- },
- "user": "jenkins",
- "webui_url": ""
- },
- {
- "active": true,
- "checkpoint": true,
- "completed_tasks": [
- {
- "executor_id": "",
- "framework_id": "20150225-172748-1513192458-5050-6647-0000",
- "id": "mesos-jenkins-cd18b433-e2ee-4a4e-875b-6ea82d90a53a",
- "name": "task mesos-jenkins-cd18b433-e2ee-4a4e-875b-6ea82d90a53a",
- "resources": {
- "cpus": 0.2,
- "disk": 0,
- "mem": 704
- },
- "slave_id": "20150225-172748-1513192458-5050-6647-S0",
- "state": "TASK_KILLED",
- "statuses": [
- {
- "state": "TASK_RUNNING",
- "timestamp": 1427209005.01389
- },
- {
- "state": "TASK_KILLED",
- "timestamp": 1427209961.51519
- }
- ]
- },
- {
- "executor_id": "",
- "framework_id": "20150225-172748-1513192458-5050-6647-0000",
- "id": "mesos-jenkins-66fca7c0-88f7-4a1a-9796-a6de2e337b0a",
- "name": "task mesos-jenkins-66fca7c0-88f7-4a1a-9796-a6de2e337b0a",
- "resources": {
- "cpus": 0.2,
- "disk": 0,
- "mem": 704
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S25",
- "state": "TASK_KILLED",
- "statuses": [
- {
- "state": "TASK_RUNNING",
- "timestamp": 1427209025.84128
- },
- {
- "state": "TASK_KILLED",
- "timestamp": 1427211101.4792
- }
- ]
- }
- ],
- "failover_timeout": 0,
- "hostname": "ip-10-124-48-147.ec2.internal",
- "id": "20150225-172748-1513192458-5050-6647-0000",
- "name": "Jenkins Scheduler",
- "offered_resources": {
- "cpus": -8.88178419700125e-16,
- "disk": 0,
- "mem": 0
- },
- "offers": [],
- "registered_time": 1427208985.06716,
- "resources": {
- "cpus": -8.88178419700125e-16,
- "disk": 0,
- "mem": 0
- },
- "role": "*",
- "tasks": [],
- "unregistered_time": 1427211101.48013,
- "used_resources": {
- "cpus": 0,
- "disk": 0,
- "mem": 0
- },
- "user": "jenkins",
- "webui_url": ""
- },
- {
- "active": true,
- "checkpoint": true,
- "completed_tasks": [
- {
- "executor_id": "",
- "framework_id": "20150225-172748-1513192458-5050-6647-0001",
- "id": "mesos-jenkins-258ad47c-85bf-4fe0-b7c4-4f0cc70f2998",
- "name": "task mesos-jenkins-258ad47c-85bf-4fe0-b7c4-4f0cc70f2998",
- "resources": {
- "cpus": 0.2,
- "disk": 0,
- "mem": 704
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S27",
- "state": "TASK_KILLED",
- "statuses": [
- {
- "state": "TASK_RUNNING",
- "timestamp": 1427211139.85003
- },
- {
- "state": "TASK_KILLED",
- "timestamp": 1427212121.47896
- }
- ]
- }
- ],
- "failover_timeout": 0,
- "hostname": "ip-10-124-48-147.ec2.internal",
- "id": "20150225-172748-1513192458-5050-6647-0001",
- "name": "Jenkins Scheduler",
- "offered_resources": {
- "cpus": 2.22044604925031e-16,
- "disk": 0,
- "mem": 0
- },
- "offers": [],
- "registered_time": 1427211125.06385,
- "resources": {
- "cpus": 2.22044604925031e-16,
- "disk": 0,
- "mem": 0
- },
- "role": "*",
- "tasks": [],
- "unregistered_time": 1427212121.4797,
- "used_resources": {
- "cpus": 0,
- "disk": 0,
- "mem": 0
- },
- "user": "jenkins",
- "webui_url": ""
- },
- {
- "active": true,
- "checkpoint": true,
- "completed_tasks": [
- {
- "executor_id": "",
- "framework_id": "20150225-172748-1513192458-5050-6647-0002",
- "id": "mesos-jenkins-f30e5e34-2ef6-4993-9260-73ee3520c0a5",
- "name": "task mesos-jenkins-f30e5e34-2ef6-4993-9260-73ee3520c0a5",
- "resources": {
- "cpus": 0.2,
- "disk": 0,
- "mem": 704
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S27",
- "state": "TASK_KILLED",
- "statuses": [
- {
- "state": "TASK_RUNNING",
- "timestamp": 1427213316.78467
- },
- {
- "state": "TASK_KILLED",
- "timestamp": 1427214401.47958
- }
- ]
- }
- ],
- "failover_timeout": 0,
- "hostname": "ip-10-124-48-147.ec2.internal",
- "id": "20150225-172748-1513192458-5050-6647-0002",
- "name": "Jenkins Scheduler",
- "offered_resources": {
- "cpus": 0,
- "disk": 0,
- "mem": 0
- },
- "offers": [],
- "registered_time": 1427213305.0687,
- "resources": {
- "cpus": 0,
- "disk": 0,
- "mem": 0
- },
- "role": "*",
- "tasks": [],
- "unregistered_time": 1427214401.48033,
- "used_resources": {
- "cpus": 0,
- "disk": 0,
- "mem": 0
- },
- "user": "jenkins",
- "webui_url": ""
- },
- {
- "active": true,
- "checkpoint": true,
- "completed_tasks": [
- {
- "executor_id": "",
- "framework_id": "20150225-172748-1513192458-5050-6647-0003",
- "id": "mesos-jenkins-1fc0bbd8-f0ff-48cd-a7f7-24a9436ba6bc",
- "name": "task mesos-jenkins-1fc0bbd8-f0ff-48cd-a7f7-24a9436ba6bc",
- "resources": {
- "cpus": 0.2,
- "disk": 0,
- "mem": 704
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S27",
- "state": "TASK_KILLED",
- "statuses": [
- {
- "state": "TASK_RUNNING",
- "timestamp": 1427215879.15661
- },
- {
- "state": "TASK_KILLED",
- "timestamp": 1427217701.47961
- }
- ]
- }
- ],
- "failover_timeout": 0,
- "hostname": "ip-10-124-48-147.ec2.internal",
- "id": "20150225-172748-1513192458-5050-6647-0003",
- "name": "Jenkins Scheduler",
- "offered_resources": {
- "cpus": -8.88178419700125e-16,
- "disk": 0,
- "mem": 0
- },
- "offers": [],
- "registered_time": 1427215868.06173,
- "resources": {
- "cpus": -8.88178419700125e-16,
- "disk": 0,
- "mem": 0
- },
- "role": "*",
- "tasks": [],
- "unregistered_time": 1427217701.48035,
- "used_resources": {
- "cpus": 0,
- "disk": 0,
- "mem": 0
- },
- "user": "jenkins",
- "webui_url": ""
- },
- {
- "active": true,
- "checkpoint": true,
- "completed_tasks": [
- {
- "executor_id": "",
- "framework_id": "20150225-172748-1513192458-5050-6647-0004",
- "id": "mesos-jenkins-62b44026-843d-4813-a6a8-e95215250bb1",
- "name": "task mesos-jenkins-62b44026-843d-4813-a6a8-e95215250bb1",
- "resources": {
- "cpus": 0.2,
- "disk": 0,
- "mem": 704
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S27",
- "state": "TASK_KILLED",
- "statuses": [
- {
- "state": "TASK_RUNNING",
- "timestamp": 1427222969.79605
- },
- {
- "state": "TASK_KILLED",
- "timestamp": 1427223941.48583
- }
- ]
- }
- ],
- "failover_timeout": 0,
- "hostname": "ip-10-124-48-147.ec2.internal",
- "id": "20150225-172748-1513192458-5050-6647-0004",
- "name": "Jenkins Scheduler",
- "offered_resources": {
- "cpus": -8.88178419700125e-16,
- "disk": 0,
- "mem": 0
- },
- "offers": [],
- "registered_time": 1427222958.07464,
- "resources": {
- "cpus": -8.88178419700125e-16,
- "disk": 0,
- "mem": 0
- },
- "role": "*",
- "tasks": [],
- "unregistered_time": 1427223941.48665,
- "used_resources": {
- "cpus": 0,
- "disk": 0,
- "mem": 0
- },
- "user": "jenkins",
- "webui_url": ""
- },
- {
- "active": true,
- "checkpoint": true,
- "completed_tasks": [
- {
- "executor_id": "",
- "framework_id": "20150225-172748-1513192458-5050-6647-0005",
- "id": "mesos-jenkins-807b9b8a-3283-4e78-94e1-9dc17df4df77",
- "name": "task mesos-jenkins-807b9b8a-3283-4e78-94e1-9dc17df4df77",
- "resources": {
- "cpus": 0.2,
- "disk": 0,
- "mem": 704
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S25",
- "state": "TASK_KILLED",
- "statuses": [
- {
- "state": "TASK_RUNNING",
- "timestamp": 1427309356.80847
- },
- {
- "state": "TASK_KILLED",
- "timestamp": 1427310341.47914
- }
- ]
- }
- ],
- "failover_timeout": 0,
- "hostname": "ip-10-124-48-147.ec2.internal",
- "id": "20150225-172748-1513192458-5050-6647-0005",
- "name": "Jenkins Scheduler",
- "offered_resources": {
- "cpus": -2.22044604925031e-16,
- "disk": 0,
- "mem": 0
- },
- "offers": [],
- "registered_time": 1427309345.18029,
- "resources": {
- "cpus": -2.22044604925031e-16,
- "disk": 0,
- "mem": 0
- },
- "role": "*",
- "tasks": [],
- "unregistered_time": 1427310341.47995,
- "used_resources": {
- "cpus": 0,
- "disk": 0,
- "mem": 0
- },
- "user": "jenkins",
- "webui_url": ""
- }
- ],
- "deactivated_slaves": 0,
- "elected_time": 1427207786.0144,
- "failed_tasks": 0,
- "finished_tasks": 0,
- "flags": {
- "allocation_interval": "1secs",
- "authenticate": "false",
- "authenticate_slaves": "false",
- "authenticators": "crammd5",
- "framework_sorter": "drf",
- "help": "false",
- "hostname": "10.124.49.90",
- "initialize_driver_logging": "true",
- "log_auto_initialize": "true",
- "log_dir": "/var/log/mesos",
- "logbufsecs": "0",
- "logging_level": "INFO",
- "port": "5050",
- "quiet": "false",
- "quorum": "2",
- "recovery_slave_removal_limit": "100%",
- "registry": "replicated_log",
- "registry_fetch_timeout": "1mins",
- "registry_store_timeout": "5secs",
- "registry_strict": "false",
- "root_submissions": "true",
- "slave_reregister_timeout": "10mins",
- "user_sorter": "drf",
- "version": "false",
- "webui_dir": "/usr/share/mesos/webui",
- "whitelist": "*",
- "work_dir": "/var/lib/mesos",
- "zk": "zk://10.124.48.221:2181,10.124.49.12:2181,10.124.50.67:2181/mesos",
- "zk_session_timeout": "10secs"
- },
- "frameworks": [
- {
- "active": true,
- "checkpoint": false,
- "completed_tasks": [],
- "failover_timeout": 1200,
- "hostname": "ip-10-124-50-210.us-east-1.aws.cloud.in.here.com",
- "id": "20150203-224144-2049997834-5050-8713-0000",
- "name": "chronos-2.2.0_mesos-0.20.0-SNAPSHOT",
- "offered_resources": {
- "cpus": -8.88178419700125e-16,
- "disk": 0,
- "mem": 0
- },
- "offers": [],
- "registered_time": 1427207787.01469,
- "reregistered_time": 1427207787.0147,
- "resources": {
- "cpus": -8.88178419700125e-16,
- "disk": 0,
- "mem": 0
- },
- "role": "*",
- "tasks": [],
- "unregistered_time": 0,
- "used_resources": {
- "cpus": 0,
- "disk": 0,
- "mem": 0
- },
- "user": "root",
- "webui_url": ""
- },
- {
- "active": true,
- "checkpoint": true,
- "completed_tasks": [
- {
- "executor_id": "",
- "framework_id": "20150127-110351-1513192458-5050-8587-0000",
- "id": "test_dv_helloworld.95f49d05-c9bf-11e4-a1fc-56847afe9799",
- "name": "helloworld.dv.test",
- "resources": {
- "cpus": 0.1,
- "disk": 0,
- "mem": 32,
- "ports": "[31000-31000]"
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S19",
- "state": "TASK_KILLED",
- "statuses": []
- },
- {
- "executor_id": "",
- "framework_id": "20150127-110351-1513192458-5050-8587-0000",
- "id": "test_dv_helloworld.a40abda6-ca02-11e4-a1fc-56847afe9799",
- "name": "helloworld.dv.test",
- "resources": {
- "cpus": 0.1,
- "disk": 0,
- "mem": 32,
- "ports": "[31000-31000]"
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S19",
- "state": "TASK_KILLED",
- "statuses": []
- },
- {
- "executor_id": "",
- "framework_id": "20150127-110351-1513192458-5050-8587-0000",
- "id": "test_dv_helloworld.3946a287-ca67-11e4-a1fc-56847afe9799",
- "name": "helloworld.dv.test",
- "resources": {
- "cpus": 0.1,
- "disk": 0,
- "mem": 32,
- "ports": "[31000-31000]"
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S19",
- "state": "TASK_KILLED",
- "statuses": []
- },
- {
- "executor_id": "",
- "framework_id": "20150127-110351-1513192458-5050-8587-0000",
- "id": "test_dv_helloworld.fec0c74c-ce11-11e4-a1fc-56847afe9799",
- "name": "helloworld.dv.test",
- "resources": {
- "cpus": 0.1,
- "disk": 0,
- "mem": 32,
- "ports": "[31000-31000]"
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S19",
- "state": "TASK_KILLED",
- "statuses": []
- },
- {
- "executor_id": "",
- "framework_id": "20150127-110351-1513192458-5050-8587-0000",
- "id": "test_jenkins-master.33d4007e-cf37-11e4-a1fc-56847afe9799",
- "name": "jenkins-master.test",
- "resources": {
- "cpus": 0.3,
- "disk": 0,
- "mem": 768,
- "ports": "[31561-31561]"
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S19",
- "state": "TASK_FAILED",
- "statuses": []
- },
- {
- "executor_id": "",
- "framework_id": "20150127-110351-1513192458-5050-8587-0000",
- "id": "test_jenkins-master.359deb0f-cf37-11e4-a1fc-56847afe9799",
- "name": "jenkins-master.test",
- "resources": {
- "cpus": 0.3,
- "disk": 0,
- "mem": 768,
- "ports": "[31939-31939]"
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S19",
- "state": "TASK_FAILED",
- "statuses": []
- },
- {
- "executor_id": "",
- "framework_id": "20150127-110351-1513192458-5050-8587-0000",
- "id": "test_jenkins-master.50773d6a-cf37-11e4-a1fc-56847afe9799",
- "name": "jenkins-master.test",
- "resources": {
- "cpus": 0.3,
- "disk": 0,
- "mem": 768,
- "ports": "[31908-31908]"
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S19",
- "state": "TASK_FAILED",
- "statuses": []
- },
- {
- "executor_id": "",
- "framework_id": "20150127-110351-1513192458-5050-8587-0000",
- "id": "test_jenkins-master.638fd9ce-cf37-11e4-a1fc-56847afe9799",
- "name": "jenkins-master.test",
- "resources": {
- "cpus": 0.3,
- "disk": 0,
- "mem": 768,
- "ports": "[31658-31658]"
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S19",
- "state": "TASK_FAILED",
- "statuses": []
- },
- {
- "executor_id": "",
- "framework_id": "20150127-110351-1513192458-5050-8587-0000",
- "id": "test_jenkins-master.81fd2852-cf37-11e4-a1fc-56847afe9799",
- "name": "jenkins-master.test",
- "resources": {
- "cpus": 0.3,
- "disk": 0,
- "mem": 768,
- "ports": "[31160-31160]"
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S19",
- "state": "TASK_FAILED",
- "statuses": []
- },
- {
- "executor_id": "",
- "framework_id": "20150127-110351-1513192458-5050-8587-0000",
- "id": "test_jenkins-master.afedb77b-cf37-11e4-a1fc-56847afe9799",
- "name": "jenkins-master.test",
- "resources": {
- "cpus": 0.3,
- "disk": 0,
- "mem": 768,
- "ports": "[31185-31185]"
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S19",
- "state": "TASK_FAILED",
- "statuses": []
- },
- {
- "executor_id": "",
- "framework_id": "20150127-110351-1513192458-5050-8587-0000",
- "id": "test_jenkins-master.0243c011-cf38-11e4-a1fc-56847afe9799",
- "name": "jenkins-master.test",
- "resources": {
- "cpus": 0.3,
- "disk": 0,
- "mem": 768,
- "ports": "[31554-31554]"
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S19",
- "state": "TASK_FAILED",
- "statuses": []
- },
- {
- "executor_id": "",
- "framework_id": "20150127-110351-1513192458-5050-8587-0000",
- "id": "test_dv_helloworld.4bdb1099-d1de-11e4-a1fc-56847afe9799",
- "name": "helloworld.dv.test",
- "resources": {
- "cpus": 0.1,
- "disk": 0,
- "mem": 32,
- "ports": "[31000-31000]"
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S19",
- "state": "TASK_KILLED",
- "statuses": []
- },
- {
- "executor_id": "",
- "framework_id": "20150127-110351-1513192458-5050-8587-0000",
- "id": "sdp_shared_jenkins-master.eb8f2863-c9a2-11e4-a1fc-56847afe9799",
- "name": "jenkins-master.shared.sdp",
- "resources": {
- "cpus": 0.3,
- "disk": 0,
- "mem": 768,
- "ports": "[31458-31458]"
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S27",
- "state": "TASK_FAILED",
- "statuses": []
- },
- {
- "executor_id": "",
- "framework_id": "20150127-110351-1513192458-5050-8587-0000",
- "id": "test_dv_helloworld.c7865efb-cd05-11e4-a1fc-56847afe9799",
- "name": "helloworld.dv.test",
- "resources": {
- "cpus": 0.1,
- "disk": 0,
- "mem": 32,
- "ports": "[31000-31000]"
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S27",
- "state": "TASK_KILLED",
- "statuses": []
- },
- {
- "executor_id": "",
- "framework_id": "20150127-110351-1513192458-5050-8587-0000",
- "id": "test_jenkins-master.37684ad0-cf37-11e4-a1fc-56847afe9799",
- "name": "jenkins-master.test",
- "resources": {
- "cpus": 0.3,
- "disk": 0,
- "mem": 768,
- "ports": "[31223-31223]"
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S27",
- "state": "TASK_FAILED",
- "statuses": []
- },
- {
- "executor_id": "",
- "framework_id": "20150127-110351-1513192458-5050-8587-0000",
- "id": "test_jenkins-master.3c2e3752-cf37-11e4-a1fc-56847afe9799",
- "name": "jenkins-master.test",
- "resources": {
- "cpus": 0.3,
- "disk": 0,
- "mem": 768,
- "ports": "[31703-31703]"
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S27",
- "state": "TASK_FAILED",
- "statuses": []
- },
- {
- "executor_id": "",
- "framework_id": "20150127-110351-1513192458-5050-8587-0000",
- "id": "test_jenkins-master.405b3f34-cf37-11e4-a1fc-56847afe9799",
- "name": "jenkins-master.test",
- "resources": {
- "cpus": 0.3,
- "disk": 0,
- "mem": 768,
- "ports": "[31996-31996]"
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S27",
- "state": "TASK_FAILED",
- "statuses": []
- },
- {
- "executor_id": "",
- "framework_id": "20150127-110351-1513192458-5050-8587-0000",
- "id": "test_jenkins-master.44886e26-cf37-11e4-a1fc-56847afe9799",
- "name": "jenkins-master.test",
- "resources": {
- "cpus": 0.3,
- "disk": 0,
- "mem": 768,
- "ports": "[31141-31141]"
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S27",
- "state": "TASK_FAILED",
- "statuses": []
- },
- {
- "executor_id": "",
- "framework_id": "20150127-110351-1513192458-5050-8587-0000",
- "id": "test_jenkins-master.54a4936b-cf37-11e4-a1fc-56847afe9799",
- "name": "jenkins-master.test",
- "resources": {
- "cpus": 0.3,
- "disk": 0,
- "mem": 768,
- "ports": "[31109-31109]"
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S27",
- "state": "TASK_FAILED",
- "statuses": []
- },
- {
- "executor_id": "",
- "framework_id": "20150127-110351-1513192458-5050-8587-0000",
- "id": "test_jenkins-master.58d1e96c-cf37-11e4-a1fc-56847afe9799",
- "name": "jenkins-master.test",
- "resources": {
- "cpus": 0.3,
- "disk": 0,
- "mem": 768,
- "ports": "[31110-31110]"
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S27",
- "state": "TASK_FAILED",
- "statuses": []
- },
- {
- "executor_id": "",
- "framework_id": "20150127-110351-1513192458-5050-8587-0000",
- "id": "test_jenkins-master.5d97fcfd-cf37-11e4-a1fc-56847afe9799",
- "name": "jenkins-master.test",
- "resources": {
- "cpus": 0.3,
- "disk": 0,
- "mem": 768,
- "ports": "[31167-31167]"
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S27",
- "state": "TASK_FAILED",
- "statuses": []
- },
- {
- "executor_id": "",
- "framework_id": "20150127-110351-1513192458-5050-8587-0000",
- "id": "test_jenkins-master.6986f34f-cf37-11e4-a1fc-56847afe9799",
- "name": "jenkins-master.test",
- "resources": {
- "cpus": 0.3,
- "disk": 0,
- "mem": 768,
- "ports": "[31158-31158]"
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S27",
- "state": "TASK_FAILED",
- "statuses": []
- },
- {
- "executor_id": "",
- "framework_id": "20150127-110351-1513192458-5050-8587-0000",
- "id": "test_jenkins-master.790a33f1-cf37-11e4-a1fc-56847afe9799",
- "name": "jenkins-master.test",
- "resources": {
- "cpus": 0.3,
- "disk": 0,
- "mem": 768,
- "ports": "[31696-31696]"
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S27",
- "state": "TASK_FAILED",
- "statuses": []
- },
- {
- "executor_id": "",
- "framework_id": "20150127-110351-1513192458-5050-8587-0000",
- "id": "test_jenkins-master.8c2149b3-cf37-11e4-a1fc-56847afe9799",
- "name": "jenkins-master.test",
- "resources": {
- "cpus": 0.3,
- "disk": 0,
- "mem": 768,
- "ports": "[31258-31258]"
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S27",
- "state": "TASK_FAILED",
- "statuses": []
- },
- {
- "executor_id": "",
- "framework_id": "20150127-110351-1513192458-5050-8587-0000",
- "id": "test_jenkins-master.9c3d47e4-cf37-11e4-a1fc-56847afe9799",
- "name": "jenkins-master.test",
- "resources": {
- "cpus": 0.3,
- "disk": 0,
- "mem": 768,
- "ports": "[31308-31308]"
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S27",
- "state": "TASK_FAILED",
- "statuses": []
- },
- {
- "executor_id": "",
- "framework_id": "20150127-110351-1513192458-5050-8587-0000",
- "id": "test_jenkins-master.a06a01a6-cf37-11e4-a1fc-56847afe9799",
- "name": "jenkins-master.test",
- "resources": {
- "cpus": 0.3,
- "disk": 0,
- "mem": 768,
- "ports": "[31252-31252]"
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S27",
- "state": "TASK_FAILED",
- "statuses": []
- },
- {
- "executor_id": "",
- "framework_id": "20150127-110351-1513192458-5050-8587-0000",
- "id": "test_jenkins-master.fa821fbd-cf37-11e4-a1fc-56847afe9799",
- "name": "jenkins-master.test",
- "resources": {
- "cpus": 0.3,
- "disk": 0,
- "mem": 768,
- "ports": "[31111-31111]"
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S27",
- "state": "TASK_FAILED",
- "statuses": []
- },
- {
- "executor_id": "",
- "framework_id": "20150127-110351-1513192458-5050-8587-0000",
- "id": "test_jenkins-master.fbb39ade-cf37-11e4-a1fc-56847afe9799",
- "name": "jenkins-master.test",
- "resources": {
- "cpus": 0.3,
- "disk": 0,
- "mem": 768,
- "ports": "[31658-31658]"
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S27",
- "state": "TASK_FAILED",
- "statuses": []
- },
- {
- "executor_id": "",
- "framework_id": "20150127-110351-1513192458-5050-8587-0000",
- "id": "test_jenkins-master.ffe0f0e0-cf37-11e4-a1fc-56847afe9799",
- "name": "jenkins-master.test",
- "resources": {
- "cpus": 0.3,
- "disk": 0,
- "mem": 768,
- "ports": "[31022-31022]"
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S27",
- "state": "TASK_FAILED",
- "statuses": []
- },
- {
- "executor_id": "",
- "framework_id": "20150127-110351-1513192458-5050-8587-0000",
- "id": "test_jenkins-master.04a68f42-cf38-11e4-a1fc-56847afe9799",
- "name": "jenkins-master.test",
- "resources": {
- "cpus": 0.3,
- "disk": 0,
- "mem": 768,
- "ports": "[31583-31583]"
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S27",
- "state": "TASK_FAILED",
- "statuses": []
- },
- {
- "executor_id": "",
- "framework_id": "20150127-110351-1513192458-5050-8587-0000",
- "id": "test_jenkins-master.4ce2cc09-cf37-11e4-a1fc-56847afe9799",
- "name": "jenkins-master.test",
- "resources": {
- "cpus": 0.3,
- "disk": 0,
- "mem": 768,
- "ports": "[31449-31449]"
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S25",
- "state": "TASK_FAILED",
- "statuses": []
- },
- {
- "executor_id": "",
- "framework_id": "20150127-110351-1513192458-5050-8587-0000",
- "id": "test_jenkins-master.a792e469-cf37-11e4-a1fc-56847afe9799",
- "name": "jenkins-master.test",
- "resources": {
- "cpus": 0.3,
- "disk": 0,
- "mem": 768,
- "ports": "[31299-31299]"
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S25",
- "state": "TASK_FAILED",
- "statuses": []
- },
- {
- "executor_id": "",
- "framework_id": "20150127-110351-1513192458-5050-8587-0000",
- "id": "test_jenkins-master.fe166a0f-cf37-11e4-a1fc-56847afe9799",
- "name": "jenkins-master.test",
- "resources": {
- "cpus": 0.3,
- "disk": 0,
- "mem": 768,
- "ports": "[31383-31383]"
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S25",
- "state": "TASK_FAILED",
- "statuses": []
- },
- {
- "executor_id": "",
- "framework_id": "20150127-110351-1513192458-5050-8587-0000",
- "id": "test_jenkins-master.0670c7f3-cf38-11e4-a1fc-56847afe9799",
- "name": "jenkins-master.test",
- "resources": {
- "cpus": 0.3,
- "disk": 0,
- "mem": 768,
- "ports": "[31607-31607]"
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S25",
- "state": "TASK_FAILED",
- "statuses": []
- },
- {
- "executor_id": "",
- "framework_id": "20150127-110351-1513192458-5050-8587-0000",
- "id": "test_dev_frontend.3950b432-d234-11e4-bc5e-56847afe9799",
- "name": "frontend.dev.test",
- "resources": {
- "cpus": 0.2,
- "disk": 0,
- "mem": 1024,
- "ports": "[31980-31980, 31000-31002]"
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S21",
- "state": "TASK_KILLED",
- "statuses": [
- {
- "state": "TASK_RUNNING",
- "timestamp": 1427208248.01184
- },
- {
- "state": "TASK_KILLED",
- "timestamp": 1427208510.81702
- }
- ]
- },
- {
- "executor_id": "",
- "framework_id": "20150127-110351-1513192458-5050-8587-0000",
- "id": "test_dv_helloworld.c3a7d253-d241-11e4-bc5e-56847afe9799",
- "name": "helloworld.dv.test",
- "resources": {
- "cpus": 0.1,
- "disk": 0,
- "mem": 32,
- "ports": "[31584-31584]"
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S21",
- "state": "TASK_KILLED",
- "statuses": [
- {
- "state": "TASK_RUNNING",
- "timestamp": 1427214063.25571
- },
- {
- "state": "TASK_KILLED",
- "timestamp": 1427214249.31952
- }
- ]
- },
- {
- "executor_id": "",
- "framework_id": "20150127-110351-1513192458-5050-8587-0000",
- "id": "test_dv_helloworld.d7c6b3c4-d244-11e4-bc5e-56847afe9799",
- "name": "helloworld.dv.test",
- "resources": {
- "cpus": 0.1,
- "disk": 0,
- "mem": 32,
- "ports": "[31000-31000]"
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S27",
- "state": "TASK_KILLED",
- "statuses": [
- {
- "state": "TASK_RUNNING",
- "timestamp": 1427215390.066
- },
- {
- "state": "TASK_KILLED",
- "timestamp": 1427215571.78983
- }
- ]
- },
- {
- "executor_id": "",
- "framework_id": "20150127-110351-1513192458-5050-8587-0000",
- "id": "test_dev_frontend.a0f3f185-d2e6-11e4-bc5e-56847afe9799",
- "name": "frontend.dev.test",
- "resources": {
- "cpus": 0.2,
- "disk": 0,
- "mem": 1024,
- "ports": "[31980-31980, 31000-31002]"
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S25",
- "state": "TASK_KILLED",
- "statuses": [
- {
- "state": "TASK_RUNNING",
- "timestamp": 1427285021.3087
- },
- {
- "state": "TASK_KILLED",
- "timestamp": 1427285124.9842
- }
- ]
- }
- ],
- "failover_timeout": 604800,
- "hostname": "ip-10-124-49-90.ec2.internal",
- "id": "20150127-110351-1513192458-5050-8587-0000",
- "name": "marathon",
- "offered_resources": {
- "cpus": -2.44249065417534e-15,
- "disk": 0,
- "mem": 0
- },
- "offers": [],
- "registered_time": 1427207786.075,
- "reregistered_time": 1427289460.06666,
- "resources": {
- "cpus": 0.299999999999998,
- "disk": 0,
- "mem": 768,
- "ports": "[31583-31583]"
- },
- "role": "*",
- "tasks": [
- {
- "executor_id": "",
- "framework_id": "20150127-110351-1513192458-5050-8587-0000",
- "id": "sdp_shared_jenkins-master.ed596114-c9a2-11e4-a1fc-56847afe9799",
- "name": "jenkins-master.shared.sdp",
- "resources": {
- "cpus": 0.3,
- "disk": 0,
- "mem": 768,
- "ports": "[31583-31583]"
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S21",
- "state": "TASK_RUNNING",
- "statuses": [
- {
- "state": "TASK_RUNNING",
- "timestamp": 1426266239.30745
- }
- ]
- }
- ],
- "unregistered_time": 0,
- "used_resources": {
- "cpus": 0.3,
- "disk": 0,
- "mem": 768,
- "ports": "[31583-31583]"
- },
- "user": "root",
- "webui_url": ""
- }
- ],
- "git_sha": "2ae1ba91e64f92ec71d327e10e6ba9e8ad5477e8",
- "git_tag": "0.21.1",
- "hostname": "10.124.49.90",
- "id": "20150225-172748-1513192458-5050-6647",
- "killed_tasks": 12,
- "leader": "master@10.124.49.90:5050",
- "log_dir": "/var/log/mesos",
- "lost_tasks": 0,
- "orphan_tasks": [],
- "pid": "master@10.124.49.90:5050",
- "slaves": [
- {
- "attributes": {
- "az": "us-east-1b",
- "instance_id": "i-496a92b3",
- "instance_type": "c3.large"
- },
- "hostname": "10.124.49.190",
- "id": "20150225-172748-1513192458-5050-6647-S0",
- "pid": "slave(1)@10.124.49.190:5051",
- "registered_time": 1427207786.83581,
- "resources": {
- "cpus": 2,
- "disk": 3966,
- "mem": 2744,
- "ports": "[31000-32000]"
- }
- },
- {
- "attributes": {
- "az": "us-east-1c",
- "instance_id": "i-b57fe25a",
- "instance_type": "c3.large"
- },
- "hostname": "10.124.50.153",
- "id": "20150225-172738-2049997834-5050-23289-S27",
- "pid": "slave(1)@10.124.50.153:5051",
- "registered_time": 1427207786.63308,
- "reregistered_time": 1427207786.63309,
- "resources": {
- "cpus": 2,
- "disk": 3966,
- "mem": 2744,
- "ports": "[31000-32000]"
- }
- },
- {
- "attributes": {
- "az": "us-east-1c",
- "instance_id": "i-2467dccb",
- "instance_type": "c3.large"
- },
- "hostname": "10.124.50.12",
- "id": "20150225-172748-1513192458-5050-6647-S2",
- "pid": "slave(1)@10.124.50.12:5051",
- "registered_time": 1427399742.96888,
- "resources": {
- "cpus": 2,
- "disk": 3966,
- "mem": 2744,
- "ports": "[31000-32000]"
- }
- },
- {
- "attributes": {
- "az": "us-east-1a",
- "instance_id": "i-b33a5842",
- "instance_type": "c3.large"
- },
- "hostname": "10.124.48.198",
- "id": "20150225-172738-2049997834-5050-23289-S25",
- "pid": "slave(1)@10.124.48.198:5051",
- "registered_time": 1427207786.94212,
- "reregistered_time": 1427207786.94213,
- "resources": {
- "cpus": 2,
- "disk": 3966,
- "mem": 2744,
- "ports": "[31000-32000]"
- }
- },
- {
- "attributes": {
- "az": "us-east-1a",
- "instance_id": "i-9bdcde6a",
- "instance_type": "c3.large"
- },
- "hostname": "10.124.48.147",
- "id": "20150225-172738-2049997834-5050-23289-S21",
- "pid": "slave(1)@10.124.48.147:5051",
- "registered_time": 1427207786.33104,
- "reregistered_time": 1427207786.33115,
- "resources": {
- "cpus": 2,
- "disk": 3966,
- "mem": 2744,
- "ports": "[31000-32000]"
- }
- }
- ],
- "staged_tasks": 11,
- "start_time": 1424885268.34093,
- "started_tasks": 0,
- "unregistered_frameworks": [
- "20150225-172738-2049997834-5050-23289-0433",
- "20150225-172738-2049997834-5050-23289-0433",
- "20150225-172738-2049997834-5050-23289-0433",
- "20150225-172738-2049997834-5050-23289-0433"
- ],
- "version": "0.21.1"
-}
\ No newline at end of file
diff --git a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/resources/issue_24.json b/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/resources/issue_24.json
deleted file mode 100644
index 5e55160..0000000
--- a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/resources/issue_24.json
+++ /dev/null
@@ -1,322 +0,0 @@
-{
- "project": {
- "@key": "Signaturengruppe ars.hydr.",
- "template": [
- {
- "@key": "foo",
- "collection": [
- "Autobiographica",
- "DigiWunschbuch",
- "Itineraria",
- "Manuscriptae",
- "Maps",
- "Mathematica",
- "Nordamericana",
- "Wissenschaftsgeschichte",
- "Sibirica",
- "Varia",
- "Zoologica"
- ]
- },
- {
- "@key": "Digitalisierungsprojekt_ars_hydr",
- "collection": [
- "Autobiographica",
- "DigiWunschbuch",
- "Itineraria",
- "Manuscriptae",
- "Maps",
- "Mathematica",
- "Nordamericana",
- "Wissenschaftsgeschichte",
- "Sibirica",
- "Varia",
- "Zoologica"
- ]
- }
- ],
- "field": [
- {
- "@key": "Artist",
- "required": "false",
- "source": "werk",
- "option": [
- {
- "@label": "Nieders?chsische Staats- und Universit?tsbibliothek G?ttingen, Germany",
- "$": "SUB"
- },
- {
- "@label": "DIGIZEITSCHRIFTEN e.V., Nieders?chsische Staats- und Universit?tsbibliothek G?ttingen, Germany",
- "$": "DIGIZEIT"
- }
- ],
- "ughbinding": "false"
- },
- {
- "@key": "Schrifttyp",
- "required": "false",
- "source": "werk",
- "option": [
- {
- "@label": "gemischt",
- "$": "gemischt"
- },
- {
- "@label": "Fraktur",
- "$": "Fraktur"
- },
- {
- "@label": "Antiqua",
- "$": "Antiqua"
- }
- ],
- "ughbinding": "false"
- },
- {
- "@key": "Titel",
- "required": "true",
- "source": "vorlage",
- "ughbinding": "true",
- "insertionLevel": "topstruct"
- },
- {
- "@key": "Titel (Sortierung)",
- "required": "true",
- "source": "vorlage",
- "ughbinding": "true",
- "insertionLevel": "topstruct"
- },
- {
- "@key": "Titel",
- "required": "true",
- "source": "vorlage",
- "ughbinding": "true",
- "insertionLevel": "topstruct"
- },
- {
- "@key": "Titel (Sortierung)",
- "required": "true",
- "source": "vorlage",
- "ughbinding": "true",
- "insertionLevel": "topstruct"
- },
- {
- "@key": "Autoren",
- "required": "false",
- "source": "vorlage",
- "ughbinding": "true",
- "insertionLevel": "topstruct"
- },
- {
- "@key": "ATS",
- "required": "false",
- "source": "werk",
- "ughbinding": "true",
- "insertionLevel": "topstruct"
- },
- {
- "@key": "TSL",
- "required": "false",
- "source": "werk",
- "ughbinding": "true",
- "insertionLevel": "topstruct"
- },
- {
- "@key": "PPN analog c-Satz",
- "required": "true",
- "source": "vorlage",
- "ughbinding": "true",
- "insertionLevel": "topstruct"
- },
- {
- "@key": "PPN digital c-Satz",
- "required": "true",
- "source": "werk",
- "ughbinding": "true",
- "insertionLevel": "topstruct"
- },
- {
- "@key": "PPN analog a-Satz",
- "required": "true",
- "source": "vorlage",
- "ughbinding": "true",
- "insertionLevel": "topstruct"
- },
- {
- "@key": "PPN digital a-Satz",
- "required": "true",
- "source": "werk",
- "ughbinding": "true",
- "insertionLevel": "topstruct"
- },
- {
- "@key": "PPN analog b-Satz",
- "required": "true",
- "source": "vorlage",
- "ughbinding": "true",
- "insertionLevel": "topstruct"
- },
- {
- "@key": "PPN digital b-Satz",
- "required": "true",
- "source": "werk",
- "ughbinding": "true",
- "insertionLevel": "topstruct"
- },
- {
- "@key": "ISSN",
- "required": "true",
- "source": "werk",
- "ughbinding": "true",
- "insertionLevel": "topstruct"
- },
- {
- "@key": "PPN analog Band",
- "required": "true",
- "source": "vorlage",
- "ughbinding": "true",
- "insertionLevel": "firstchild"
- },
- {
- "@key": "PPN digital Band",
- "required": "true",
- "source": "werk",
- "ughbinding": "true",
- "insertionLevel": "firstchild"
- },
- {
- "@key": "Titel (Band)",
- "required": "true",
- "source": "vorlage",
- "ughbinding": "true",
- "insertionLevel": "firstchild"
- },
- {
- "@key": "Titel (Band) (Sortierung)",
- "required": "true",
- "source": "vorlage",
- "ughbinding": "true",
- "insertionLevel": "firstchild"
- },
- {
- "@key": "Autoren (Band)",
- "required": "false",
- "source": "vorlage",
- "ughbinding": "true",
- "insertionLevel": "firstchild"
- },
- {
- "@key": "Bandnummer",
- "required": "false",
- "source": "vorlage",
- "ughbinding": "true",
- "insertionLevel": "firstchild"
- },
- {
- "@key": "Nummer (Sortierung)",
- "required": "false",
- "source": "vorlage",
- "ughbinding": "true",
- "insertionLevel": "firstchild"
- },
- {
- "@key": "Nummer (Benennung)",
- "required": "true",
- "source": "vorlage",
- "ughbinding": "false"
- },
- {
- "@key": "PPN analog f-Satz",
- "required": "true",
- "source": "vorlage",
- "ughbinding": "true",
- "insertionLevel": "firstchild"
- },
- {
- "@key": "PPN digital f-Satz",
- "required": "true",
- "source": "werk",
- "ughbinding": "true",
- "insertionLevel": "firstchild"
- },
- {
- "@key": "Erscheinungsort",
- "required": "false",
- "source": "vorlage",
- "ughbinding": "true",
- "insertionLevel": "topstruct"
- },
- {
- "@key": "Erscheinungsjahr",
- "required": "false",
- "source": "vorlage",
- "ughbinding": "true",
- "insertionLevel": "topstruct"
- },
- {
- "@key": "Erscheinungsjahr",
- "required": "false",
- "source": "vorlage",
- "ughbinding": "true",
- "insertionLevel": "firstchild"
- },
- {
- "@key": "Verlag",
- "required": "false",
- "source": "vorlage",
- "ughbinding": "true",
- "insertionLevel": "firstchild"
- },
- {
- "@key": "Verlag",
- "required": "false",
- "source": "vorlage",
- "ughbinding": "true",
- "insertionLevel": "topstruct"
- },
- {
- "@key": "Signatur",
- "required": "false",
- "source": "vorlage",
- "ughbinding": "true",
- "insertionLevel": "boundbook"
- },
- {
- "@key": "Farbtiefe",
- "required": "true",
- "source": "werk",
- "option": [
- {
- "@label": "Bitonal",
- "$": "Bitonal"
- },
- {
- "@label": "Farbe",
- "$": "Farbe"
- },
- {
- "@label": "Graustufen",
- "$": "Graustufen"
- }
- ],
- "ughbinding": "false"
- },
- {
- "@key": "?ffnungswinkel",
- "required": "true",
- "source": "werk",
- "option": [
- {
- "@label": "180?",
- "$": "180?"
- },
- {
- "@label": "90?",
- "$": "90?"
- }
- ],
- "ughbinding": "false"
- }
- ]
- }
-}
\ No newline at end of file
diff --git a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/resources/issue_76.json b/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/resources/issue_76.json
deleted file mode 100644
index 934026a..0000000
--- a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/resources/issue_76.json
+++ /dev/null
@@ -1,1258 +0,0 @@
-{
- "activated_slaves": 5,
- "build_date": "2015-01-09 02:25:21",
- "build_time": 1420770321,
- "build_user": "root",
- "completed_frameworks": [
- {
- "active": true,
- "checkpoint": true,
- "completed_tasks": [
- {
- "executor_id": "",
- "framework_id": "20150225-172738-2049997834-5050-23289-0433",
- "id": "mesos-jenkins-172c6f74-12bc-44fe-849a-ad902ddc2b64",
- "name": "task mesos-jenkins-172c6f74-12bc-44fe-849a-ad902ddc2b64",
- "resources": {
- "cpus": 0.2,
- "disk": 0,
- "mem": 704
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S19",
- "state": "TASK_KILLED",
- "statuses": [
- {
- "state": "TASK_RUNNING",
- "timestamp": 1427206149.38254
- },
- {
- "state": "TASK_KILLED",
- "timestamp": 1427207981.47819
- }
- ]
- }
- ],
- "failover_timeout": 0,
- "hostname": "ip-10-124-48-147.ec2.internal",
- "id": "20150225-172738-2049997834-5050-23289-0433",
- "name": "Jenkins Scheduler",
- "offered_resources": {
- "cpus": -2.22044604925031e-16,
- "disk": 0,
- "mem": 0
- },
- "offers": [],
- "registered_time": 1427207787.01579,
- "reregistered_time": 1427207787.0158,
- "resources": {
- "cpus": -2.22044604925031e-16,
- "disk": 0,
- "mem": 0
- },
- "role": "*",
- "tasks": [],
- "unregistered_time": 1427207981.47898,
- "used_resources": {
- "cpus": 0,
- "disk": 0,
- "mem": 0
- },
- "user": "jenkins",
- "webui_url": ""
- },
- {
- "active": true,
- "checkpoint": true,
- "completed_tasks": [
- {
- "executor_id": "",
- "framework_id": "20150225-172748-1513192458-5050-6647-0000",
- "id": "mesos-jenkins-cd18b433-e2ee-4a4e-875b-6ea82d90a53a",
- "name": "task mesos-jenkins-cd18b433-e2ee-4a4e-875b-6ea82d90a53a",
- "resources": {
- "cpus": 0.2,
- "disk": 0,
- "mem": 704
- },
- "slave_id": "20150225-172748-1513192458-5050-6647-S0",
- "state": "TASK_KILLED",
- "statuses": [
- {
- "state": "TASK_RUNNING",
- "timestamp": 1427209005.01389
- },
- {
- "state": "TASK_KILLED",
- "timestamp": 1427209961.51519
- }
- ]
- },
- {
- "executor_id": "",
- "framework_id": "20150225-172748-1513192458-5050-6647-0000",
- "id": "mesos-jenkins-66fca7c0-88f7-4a1a-9796-a6de2e337b0a",
- "name": "task mesos-jenkins-66fca7c0-88f7-4a1a-9796-a6de2e337b0a",
- "resources": {
- "cpus": 0.2,
- "disk": 0,
- "mem": 704
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S25",
- "state": "TASK_KILLED",
- "statuses": [
- {
- "state": "TASK_RUNNING",
- "timestamp": 1427209025.84128
- },
- {
- "state": "TASK_KILLED",
- "timestamp": 1427211101.4792
- }
- ]
- }
- ],
- "failover_timeout": 0,
- "hostname": "ip-10-124-48-147.ec2.internal",
- "id": "20150225-172748-1513192458-5050-6647-0000",
- "name": "Jenkins Scheduler",
- "offered_resources": {
- "cpus": -8.88178419700125e-16,
- "disk": 0,
- "mem": 0
- },
- "offers": [],
- "registered_time": 1427208985.06716,
- "resources": {
- "cpus": -8.88178419700125e-16,
- "disk": 0,
- "mem": 0
- },
- "role": "*",
- "tasks": [],
- "unregistered_time": 1427211101.48013,
- "used_resources": {
- "cpus": 0,
- "disk": 0,
- "mem": 0
- },
- "user": "jenkins",
- "webui_url": ""
- },
- {
- "active": true,
- "checkpoint": true,
- "completed_tasks": [
- {
- "executor_id": "",
- "framework_id": "20150225-172748-1513192458-5050-6647-0001",
- "id": "mesos-jenkins-258ad47c-85bf-4fe0-b7c4-4f0cc70f2998",
- "name": "task mesos-jenkins-258ad47c-85bf-4fe0-b7c4-4f0cc70f2998",
- "resources": {
- "cpus": 0.2,
- "disk": 0,
- "mem": 704
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S27",
- "state": "TASK_KILLED",
- "statuses": [
- {
- "state": "TASK_RUNNING",
- "timestamp": 1427211139.85003
- },
- {
- "state": "TASK_KILLED",
- "timestamp": 1427212121.47896
- }
- ]
- }
- ],
- "failover_timeout": 0,
- "hostname": "ip-10-124-48-147.ec2.internal",
- "id": "20150225-172748-1513192458-5050-6647-0001",
- "name": "Jenkins Scheduler",
- "offered_resources": {
- "cpus": 2.22044604925031e-16,
- "disk": 0,
- "mem": 0
- },
- "offers": [],
- "registered_time": 1427211125.06385,
- "resources": {
- "cpus": 2.22044604925031e-16,
- "disk": 0,
- "mem": 0
- },
- "role": "*",
- "tasks": [],
- "unregistered_time": 1427212121.4797,
- "used_resources": {
- "cpus": 0,
- "disk": 0,
- "mem": 0
- },
- "user": "jenkins",
- "webui_url": ""
- },
- {
- "active": true,
- "checkpoint": true,
- "completed_tasks": [
- {
- "executor_id": "",
- "framework_id": "20150225-172748-1513192458-5050-6647-0002",
- "id": "mesos-jenkins-f30e5e34-2ef6-4993-9260-73ee3520c0a5",
- "name": "task mesos-jenkins-f30e5e34-2ef6-4993-9260-73ee3520c0a5",
- "resources": {
- "cpus": 0.2,
- "disk": 0,
- "mem": 704
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S27",
- "state": "TASK_KILLED",
- "statuses": [
- {
- "state": "TASK_RUNNING",
- "timestamp": 1427213316.78467
- },
- {
- "state": "TASK_KILLED",
- "timestamp": 1427214401.47958
- }
- ]
- }
- ],
- "failover_timeout": 0,
- "hostname": "ip-10-124-48-147.ec2.internal",
- "id": "20150225-172748-1513192458-5050-6647-0002",
- "name": "Jenkins Scheduler",
- "offered_resources": {
- "cpus": 0,
- "disk": 0,
- "mem": 0
- },
- "offers": [],
- "registered_time": 1427213305.0687,
- "resources": {
- "cpus": 0,
- "disk": 0,
- "mem": 0
- },
- "role": "*",
- "tasks": [],
- "unregistered_time": 1427214401.48033,
- "used_resources": {
- "cpus": 0,
- "disk": 0,
- "mem": 0
- },
- "user": "jenkins",
- "webui_url": ""
- },
- {
- "active": true,
- "checkpoint": true,
- "completed_tasks": [
- {
- "executor_id": "",
- "framework_id": "20150225-172748-1513192458-5050-6647-0003",
- "id": "mesos-jenkins-1fc0bbd8-f0ff-48cd-a7f7-24a9436ba6bc",
- "name": "task mesos-jenkins-1fc0bbd8-f0ff-48cd-a7f7-24a9436ba6bc",
- "resources": {
- "cpus": 0.2,
- "disk": 0,
- "mem": 704
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S27",
- "state": "TASK_KILLED",
- "statuses": [
- {
- "state": "TASK_RUNNING",
- "timestamp": 1427215879.15661
- },
- {
- "state": "TASK_KILLED",
- "timestamp": 1427217701.47961
- }
- ]
- }
- ],
- "failover_timeout": 0,
- "hostname": "ip-10-124-48-147.ec2.internal",
- "id": "20150225-172748-1513192458-5050-6647-0003",
- "name": "Jenkins Scheduler",
- "offered_resources": {
- "cpus": -8.88178419700125e-16,
- "disk": 0,
- "mem": 0
- },
- "offers": [],
- "registered_time": 1427215868.06173,
- "resources": {
- "cpus": -8.88178419700125e-16,
- "disk": 0,
- "mem": 0
- },
- "role": "*",
- "tasks": [],
- "unregistered_time": 1427217701.48035,
- "used_resources": {
- "cpus": 0,
- "disk": 0,
- "mem": 0
- },
- "user": "jenkins",
- "webui_url": ""
- },
- {
- "active": true,
- "checkpoint": true,
- "completed_tasks": [
- {
- "executor_id": "",
- "framework_id": "20150225-172748-1513192458-5050-6647-0004",
- "id": "mesos-jenkins-62b44026-843d-4813-a6a8-e95215250bb1",
- "name": "task mesos-jenkins-62b44026-843d-4813-a6a8-e95215250bb1",
- "resources": {
- "cpus": 0.2,
- "disk": 0,
- "mem": 704
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S27",
- "state": "TASK_KILLED",
- "statuses": [
- {
- "state": "TASK_RUNNING",
- "timestamp": 1427222969.79605
- },
- {
- "state": "TASK_KILLED",
- "timestamp": 1427223941.48583
- }
- ]
- }
- ],
- "failover_timeout": 0,
- "hostname": "ip-10-124-48-147.ec2.internal",
- "id": "20150225-172748-1513192458-5050-6647-0004",
- "name": "Jenkins Scheduler",
- "offered_resources": {
- "cpus": -8.88178419700125e-16,
- "disk": 0,
- "mem": 0
- },
- "offers": [],
- "registered_time": 1427222958.07464,
- "resources": {
- "cpus": -8.88178419700125e-16,
- "disk": 0,
- "mem": 0
- },
- "role": "*",
- "tasks": [],
- "unregistered_time": 1427223941.48665,
- "used_resources": {
- "cpus": 0,
- "disk": 0,
- "mem": 0
- },
- "user": "jenkins",
- "webui_url": ""
- },
- {
- "active": true,
- "checkpoint": true,
- "completed_tasks": [
- {
- "executor_id": "",
- "framework_id": "20150225-172748-1513192458-5050-6647-0005",
- "id": "mesos-jenkins-807b9b8a-3283-4e78-94e1-9dc17df4df77",
- "name": "task mesos-jenkins-807b9b8a-3283-4e78-94e1-9dc17df4df77",
- "resources": {
- "cpus": 0.2,
- "disk": 0,
- "mem": 704
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S25",
- "state": "TASK_KILLED",
- "statuses": [
- {
- "state": "TASK_RUNNING",
- "timestamp": 1427309356.80847
- },
- {
- "state": "TASK_KILLED",
- "timestamp": 1427310341.47914
- }
- ]
- }
- ],
- "failover_timeout": 0,
- "hostname": "ip-10-124-48-147.ec2.internal",
- "id": "20150225-172748-1513192458-5050-6647-0005",
- "name": "Jenkins Scheduler",
- "offered_resources": {
- "cpus": -2.22044604925031e-16,
- "disk": 0,
- "mem": 0
- },
- "offers": [],
- "registered_time": 1427309345.18029,
- "resources": {
- "cpus": -2.22044604925031e-16,
- "disk": 0,
- "mem": 0
- },
- "role": "*",
- "tasks": [],
- "unregistered_time": 1427310341.47995,
- "used_resources": {
- "cpus": 0,
- "disk": 0,
- "mem": 0
- },
- "user": "jenkins",
- "webui_url": ""
- }
- ],
- "deactivated_slaves": 0,
- "elected_time": 1427207786.0144,
- "failed_tasks": 0,
- "finished_tasks": 0,
- "flags": {
- "allocation_interval": "1secs",
- "authenticate": "false",
- "authenticate_slaves": "false",
- "authenticators": "crammd5",
- "framework_sorter": "drf",
- "help": "false",
- "hostname": "10.124.49.90",
- "initialize_driver_logging": "true",
- "log_auto_initialize": "true",
- "log_dir": "/var/log/mesos",
- "logbufsecs": "0",
- "logging_level": "INFO",
- "port": "5050",
- "quiet": "false",
- "quorum": "2",
- "recovery_slave_removal_limit": "100%",
- "registry": "replicated_log",
- "registry_fetch_timeout": "1mins",
- "registry_store_timeout": "5secs",
- "registry_strict": "false",
- "root_submissions": "true",
- "slave_reregister_timeout": "10mins",
- "user_sorter": "drf",
- "version": "false",
- "webui_dir": "/usr/share/mesos/webui",
- "whitelist": "*",
- "work_dir": "/var/lib/mesos",
- "zk": "zk://10.124.48.221:2181,10.124.49.12:2181,10.124.50.67:2181/mesos",
- "zk_session_timeout": "10secs"
- },
- "frameworks": [
- {
- "active": true,
- "checkpoint": false,
- "completed_tasks": [],
- "failover_timeout": 1200,
- "hostname": "ip-10-124-50-210.us-east-1.aws.cloud.in.here.com",
- "id": "20150203-224144-2049997834-5050-8713-0000",
- "name": "chronos-2.2.0_mesos-0.20.0-SNAPSHOT",
- "offered_resources": {
- "cpus": -8.88178419700125e-16,
- "disk": 0,
- "mem": 0
- },
- "offers": [],
- "registered_time": 1427207787.01469,
- "reregistered_time": 1427207787.0147,
- "resources": {
- "cpus": -8.88178419700125e-16,
- "disk": 0,
- "mem": 0
- },
- "role": "*",
- "tasks": [],
- "unregistered_time": 0,
- "used_resources": {
- "cpus": 0,
- "disk": 0,
- "mem": 0
- },
- "user": "root",
- "webui_url": ""
- },
- {
- "active": true,
- "checkpoint": true,
- "completed_tasks": [
- {
- "executor_id": "",
- "framework_id": "20150127-110351-1513192458-5050-8587-0000",
- "id": "test_dv_helloworld.95f49d05-c9bf-11e4-a1fc-56847afe9799",
- "name": "helloworld.dv.test",
- "resources": {
- "cpus": 0.1,
- "disk": 0,
- "mem": 32,
- "ports": "[31000-31000]"
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S19",
- "state": "TASK_KILLED",
- "statuses": []
- },
- {
- "executor_id": "",
- "framework_id": "20150127-110351-1513192458-5050-8587-0000",
- "id": "test_dv_helloworld.a40abda6-ca02-11e4-a1fc-56847afe9799",
- "name": "helloworld.dv.test",
- "resources": {
- "cpus": 0.1,
- "disk": 0,
- "mem": 32,
- "ports": "[31000-31000]"
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S19",
- "state": "TASK_KILLED",
- "statuses": []
- },
- {
- "executor_id": "",
- "framework_id": "20150127-110351-1513192458-5050-8587-0000",
- "id": "test_dv_helloworld.3946a287-ca67-11e4-a1fc-56847afe9799",
- "name": "helloworld.dv.test",
- "resources": {
- "cpus": 0.1,
- "disk": 0,
- "mem": 32,
- "ports": "[31000-31000]"
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S19",
- "state": "TASK_KILLED",
- "statuses": []
- },
- {
- "executor_id": "",
- "framework_id": "20150127-110351-1513192458-5050-8587-0000",
- "id": "test_dv_helloworld.fec0c74c-ce11-11e4-a1fc-56847afe9799",
- "name": "helloworld.dv.test",
- "resources": {
- "cpus": 0.1,
- "disk": 0,
- "mem": 32,
- "ports": "[31000-31000]"
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S19",
- "state": "TASK_KILLED",
- "statuses": []
- },
- {
- "executor_id": "",
- "framework_id": "20150127-110351-1513192458-5050-8587-0000",
- "id": "test_jenkins-master.33d4007e-cf37-11e4-a1fc-56847afe9799",
- "name": "jenkins-master.test",
- "resources": {
- "cpus": 0.3,
- "disk": 0,
- "mem": 768,
- "ports": "[31561-31561]"
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S19",
- "state": "TASK_FAILED",
- "statuses": []
- },
- {
- "executor_id": "",
- "framework_id": "20150127-110351-1513192458-5050-8587-0000",
- "id": "test_jenkins-master.359deb0f-cf37-11e4-a1fc-56847afe9799",
- "name": "jenkins-master.test",
- "resources": {
- "cpus": 0.3,
- "disk": 0,
- "mem": 768,
- "ports": "[31939-31939]"
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S19",
- "state": "TASK_FAILED",
- "statuses": []
- },
- {
- "executor_id": "",
- "framework_id": "20150127-110351-1513192458-5050-8587-0000",
- "id": "test_jenkins-master.50773d6a-cf37-11e4-a1fc-56847afe9799",
- "name": "jenkins-master.test",
- "resources": {
- "cpus": 0.3,
- "disk": 0,
- "mem": 768,
- "ports": "[31908-31908]"
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S19",
- "state": "TASK_FAILED",
- "statuses": []
- },
- {
- "executor_id": "",
- "framework_id": "20150127-110351-1513192458-5050-8587-0000",
- "id": "test_jenkins-master.638fd9ce-cf37-11e4-a1fc-56847afe9799",
- "name": "jenkins-master.test",
- "resources": {
- "cpus": 0.3,
- "disk": 0,
- "mem": 768,
- "ports": "[31658-31658]"
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S19",
- "state": "TASK_FAILED",
- "statuses": []
- },
- {
- "executor_id": "",
- "framework_id": "20150127-110351-1513192458-5050-8587-0000",
- "id": "test_jenkins-master.81fd2852-cf37-11e4-a1fc-56847afe9799",
- "name": "jenkins-master.test",
- "resources": {
- "cpus": 0.3,
- "disk": 0,
- "mem": 768,
- "ports": "[31160-31160]"
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S19",
- "state": "TASK_FAILED",
- "statuses": []
- },
- {
- "executor_id": "",
- "framework_id": "20150127-110351-1513192458-5050-8587-0000",
- "id": "test_jenkins-master.afedb77b-cf37-11e4-a1fc-56847afe9799",
- "name": "jenkins-master.test",
- "resources": {
- "cpus": 0.3,
- "disk": 0,
- "mem": 768,
- "ports": "[31185-31185]"
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S19",
- "state": "TASK_FAILED",
- "statuses": []
- },
- {
- "executor_id": "",
- "framework_id": "20150127-110351-1513192458-5050-8587-0000",
- "id": "test_jenkins-master.0243c011-cf38-11e4-a1fc-56847afe9799",
- "name": "jenkins-master.test",
- "resources": {
- "cpus": 0.3,
- "disk": 0,
- "mem": 768,
- "ports": "[31554-31554]"
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S19",
- "state": "TASK_FAILED",
- "statuses": []
- },
- {
- "executor_id": "",
- "framework_id": "20150127-110351-1513192458-5050-8587-0000",
- "id": "test_dv_helloworld.4bdb1099-d1de-11e4-a1fc-56847afe9799",
- "name": "helloworld.dv.test",
- "resources": {
- "cpus": 0.1,
- "disk": 0,
- "mem": 32,
- "ports": "[31000-31000]"
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S19",
- "state": "TASK_KILLED",
- "statuses": []
- },
- {
- "executor_id": "",
- "framework_id": "20150127-110351-1513192458-5050-8587-0000",
- "id": "sdp_shared_jenkins-master.eb8f2863-c9a2-11e4-a1fc-56847afe9799",
- "name": "jenkins-master.shared.sdp",
- "resources": {
- "cpus": 0.3,
- "disk": 0,
- "mem": 768,
- "ports": "[31458-31458]"
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S27",
- "state": "TASK_FAILED",
- "statuses": []
- },
- {
- "executor_id": "",
- "framework_id": "20150127-110351-1513192458-5050-8587-0000",
- "id": "test_dv_helloworld.c7865efb-cd05-11e4-a1fc-56847afe9799",
- "name": "helloworld.dv.test",
- "resources": {
- "cpus": 0.1,
- "disk": 0,
- "mem": 32,
- "ports": "[31000-31000]"
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S27",
- "state": "TASK_KILLED",
- "statuses": []
- },
- {
- "executor_id": "",
- "framework_id": "20150127-110351-1513192458-5050-8587-0000",
- "id": "test_jenkins-master.37684ad0-cf37-11e4-a1fc-56847afe9799",
- "name": "jenkins-master.test",
- "resources": {
- "cpus": 0.3,
- "disk": 0,
- "mem": 768,
- "ports": "[31223-31223]"
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S27",
- "state": "TASK_FAILED",
- "statuses": []
- },
- {
- "executor_id": "",
- "framework_id": "20150127-110351-1513192458-5050-8587-0000",
- "id": "test_jenkins-master.3c2e3752-cf37-11e4-a1fc-56847afe9799",
- "name": "jenkins-master.test",
- "resources": {
- "cpus": 0.3,
- "disk": 0,
- "mem": 768,
- "ports": "[31703-31703]"
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S27",
- "state": "TASK_FAILED",
- "statuses": []
- },
- {
- "executor_id": "",
- "framework_id": "20150127-110351-1513192458-5050-8587-0000",
- "id": "test_jenkins-master.405b3f34-cf37-11e4-a1fc-56847afe9799",
- "name": "jenkins-master.test",
- "resources": {
- "cpus": 0.3,
- "disk": 0,
- "mem": 768,
- "ports": "[31996-31996]"
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S27",
- "state": "TASK_FAILED",
- "statuses": []
- },
- {
- "executor_id": "",
- "framework_id": "20150127-110351-1513192458-5050-8587-0000",
- "id": "test_jenkins-master.44886e26-cf37-11e4-a1fc-56847afe9799",
- "name": "jenkins-master.test",
- "resources": {
- "cpus": 0.3,
- "disk": 0,
- "mem": 768,
- "ports": "[31141-31141]"
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S27",
- "state": "TASK_FAILED",
- "statuses": []
- },
- {
- "executor_id": "",
- "framework_id": "20150127-110351-1513192458-5050-8587-0000",
- "id": "test_jenkins-master.54a4936b-cf37-11e4-a1fc-56847afe9799",
- "name": "jenkins-master.test",
- "resources": {
- "cpus": 0.3,
- "disk": 0,
- "mem": 768,
- "ports": "[31109-31109]"
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S27",
- "state": "TASK_FAILED",
- "statuses": []
- },
- {
- "executor_id": "",
- "framework_id": "20150127-110351-1513192458-5050-8587-0000",
- "id": "test_jenkins-master.58d1e96c-cf37-11e4-a1fc-56847afe9799",
- "name": "jenkins-master.test",
- "resources": {
- "cpus": 0.3,
- "disk": 0,
- "mem": 768,
- "ports": "[31110-31110]"
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S27",
- "state": "TASK_FAILED",
- "statuses": []
- },
- {
- "executor_id": "",
- "framework_id": "20150127-110351-1513192458-5050-8587-0000",
- "id": "test_jenkins-master.5d97fcfd-cf37-11e4-a1fc-56847afe9799",
- "name": "jenkins-master.test",
- "resources": {
- "cpus": 0.3,
- "disk": 0,
- "mem": 768,
- "ports": "[31167-31167]"
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S27",
- "state": "TASK_FAILED",
- "statuses": []
- },
- {
- "executor_id": "",
- "framework_id": "20150127-110351-1513192458-5050-8587-0000",
- "id": "test_jenkins-master.6986f34f-cf37-11e4-a1fc-56847afe9799",
- "name": "jenkins-master.test",
- "resources": {
- "cpus": 0.3,
- "disk": 0,
- "mem": 768,
- "ports": "[31158-31158]"
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S27",
- "state": "TASK_FAILED",
- "statuses": []
- },
- {
- "executor_id": "",
- "framework_id": "20150127-110351-1513192458-5050-8587-0000",
- "id": "test_jenkins-master.790a33f1-cf37-11e4-a1fc-56847afe9799",
- "name": "jenkins-master.test",
- "resources": {
- "cpus": 0.3,
- "disk": 0,
- "mem": 768,
- "ports": "[31696-31696]"
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S27",
- "state": "TASK_FAILED",
- "statuses": []
- },
- {
- "executor_id": "",
- "framework_id": "20150127-110351-1513192458-5050-8587-0000",
- "id": "test_jenkins-master.8c2149b3-cf37-11e4-a1fc-56847afe9799",
- "name": "jenkins-master.test",
- "resources": {
- "cpus": 0.3,
- "disk": 0,
- "mem": 768,
- "ports": "[31258-31258]"
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S27",
- "state": "TASK_FAILED",
- "statuses": []
- },
- {
- "executor_id": "",
- "framework_id": "20150127-110351-1513192458-5050-8587-0000",
- "id": "test_jenkins-master.9c3d47e4-cf37-11e4-a1fc-56847afe9799",
- "name": "jenkins-master.test",
- "resources": {
- "cpus": 0.3,
- "disk": 0,
- "mem": 768,
- "ports": "[31308-31308]"
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S27",
- "state": "TASK_FAILED",
- "statuses": []
- },
- {
- "executor_id": "",
- "framework_id": "20150127-110351-1513192458-5050-8587-0000",
- "id": "test_jenkins-master.a06a01a6-cf37-11e4-a1fc-56847afe9799",
- "name": "jenkins-master.test",
- "resources": {
- "cpus": 0.3,
- "disk": 0,
- "mem": 768,
- "ports": "[31252-31252]"
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S27",
- "state": "TASK_FAILED",
- "statuses": []
- },
- {
- "executor_id": "",
- "framework_id": "20150127-110351-1513192458-5050-8587-0000",
- "id": "test_jenkins-master.fa821fbd-cf37-11e4-a1fc-56847afe9799",
- "name": "jenkins-master.test",
- "resources": {
- "cpus": 0.3,
- "disk": 0,
- "mem": 768,
- "ports": "[31111-31111]"
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S27",
- "state": "TASK_FAILED",
- "statuses": []
- },
- {
- "executor_id": "",
- "framework_id": "20150127-110351-1513192458-5050-8587-0000",
- "id": "test_jenkins-master.fbb39ade-cf37-11e4-a1fc-56847afe9799",
- "name": "jenkins-master.test",
- "resources": {
- "cpus": 0.3,
- "disk": 0,
- "mem": 768,
- "ports": "[31658-31658]"
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S27",
- "state": "TASK_FAILED",
- "statuses": []
- },
- {
- "executor_id": "",
- "framework_id": "20150127-110351-1513192458-5050-8587-0000",
- "id": "test_jenkins-master.ffe0f0e0-cf37-11e4-a1fc-56847afe9799",
- "name": "jenkins-master.test",
- "resources": {
- "cpus": 0.3,
- "disk": 0,
- "mem": 768,
- "ports": "[31022-31022]"
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S27",
- "state": "TASK_FAILED",
- "statuses": []
- },
- {
- "executor_id": "",
- "framework_id": "20150127-110351-1513192458-5050-8587-0000",
- "id": "test_jenkins-master.04a68f42-cf38-11e4-a1fc-56847afe9799",
- "name": "jenkins-master.test",
- "resources": {
- "cpus": 0.3,
- "disk": 0,
- "mem": 768,
- "ports": "[31583-31583]"
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S27",
- "state": "TASK_FAILED",
- "statuses": []
- },
- {
- "executor_id": "",
- "framework_id": "20150127-110351-1513192458-5050-8587-0000",
- "id": "test_jenkins-master.4ce2cc09-cf37-11e4-a1fc-56847afe9799",
- "name": "jenkins-master.test",
- "resources": {
- "cpus": 0.3,
- "disk": 0,
- "mem": 768,
- "ports": "[31449-31449]"
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S25",
- "state": "TASK_FAILED",
- "statuses": []
- },
- {
- "executor_id": "",
- "framework_id": "20150127-110351-1513192458-5050-8587-0000",
- "id": "test_jenkins-master.a792e469-cf37-11e4-a1fc-56847afe9799",
- "name": "jenkins-master.test",
- "resources": {
- "cpus": 0.3,
- "disk": 0,
- "mem": 768,
- "ports": "[31299-31299]"
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S25",
- "state": "TASK_FAILED",
- "statuses": []
- },
- {
- "executor_id": "",
- "framework_id": "20150127-110351-1513192458-5050-8587-0000",
- "id": "test_jenkins-master.fe166a0f-cf37-11e4-a1fc-56847afe9799",
- "name": "jenkins-master.test",
- "resources": {
- "cpus": 0.3,
- "disk": 0,
- "mem": 768,
- "ports": "[31383-31383]"
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S25",
- "state": "TASK_FAILED",
- "statuses": []
- },
- {
- "executor_id": "",
- "framework_id": "20150127-110351-1513192458-5050-8587-0000",
- "id": "test_jenkins-master.0670c7f3-cf38-11e4-a1fc-56847afe9799",
- "name": "jenkins-master.test",
- "resources": {
- "cpus": 0.3,
- "disk": 0,
- "mem": 768,
- "ports": "[31607-31607]"
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S25",
- "state": "TASK_FAILED",
- "statuses": []
- },
- {
- "executor_id": "",
- "framework_id": "20150127-110351-1513192458-5050-8587-0000",
- "id": "test_dev_frontend.3950b432-d234-11e4-bc5e-56847afe9799",
- "name": "frontend.dev.test",
- "resources": {
- "cpus": 0.2,
- "disk": 0,
- "mem": 1024,
- "ports": "[31980-31980, 31000-31002]"
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S21",
- "state": "TASK_KILLED",
- "statuses": [
- {
- "state": "TASK_RUNNING",
- "timestamp": 1427208248.01184
- },
- {
- "state": "TASK_KILLED",
- "timestamp": 1427208510.81702
- }
- ]
- },
- {
- "executor_id": "",
- "framework_id": "20150127-110351-1513192458-5050-8587-0000",
- "id": "test_dv_helloworld.c3a7d253-d241-11e4-bc5e-56847afe9799",
- "name": "helloworld.dv.test",
- "resources": {
- "cpus": 0.1,
- "disk": 0,
- "mem": 32,
- "ports": "[31584-31584]"
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S21",
- "state": "TASK_KILLED",
- "statuses": [
- {
- "state": "TASK_RUNNING",
- "timestamp": 1427214063.25571
- },
- {
- "state": "TASK_KILLED",
- "timestamp": 1427214249.31952
- }
- ]
- },
- {
- "executor_id": "",
- "framework_id": "20150127-110351-1513192458-5050-8587-0000",
- "id": "test_dv_helloworld.d7c6b3c4-d244-11e4-bc5e-56847afe9799",
- "name": "helloworld.dv.test",
- "resources": {
- "cpus": 0.1,
- "disk": 0,
- "mem": 32,
- "ports": "[31000-31000]"
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S27",
- "state": "TASK_KILLED",
- "statuses": [
- {
- "state": "TASK_RUNNING",
- "timestamp": 1427215390.066
- },
- {
- "state": "TASK_KILLED",
- "timestamp": 1427215571.78983
- }
- ]
- },
- {
- "executor_id": "",
- "framework_id": "20150127-110351-1513192458-5050-8587-0000",
- "id": "test_dev_frontend.a0f3f185-d2e6-11e4-bc5e-56847afe9799",
- "name": "frontend.dev.test",
- "resources": {
- "cpus": 0.2,
- "disk": 0,
- "mem": 1024,
- "ports": "[31980-31980, 31000-31002]"
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S25",
- "state": "TASK_KILLED",
- "statuses": [
- {
- "state": "TASK_RUNNING",
- "timestamp": 1427285021.3087
- },
- {
- "state": "TASK_KILLED",
- "timestamp": 1427285124.9842
- }
- ]
- }
- ],
- "failover_timeout": 604800,
- "hostname": "ip-10-124-49-90.ec2.internal",
- "id": "20150127-110351-1513192458-5050-8587-0000",
- "name": "marathon",
- "offered_resources": {
- "cpus": -2.44249065417534e-15,
- "disk": 0,
- "mem": 0
- },
- "offers": [],
- "registered_time": 1427207786.075,
- "reregistered_time": 1427289460.06666,
- "resources": {
- "cpus": 0.299999999999998,
- "disk": 0,
- "mem": 768,
- "ports": "[31583-31583]"
- },
- "role": "*",
- "tasks": [
- {
- "executor_id": "",
- "framework_id": "20150127-110351-1513192458-5050-8587-0000",
- "id": "sdp_shared_jenkins-master.ed596114-c9a2-11e4-a1fc-56847afe9799",
- "name": "jenkins-master.shared.sdp",
- "resources": {
- "cpus": 0.3,
- "disk": 0,
- "mem": 768,
- "ports": "[31583-31583]"
- },
- "slave_id": "20150225-172738-2049997834-5050-23289-S21",
- "state": "TASK_RUNNING",
- "statuses": [
- {
- "state": "TASK_RUNNING",
- "timestamp": 1426266239.30745
- }
- ]
- }
- ],
- "unregistered_time": 0,
- "used_resources": {
- "cpus": 0.3,
- "disk": 0,
- "mem": 768,
- "ports": "[31583-31583]"
- },
- "user": "root",
- "webui_url": ""
- }
- ],
- "git_sha": "2ae1ba91e64f92ec71d327e10e6ba9e8ad5477e8",
- "git_tag": "0.21.1",
- "hostname": "10.124.49.90",
- "id": "20150225-172748-1513192458-5050-6647",
- "killed_tasks": 12,
- "leader": "master@10.124.49.90:5050",
- "log_dir": "/var/log/mesos",
- "lost_tasks": 0,
- "orphan_tasks": [],
- "pid": "master@10.124.49.90:5050",
- "slaves": [
- {
- "attributes": {
- "az": "us-east-1b",
- "instance_id": "i-496a92b3",
- "instance_type": "c3.large"
- },
- "hostname": "10.124.49.190",
- "id": "20150225-172748-1513192458-5050-6647-S0",
- "pid": "slave(1)@10.124.49.190:5051",
- "registered_time": 1427207786.83581,
- "resources": {
- "cpus": 2,
- "disk": 3966,
- "mem": 2744,
- "ports": "[31000-32000]"
- }
- },
- {
- "attributes": {
- "az": "us-east-1c",
- "instance_id": "i-b57fe25a",
- "instance_type": "c3.large"
- },
- "hostname": "10.124.50.153",
- "id": "20150225-172738-2049997834-5050-23289-S27",
- "pid": "slave(1)@10.124.50.153:5051",
- "registered_time": 1427207786.63308,
- "reregistered_time": 1427207786.63309,
- "resources": {
- "cpus": 2,
- "disk": 3966,
- "mem": 2744,
- "ports": "[31000-32000]"
- }
- },
- {
- "attributes": {
- "az": "us-east-1c",
- "instance_id": "i-2467dccb",
- "instance_type": "c3.large"
- },
- "hostname": "10.124.50.12",
- "id": "20150225-172748-1513192458-5050-6647-S2",
- "pid": "slave(1)@10.124.50.12:5051",
- "registered_time": 1427399742.96888,
- "resources": {
- "cpus": 2,
- "disk": 3966,
- "mem": 2744,
- "ports": "[31000-32000]"
- }
- },
- {
- "attributes": {
- "az": "us-east-1a",
- "instance_id": "i-b33a5842",
- "instance_type": "c3.large"
- },
- "hostname": "10.124.48.198",
- "id": "20150225-172738-2049997834-5050-23289-S25",
- "pid": "slave(1)@10.124.48.198:5051",
- "registered_time": 1427207786.94212,
- "reregistered_time": 1427207786.94213,
- "resources": {
- "cpus": 2,
- "disk": 3966,
- "mem": 2744,
- "ports": "[31000-32000]"
- }
- },
- {
- "attributes": {
- "az": "us-east-1a",
- "instance_id": "i-9bdcde6a",
- "instance_type": "c3.large"
- },
- "hostname": "10.124.48.147",
- "id": "20150225-172738-2049997834-5050-23289-S21",
- "pid": "slave(1)@10.124.48.147:5051",
- "registered_time": 1427207786.33104,
- "reregistered_time": 1427207786.33115,
- "resources": {
- "cpus": 2,
- "disk": 3966,
- "mem": 2744,
- "ports": "[31000-32000]"
- }
- }
- ],
- "staged_tasks": 11,
- "start_time": 1424885268.34093,
- "started_tasks": 0,
- "unregistered_frameworks": [
- "20150225-172738-2049997834-5050-23289-0433",
- "20150225-172738-2049997834-5050-23289-0433",
- "20150225-172738-2049997834-5050-23289-0433",
- "20150225-172738-2049997834-5050-23289-0433"
- ],
- "version": "0.21.1"
-}
\ No newline at end of file
diff --git a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/resources/issue_76_2.json b/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/resources/issue_76_2.json
deleted file mode 100644
index 8cbd141..0000000
--- a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/resources/issue_76_2.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "cpus": -8.88178419700125e-16,
- "disk": 0,
- "mem": 0
-}
diff --git a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/resources/json-test-doc.json b/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/resources/json-test-doc.json
deleted file mode 100644
index f03e289..0000000
--- a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/resources/json-test-doc.json
+++ /dev/null
@@ -1,30 +0,0 @@
-{
- "id": 100,
- "type": "donut",
- "name": "Cake",
- "available": true,
- "ppu": 0.55,
- "batters":
- {
- "batter":
- [
- {
- "id": "1001",
- "type": "Regular"
- },
- {
- "id": "1002",
- "type": "Chocolate"
- },
- {
- "id": "1003",
- "type": "Blueberry"
- },
- {
- "id": "1004",
- "type": "Devil's Food"
- }
- ]
- },
- "toppings": ["Glazed", "Sugar", "Chocolate", "Maple"]
-}
\ No newline at end of file
diff --git a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/resources/json_array.json b/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/resources/json_array.json
deleted file mode 100644
index 27cfd06..0000000
--- a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/resources/json_array.json
+++ /dev/null
@@ -1,27 +0,0 @@
-
-
-
-{
- "arr": [
- {
- "obj":{"innerArr": [
- {
- "val": "bla_0"
- },
- {
- "val": null
- }
- ]}
- },
- {
- "obj":{"innerArr": [
- {
- "val": "bla_4"
- },
- {
- "val": "bla_5"
- }
- ]}
- }
- ]
-}
\ No newline at end of file
diff --git a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/resources/json_array_multiple_delete.json b/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/resources/json_array_multiple_delete.json
deleted file mode 100644
index a5178cb..0000000
--- a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/resources/json_array_multiple_delete.json
+++ /dev/null
@@ -1,54 +0,0 @@
-{
- "_embedded": {
- "mandates": [
- {
- "count": "0",
- "difference": "+0"
- },
- {
- "count": "0",
- "difference": "+0"
- },
- {
- "count": "0",
- "difference": "+0"
- },
- {
- "count": "0",
- "difference": "+0"
- },
- {
- "count": "0",
- "difference": "+0"
- },
- {
- "count": "10",
- "difference": "+0"
- },
- {
- "count": "34",
- "difference": "+0"
- },
- {
- "count": "2",
- "difference": "+0"
- },
- {
- "count": "4",
- "difference": "+0"
- },
- {
- "count": "0",
- "difference": "+0"
- },
- {
- "count": "0",
- "difference": "+0"
- },
- {
- "count": "0",
- "difference": "+0"
- }
- ]
- }
-}
\ No newline at end of file
diff --git a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/resources/simplelogger.properties b/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/resources/simplelogger.properties
deleted file mode 100644
index b2531ce..0000000
--- a/platform/northbound/jsonpath-filtering/json-provider-minimal/src/test/resources/simplelogger.properties
+++ /dev/null
@@ -1,5 +0,0 @@
-#org.slf4j.simpleLogger.log.com.jayway=debug
-#org.slf4j.simpleLogger.log.com.jayway.jsonpath.internal.filter=trace
-#org.slf4j.simpleLogger.log.com.jayway.jsonpath.internal.path.ScanPathToken=trace
-
-
diff --git a/platform/northbound/jsonpath-filtering/jsonpath-filter/pom.xml b/platform/northbound/jsonpath-filtering/jsonpath-filter/pom.xml
index 5fc1980..6c1f8f2 100644
--- a/platform/northbound/jsonpath-filtering/jsonpath-filter/pom.xml
+++ b/platform/northbound/jsonpath-filtering/jsonpath-filter/pom.xml
@@ -80,81 +80,15 @@
<version>${project.version}</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>com.jayway.jsonpath</groupId>
+ <artifactId>json-path</artifactId>
+ <version>2.4.0</version>
+ </dependency>
</dependencies>
<build>
- <plugins>
- <plugin>
- <groupId>org.codehaus.gmaven</groupId>
- <artifactId>groovy-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>search-dependency</id>
- <phase>validate</phase>
- <goals>
- <goal>execute</goal>
- </goals>
- <configuration>
- <source>
- String basedir = project.basedir.absolutePath.replace('\\','/');
- File dependencyFile = new File(new File(basedir).getParentFile(), "json-path/target/json-path-2.4.0.jar");
-
- if(!dependencyFile.exists())
- {
- project.getCompileSourceRoots().clear();
- project.getTestCompileSourceRoots().clear();
-
-
- org.apache.maven.plugin.internal.DefaultPluginManager
- manager = session.getContainer().lookup(
- org.apache.maven.plugin.PluginManager.class.getName());
-
- log.info('{}',manager);
-
- } else
- {
- org.apache.maven.artifact.Artifact artifact =
- new org.apache.maven.artifact.DefaultArtifact('com.jayway.jsonpath',
- 'json-path',
- org.apache.maven.artifact.versioning.VersionRange.createFromVersionSpec('2.4.0'),
- org.apache.maven.artifact.Artifact.SCOPE_SYSTEM,
- 'jar', '',
- new org.apache.maven.artifact.handler.DefaultArtifactHandler('jar')
- {
- @Override
- public boolean isAddedToClasspath()
- {
- return true;
- }
-
- @Override
- public boolean isIncludesDependencies()
- {
- return true;
- }
-
- @Override
- public String getDirectory()
- {
- return dependencyFile.getParentFile().getAbsolutePath();
- }
- },
- false);
- artifact.setFile(dependencyFile);
- project.getDependencyArtifacts().add(artifact);
- }
- </source>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.7</source>
- <target>1.7</target>
- </configuration>
- </plugin>
+ <plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
@@ -252,13 +186,13 @@
<outputDirectory>${project.build.directory}/felix/bundle</outputDirectory>
<destFileName>sensinact-core.jar</destFileName>
</artifactItem>
- <artifactItem>
- <groupId>org.eclipse.sensinact.gateway</groupId>
- <artifactId>sensinact-signature-validator</artifactId>
- <version>${project.version}</version>
- <outputDirectory>${project.build.directory}/felix/bundle</outputDirectory>
- <destFileName>sensinact-signature-validator.jar</destFileName>
- </artifactItem>
+ <artifactItem>
+ <groupId>org.eclipse.sensinact.gateway</groupId>
+ <artifactId>sensinact-signature-validator</artifactId>
+ <version>${project.version}</version>
+ <outputDirectory>${project.build.directory}/felix/bundle</outputDirectory>
+ <destFileName>sensinact-signature-validator.jar</destFileName>
+ </artifactItem>
<artifactItem>
<groupId>org.eclipse.sensinact.gateway</groupId>
<artifactId>sensinact-framework-extension</artifactId>
@@ -300,28 +234,21 @@
<version>${project.version}</version>
<outputDirectory>${project.build.directory}/felix/bundle</outputDirectory>
<destFileName>rest-access.jar</destFileName>
- </artifactItem>
+ </artifactItem>
<artifactItem>
- <groupId>org.eclipse.sensinact.gateway.nthbnd</groupId>
- <artifactId>json-provider-minimal</artifactId>
- <version>${project.version}</version>
- <outputDirectory>${project.build.directory}/felix/bundle</outputDirectory>
- <destFileName>json-provider-minimal.jar</destFileName>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.7.25</version>
+ <outputDirectory>${project.build.directory}/felix/bundle</outputDirectory>
+ <destFileName>slf4j-api.jar</destFileName>
</artifactItem>
- <artifactItem>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- <version>1.7.25</version>
- <outputDirectory>${project.build.directory}/felix/bundle</outputDirectory>
- <destFileName>slf4j-api.jar</destFileName>
- </artifactItem>
- <artifactItem>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-simple</artifactId>
- <version>1.7.16</version>
- <outputDirectory>${project.build.directory}/felix/bundle</outputDirectory>
- <destFileName>slf4j-simple.jar</destFileName>
- </artifactItem>
+ <artifactItem>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ <version>1.7.16</version>
+ <outputDirectory>${project.build.directory}/felix/bundle</outputDirectory>
+ <destFileName>slf4j-simple.jar</destFileName>
+ </artifactItem>
<artifactItem>
<groupId>org.eclipse.sensinact.gateway.protocol</groupId>
<artifactId>http</artifactId>
@@ -364,55 +291,26 @@
<outputDirectory>${project.build.directory}/felix/bundle</outputDirectory>
<destFileName>light.jar</destFileName>
</artifactItem>
+ <artifactItem>
+ <groupId>com.jayway.jsonpath</groupId>
+ <artifactId>json-path</artifactId>
+ <version>2.4.0</version>
+ <outputDirectory>${project.build.directory}/felix/bundle</outputDirectory>
+ <destFileName>json-path.jar</destFileName>
+ </artifactItem>
+ <artifactItem>
+ <groupId>net.minidev</groupId>
+ <artifactId>json-smart</artifactId>
+ <version>2.3</version>
+ <outputDirectory>${project.build.directory}/felix/bundle</outputDirectory>
+ <destFileName>json-smart.jar</destFileName>
+ </artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
<extensions>true</extensions>
- </plugin>
- <plugin>
- <groupId>org.codehaus.gmaven</groupId>
- <artifactId>groovy-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>copy-dependency</id>
- <phase>generate-test-resources</phase>
- <goals>
- <goal>execute</goal>
- </goals>
- <configuration>
- <source>
- String basedir = project.basedir.absolutePath.replace('\\','/');
- File dependencyFile = new File(new File(basedir).getParentFile(), "json-path/target/json-path-2.4.0.jar");
-
-<!-- File dir = new File(new File(basedir),'target'); -->
-<!-- if(!dir.exists()) -->
-<!-- { -->
-<!-- dir.mkdir(); -->
-<!-- } -->
-<!-- dir = new File(new File(basedir),'target/felix'); -->
-<!-- if(!dir.exists()) -->
-<!-- { -->
-<!-- dir.mkdir(); -->
-<!-- } -->
- File dir = new File(new File(basedir),'target/felix/bundle');
- if(!dir.exists())
- {
- dir.mkdirs();
- }
-
- def newFile = new File(new File(basedir),'target/felix/bundle/json-path.jar');
- newFile.createNewFile();
-
- output = newFile.newOutputStream();
- dependencyFile.newInputStream().eachByte(1024,
- {data, lenth -> output.write(data, 0, lenth)});
- output.close();
- </source>
- </configuration>
- </execution>
- </executions>
- </plugin>
+ </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
diff --git a/platform/northbound/jsonpath-filtering/jsonpath-filter/src/test/java/org/eclipse/sensinact/gateway/nthbnd/filter/jsonpath/test/TestJsonPathFiltering.java b/platform/northbound/jsonpath-filtering/jsonpath-filter/src/test/java/org/eclipse/sensinact/gateway/nthbnd/filter/jsonpath/test/TestJsonPathFiltering.java
index f35e9b6..f2d4b08 100644
--- a/platform/northbound/jsonpath-filtering/jsonpath-filter/src/test/java/org/eclipse/sensinact/gateway/nthbnd/filter/jsonpath/test/TestJsonPathFiltering.java
+++ b/platform/northbound/jsonpath-filtering/jsonpath-filter/src/test/java/org/eclipse/sensinact/gateway/nthbnd/filter/jsonpath/test/TestJsonPathFiltering.java
@@ -76,8 +76,8 @@
configuration.put("felix.auto.start.2", "file:target/felix/bundle/sensinact-test-configuration.jar " + "file:target/felix/bundle/sensinact-signature-validator.jar " + "file:target/felix/bundle/sensinact-core.jar ");
configuration.put("felix.auto.start.3", "file:target/felix/bundle/javax.servlet-api.jar " + "file:target/felix/bundle/org.apache.felix.http.api.jar " + "file:target/felix/bundle/org.apache.felix.http.jetty.jar " + "file:target/felix/bundle/http.jar " + "file:target/felix/bundle/sensinact-northbound-access.jar " + "file:target/felix/bundle/rest-access.jar");
- configuration.put("felix.auto.install.4", "file:target/felix/bundle/json-provider-minimal.jar");
- configuration.put("felix.auto.start.4", "file:target/felix/bundle/json-path.jar " + "file:target/felix/bundle/dynamicBundle.jar " + "file:target/felix/bundle/slider.jar " + "file:target/felix/bundle/light.jar ");
+ configuration.put("felix.auto.install.4", "file:target/felix/bundle/json-path.jar " + "file:target/felix/bundle/json-smart.jar ");
+ configuration.put("felix.auto.start.4", "file:target/felix/bundle/dynamicBundle.jar " + "file:target/felix/bundle/slider.jar " + "file:target/felix/bundle/light.jar ");
configuration.put("org.eclipse.sensinact.gateway.security.jks.filename", "target/felix/bundle/keystore.jks");
configuration.put("org.eclipse.sensinact.gateway.security.jks.password", "sensiNact_team");
configuration.put("org.osgi.service.http.port", "8898");
diff --git a/platform/northbound/jsonpath-filtering/pom.xml b/platform/northbound/jsonpath-filtering/pom.xml
index 724c48e..5188b6a 100644
--- a/platform/northbound/jsonpath-filtering/pom.xml
+++ b/platform/northbound/jsonpath-filtering/pom.xml
@@ -29,8 +29,6 @@
<name>sensiNact IoT Gateway - JSONPath filtering parent module</name>
<modules>
- <module>json-path</module>
- <module>json-provider-minimal</module>
<module>jsonpath-filter</module>
</modules>