Skip to content

Commit

Permalink
build: fix issues and failing tests after migration
Browse files Browse the repository at this point in the history
ING-4375
  • Loading branch information
stempler committed Aug 16, 2024
1 parent 8f8f0d4 commit 55c9803
Show file tree
Hide file tree
Showing 51 changed files with 259 additions and 160 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ dependencies {
testImplementation libs.groovy.xml

testImplementation project(':common:plugins:eu.esdihumboldt.hale.common.test')
testImplementation project(':common:plugins:eu.esdihumboldt.hale.common.filter')

testRuntimeOnly project(':io:features:eu.esdihumboldt.hale.io.feature.core')
testRuntimeOnly project(':cst:features:eu.esdihumboldt.cst.feature')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
-project
platform:/plugin/eu.esdihumboldt.hale.app.transform.test/projects/hydro/project.halex
RESOLVE:projects/hydro/project.halex
-source
platform:/plugin/eu.esdihumboldt.hale.app.transform.test/projects/hydro/hydro-source.gml.gz
RESOLVE:projects/hydro/hydro-source.gml.gz
-Sinspire.sds.localId
1234
-filter
name='River Rede'
-filter-on
River
width='10.0'
width='10.0'
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
-project
platform:/plugin/eu.esdihumboldt.hale.app.transform.test/projects/multitype/project.halex
RESOLVE:projects/multitype/project.halex
-source
platform:/plugin/eu.esdihumboldt.hale.app.transform.test/projects/multitype/multi-type-source.xml
RESOLVE:projects/multitype/multi-type-source.xml
-filter
CQL:price>'11'
-filter-on
shirt
name='Polo shirt green'
-exclude-type
shirt
shirt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-project
platform:/plugin/eu.esdihumboldt.hale.app.transform.test/projects/multitype/project.halex
RESOLVE:projects/multitype/project.halex
-source
platform:/plugin/eu.esdihumboldt.hale.app.transform.test/projects/multitype/multi-type-source.xml
RESOLVE:projects/multitype/multi-type-source.xml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ class ExecuteTest extends AbstractPlatformTest {
tempArgsFile.deleteOnExit()
createTempFile(MULTITYPE_ARGS_2_FILE_PATH, tempArgsFile);

// replace RESOLVE: for correct URL
resolveArgResources(tempArgsFile)

println ">> Arguments will be read from ${tempArgsFile}"
println ">> Transformed data will be written to ${targetFile}..."
transform([
Expand Down Expand Up @@ -157,6 +160,9 @@ class ExecuteTest extends AbstractPlatformTest {
tempArgsFile.deleteOnExit()
createTempFile(MULTITYPE_ARGS_FILE_PATH, tempArgsFile);

// replace RESOLVE: for correct URL
resolveArgResources(tempArgsFile)

println ">> Arguments will be read from ${tempArgsFile}"
println ">> Transformed data will be written to ${targetFile}..."
transform([
Expand Down Expand Up @@ -384,6 +390,9 @@ class ExecuteTest extends AbstractPlatformTest {
tempArgsFile.deleteOnExit()
createTempFile(HYDRO_ARGS_FILE_PATH, tempArgsFile);

// replace RESOLVE: for correct URL
resolveArgResources(tempArgsFile)

println ">> Arguments will be read from ${tempArgsFile}"
println ">> Transformed data will be written to ${targetFile}..."
transform([
Expand Down Expand Up @@ -1100,4 +1109,16 @@ assert aggregated['eu.esdihumboldt.hale.instance.validation.internal'].report.wa

return res
}

def void resolveArgResources(File argFile) {
argFile.text = argFile.readLines().collect {line ->
if (line.startsWith('RESOLVE:')) {
def path = line.substring('RESOLVE:'.length())
getClass().getClassLoader().getResource(path).toString()
}
else {
line
}
}.join('\n')
}
}
3 changes: 3 additions & 0 deletions buildSrc/src/main/groovy/hale.java-conventions.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ dependencies {
testRuntimeOnly libs.logback.core
testRuntimeOnly libs.logback.classic
testRuntimeOnly project(':common:plugins:eu.esdihumboldt.hale.common.logback.config.test')

// make offline resources available to all tests
testRuntimeOnly project(':util:features:eu.esdihumboldt.util.feature.resource')
}

task sourcesJar(type: Jar) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,6 @@ dependencies {
testImplementation testLibs.junit4
testImplementation project(':common:plugins:eu.esdihumboldt.hale.common.schema.groovy')
testImplementation project(':util:plugins:eu.esdihumboldt.util.test')

testRuntimeOnly project(':common:plugins:eu.esdihumboldt.hale.common.filter')
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,13 @@ dependencies {

testImplementation testLibs.junit4

testImplementation libs.jakarta.xml.bind.api

testImplementation project(':common:plugins:eu.esdihumboldt.hale.common.align.merge.test')
testImplementation project(':common:plugins:eu.esdihumboldt.hale.common.instance.index')
testImplementation project(':common:plugins:eu.esdihumboldt.hale.common.instance.groovy')

// unsafe providers
testRuntimeOnly project(':io:plugins:eu.esdihumboldt.hale.io.schemabuilder')
testRuntimeOnly project(':io:plugins:eu.esdihumboldt.hale.io.instancebuilder')
}
Original file line number Diff line number Diff line change
@@ -1,35 +1,44 @@
/*
* Copyright (c) 2020 wetransform GmbH
*
*
* All rights reserved. This program and the accompanying materials are made
* available under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of the License,
* or (at your option) any later version.
*
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution. If not, see <http://www.gnu.org/licenses/>.
*
*
* Contributors:
* wetransform GmbH <http://www.wetransform.to>
*/

package eu.esdihumboldt.hale.common.convert.core;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;

/**
* Convert a {@link String} to a {@link LocalDate}.
*
*
* @author Simon Templer
*/
public class StringToLocalDateConverter extends AbstractStringToDateTimeTypeConverter<LocalDate> {

private static DateTimeFormatter SLASH_FORMATTER = DateTimeFormatter.ofPattern("yyyy/MM/dd");

/**
* @see eu.esdihumboldt.hale.common.convert.core.AbstractStringToDateTimeTypeConverter#parse(java.lang.String)
*/
@Override
protected LocalDate parse(String source) {
return LocalDate.parse(source);
try {
return LocalDate.parse(source);
} catch (DateTimeParseException e) {
// try alternative format
return LocalDate.parse(source, SLASH_FORMATTER);
}
}

}
3 changes: 3 additions & 0 deletions common/plugins/eu.esdihumboldt.hale.common.core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,8 @@ dependencies {
implementation libs.model.project

testImplementation testLibs.junit4

testImplementation project(':util:plugins:eu.esdihumboldt.util.test')

testImplementation project(':ext:nonosgi:org.eclipse.equinox.nonosgi.registry')
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import org.eclipse.equinox.nonosgi.registry.RegistryFactoryHelper;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.osgi.framework.Version;

Expand All @@ -39,6 +40,7 @@ public static void init() {

@SuppressWarnings("javadoc")
@Test
@Ignore("Does not work in dev environment because manifest file is not present yet")
public void testGetVersion() {
Version version = HalePlatform.getCoreVersion();
assertNotNull(version);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import eu.esdihumboldt.hale.common.core.io.HaleIO
import eu.esdihumboldt.hale.common.core.io.Value
import eu.esdihumboldt.hale.common.core.io.ValueList
import eu.esdihumboldt.hale.common.core.io.ValueMap
import org.eclipse.equinox.nonosgi.registry.RegistryFactoryHelper
import org.junit.BeforeClass
import eu.esdihumboldt.util.nonosgi.Init
import eu.esdihumboldt.util.test.AbstractPlatformTest
import org.junit.Test
import org.w3c.dom.Element

Expand All @@ -31,13 +31,7 @@ import org.w3c.dom.Element
*
* @author Simon Templer
*/
class ValueMapTypeTest {

@BeforeClass
static void init() {
// initialize registry
RegistryFactoryHelper.getRegistry()
}
class ValueMapTypeTest extends AbstractPlatformTest {

/**
* Test if a map containing simple values and complex values is the same
Expand All @@ -46,13 +40,16 @@ class ValueMapTypeTest {
@Test
public void testValueMap() {
ValueMap vm = new ValueMap()
vm['languages' as Value] = new ValueList(['de' as Value, 'en' as Value]) as Value
vm[Value.of('languages')] = Value.of(new ValueList([
Value.of('de'),
Value.of('en')
]))
vm[6*7 as Value] = 42 as Value
vm[new ValueList([
vm[Value.of(new ValueList([
1 as Value,
2 as Value,
3 as Value
]) as Value] = 123 as Value
]))] = 123 as Value

// convert to DOM
Element fragment = HaleIO.getComplexElement(vm)
Expand All @@ -72,13 +69,16 @@ class ValueMapTypeTest {
@Test
public void testValueMapJson() {
ValueMap vm = new ValueMap()
vm['languages' as Value] = new ValueList(['de' as Value, 'en' as Value]) as Value
vm[Value.of('languages')] = Value.of(new ValueList([
Value.of('de'),
Value.of('en')
]))
vm[6*7 as Value] = 42 as Value
vm[new ValueList([
vm[Value.of(new ValueList([
1 as Value,
2 as Value,
3 as Value
]) as Value] = 123 as Value
]))] = 123 as Value

// converter
ValueMapType vmt = new ValueMapType()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import eu.esdihumboldt.hale.common.core.io.HaleIO
import eu.esdihumboldt.hale.common.core.io.Value
import eu.esdihumboldt.hale.common.core.io.ValueList
import eu.esdihumboldt.hale.common.core.io.ValueProperties
import eu.esdihumboldt.util.test.AbstractPlatformTest
import org.eclipse.equinox.nonosgi.registry.RegistryFactoryHelper
import org.junit.BeforeClass
import org.junit.Test
Expand All @@ -32,13 +33,7 @@ import org.w3c.dom.Element
*
* @author Simon Templer
*/
class ValuePropertiesTypeTest {

@BeforeClass
static void init() {
// initialize registry
RegistryFactoryHelper.getRegistry()
}
class ValuePropertiesTypeTest extends AbstractPlatformTest {

/**
* Test if a simple properties map containing only simple values is the same
Expand All @@ -47,9 +42,9 @@ class ValuePropertiesTypeTest {
@Test
public void testValueProperties() {
ValueProperties vp = new ValueProperties()
Value name = 'Peter' as Value
Value name = Value.of('Peter')
vp['name'] = name
vp['city'] = 'Petersburg' as Value
vp['city'] = Value.of('Petersburg')
vp['age'] = 2.power(5) as Value

// convert to DOM
Expand All @@ -69,9 +64,9 @@ class ValuePropertiesTypeTest {
@Test
public void testValuePropertiesJson() {
ValueProperties vp = new ValueProperties()
Value name = 'Peter' as Value
Value name = Value.of('Peter')
vp['name'] = name
vp['city'] = 'Petersburg' as Value
vp['city'] = Value.of('Petersburg')
vp['age'] = 2.power(5) as Value

// converter
Expand All @@ -97,12 +92,12 @@ class ValuePropertiesTypeTest {
@Test
public void testValuePropertiesList() {
ValueProperties vp = new ValueProperties()
vp['name'] = 'Peter' as Value
vp['cities'] = new ValueList([
'Petersburg' as Value,
'Katzenhirn' as Value,
'Munich' as Value
]) as Value
vp['name'] = Value.of('Peter')
vp['cities'] = Value.of(new ValueList([
Value.of('Petersburg'),
Value.of('Katzenhirn'),
Value.of('Munich')
]))
vp['age'] = 42 - 10 as Value

// convert to DOM
Expand All @@ -123,12 +118,12 @@ class ValuePropertiesTypeTest {
@Test
public void testValuePropertiesListJson() {
ValueProperties vp = new ValueProperties()
vp['name'] = 'Peter' as Value
vp['cities'] = new ValueList([
'Petersburg' as Value,
'Katzenhirn' as Value,
'Munich' as Value
]) as Value
vp['name'] = Value.of('Peter')
vp['cities'] = Value.of(new ValueList([
Value.of('Petersburg'),
Value.of('Katzenhirn'),
Value.of('Munich')
]))
vp['age'] = 42 - 10 as Value

// converter
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
/*
* Copyright (c) 2017 wetransform GmbH
*
*
* All rights reserved. This program and the accompanying materials are made
* available under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of the License,
* or (at your option) any later version.
*
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution. If not, see <http://www.gnu.org/licenses/>.
*
*
* Contributors:
* wetransform GmbH <http://www.wetransform.to>
*/

package eu.esdihumboldt.hale.common.filter;
package eu.esdihumboldt.hale.common.filter

import static org.junit.Assert.*

Expand All @@ -24,6 +24,7 @@ import eu.esdihumboldt.hale.common.instance.model.Instance
import eu.esdihumboldt.hale.common.schema.groovy.SchemaBuilder
import eu.esdihumboldt.hale.common.schema.model.Schema
import eu.esdihumboldt.hale.common.schema.model.TypeDefinition
import eu.esdihumboldt.util.test.AbstractPlatformTest
import java.text.SimpleDateFormat
import org.junit.Before
import org.locationtech.jts.geom.Coordinate
Expand All @@ -32,10 +33,10 @@ import org.locationtech.jts.geom.GeometryFactory

/**
* Base class for filter tests providing test instances.
*
*
* @author Simon Templer
*/
abstract class AbstractFilterTest {
abstract class AbstractFilterTest extends AbstractPlatformTest {

private static final String defaultNs = "http://www.my.namespace"

Expand Down
Loading

0 comments on commit 55c9803

Please sign in to comment.