Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CARDS-2158: data-entry tests #1455

Draft
wants to merge 12 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions aggregated-cnd/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<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>io.uhndata.cards</groupId>
<artifactId>cards-parent</artifactId>
<version>0.9-SNAPSHOT</version>
</parent>

<artifactId>cards-aggregated-cnd</artifactId>
<packaging>bundle</packaging>
<name>CARDS - The aggregated CND files for unit testing</name>

<build>
<plugins>
<plugin>
<groupId>org.apache.sling</groupId>
<artifactId>slingfeature-maven-plugin</artifactId>
</plugin>

<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Include-Resource>{maven-resources}</Include-Resource>
<Sling-Nodetypes>SLING-INF/nodetypes/aggregated.cnd</Sling-Nodetypes>
</instructions>
</configuration>
</plugin>
</plugins>
</build>

</project>
25 changes: 25 additions & 0 deletions aggregated-cnd/src/main/features/feature.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

{
"bundles":[
{
"id":"${project.groupId}:${project.artifactId}:${project.version}",
"start-order":"25"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
//

<sling = 'http://sling.apache.org/jcr/sling/1.Bac0'>
<cards = 'https://cards.uhndata.io/'>

//-----------------------------------------------------------------------------
// Nodetype for data query handling
[cards:dataQuery] > sling:Folder
// Attributes:
query

// Properties:
// Hardcode the resource type
- sling:resourceType (STRING) = "cards/dataQuery" mandatory autocreated protected
// Hardcode the resource supertype: the dataQuery is a resource
- sling:resourceSuperType (STRING) = "cards/Resource" mandatory autocreated protected
// Set a default title
- title (String) = "CARDS query" mandatory autocreated

//-----------------------------------------------------------------------------
// The configuration for the quick search widget.
[cards:QuickSearchConfiguration] > sling:Folder
// Attributes:

// We can use this in a query.
query

// Properties:

// Hardcode the resource type.
- sling:resourceType (STRING) = "cards/QuickSearchConfiguration" mandatory autocreated protected

// Hardcode the resource supertype: this is a resource.
- sling:resourceSuperType (STRING) = "cards/Resource" mandatory autocreated protected

// What types of resources will be queried.
// Default: all.
- allowedResourceTypes (STRING) multiple

// How many results should be displayed.
- limit (long) = '5'

// Whether to show the total number of results.
// Can be set to 'false' in case of performance issues.
- showTotalRows (BOOLEAN) = 'true'

//-----------------------------------------------------------------------------
[cards:QueryCache] > nt:unstructured
// Attributes

// We can query the cache for saved counts.
query

// Properties

// Hardcode the resource type.
- sling:resourceType (STRING) = "cards/QueryCache" mandatory autocreated protected

// Hardcode the resource supertype: each queryCache is a resource.
- sling:resourceSuperType (STRING) = "cards/Resource" mandatory autocreated protected

// Children

//-----------------------------------------------------------------------------
// The homepage for the QueryCache space.
[cards:QueryCacheHomepage] > sling:Folder
// Attributes:

// We can use this homepage in a query.
query

// Properties:

// Hardcode the resource type.
- sling:resourceType (STRING) = "cards/QueryCacheHomepage" mandatory autocreated protected

// Hardcode the resource supertype: the QueryCacheHomepage is a resource homepage.
- sling:resourceSuperType (STRING) = "cards/ResourceHomepage" mandatory autocreated protected

// Children
+ * (cards:QueryCache)
90 changes: 90 additions & 0 deletions modules/data-entry/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
<packaging>bundle</packaging>
<name>CARDS - Data entry module</name>

<properties>
<coverage.instructionRatio>0.90</coverage.instructionRatio>
</properties>

<build>
<plugins>
<plugin>
Expand Down Expand Up @@ -68,6 +72,18 @@
</excludes>
</configuration>
</plugin>

<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerArgs>
<arg>-Werror</arg>
</compilerArgs>
<showWarnings>true</showWarnings>
<showDeprecation>true</showDeprecation>
<failOnWarning>true</failOnWarning>
</configuration>
</plugin>
</plugins>
</build>

Expand Down Expand Up @@ -135,5 +151,79 @@
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>cards-data-model-subjects-api</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>cards-data-model-forms-api</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>cards-aggregated-cnd</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.resourcebuilder</artifactId>
<version>1.0.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.testing.sling-mock.core</artifactId>
<version>3.4.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.testing.sling-mock.junit4</artifactId>
<version>3.4.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.testing.sling-mock-oak</artifactId>
<version>3.1.4-1.40.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.testing.jcr-mock</artifactId>
<version>1.5.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.framework</artifactId>
<version>1.8.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>20.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.24.2</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,6 @@ private static void sendJsonError(final SlingHttpServletResponse response, int s
.writeEnd();
}
jsonGen.writeEnd().close();
response.setStatus(sc);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ private void copyFields(JsonObject question, String key, JsonObjectBuilder build
if (seenTypes.containsKey(key)) {
// If this question already exists, make sure that it has the same dataType
String questionType = question.getString("dataType");
if (seenTypes.get(key) != questionType) {
if (!seenTypes.get(key).equals(questionType)) {
// DIFFERENT -- prepend a slightly differently named version
String newKey = questionType.concat("|").concat(key);
seenTypes.put(newKey, questionType);
Expand Down
Loading