diff --git a/indexer-core/src/main/java/org/opengroup/osdu/indexer/schema/converter/PropertiesProcessor.java b/indexer-core/src/main/java/org/opengroup/osdu/indexer/schema/converter/PropertiesProcessor.java index c720db2da5c7255b8939886524f21506f1ae7077..8a7c65739b1fd07dd858dad589242adabb86d8d5 100644 --- a/indexer-core/src/main/java/org/opengroup/osdu/indexer/schema/converter/PropertiesProcessor.java +++ b/indexer-core/src/main/java/org/opengroup/osdu/indexer/schema/converter/PropertiesProcessor.java @@ -1,3 +1,17 @@ +// Copyright 2017-2019, Schlumberger +// +// Licensed 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. + package org.opengroup.osdu.indexer.schema.converter; import lombok.AccessLevel; diff --git a/indexer-core/src/test/java/org/opengroup/osdu/indexer/schema/converter/SchemaToStorageFormatImplTest.java b/indexer-core/src/test/java/org/opengroup/osdu/indexer/schema/converter/SchemaToStorageFormatImplTest.java index 17f1cc5bc56e7414d5d306184439f852186e5cc0..05373229d17e63d92684954a6371a51e339fc1c2 100644 --- a/indexer-core/src/test/java/org/opengroup/osdu/indexer/schema/converter/SchemaToStorageFormatImplTest.java +++ b/indexer-core/src/test/java/org/opengroup/osdu/indexer/schema/converter/SchemaToStorageFormatImplTest.java @@ -1,13 +1,25 @@ +// Copyright 2017-2019, Schlumberger +// +// Licensed 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. + package org.opengroup.osdu.indexer.schema.converter; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import org.junit.Test; -import org.junit.runner.RunWith; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder; -import javax.inject.Inject; import java.io.IOException; import java.net.URISyntaxException; import java.nio.charset.StandardCharsets; @@ -19,15 +31,13 @@ import java.util.Map; import static org.junit.Assert.assertEquals; -@RunWith(SpringRunner.class) + @SpringBootTest public class SchemaToStorageFormatImplTest { - @Inject - private ObjectMapper objectMapper; + private ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json().build(); - @Inject - SchemaToStorageFormatImpl schemaToStorageFormatImpl; + private SchemaToStorageFormatImpl schemaToStorageFormatImpl = new SchemaToStorageFormatImpl(objectMapper); @Test public void firstSchemaPassed() throws IOException, URISyntaxException { @@ -63,23 +73,23 @@ public class SchemaToStorageFormatImplTest { } private void compareSchemas(Map<String, Object> expected, Map<String, Object> converted) { - assertEquals(converted.size(), expected.size()); - assertEquals(converted.get("kind"), expected.get("kind")); + assertEquals(expected.size(), converted.size()); + assertEquals(expected.get("kind"), converted.get("kind")); ArrayList<Map<String, String>> conv = (ArrayList<Map<String, String>>) converted.get("schema"); ArrayList<Map<String, String>> exp = (ArrayList<Map<String, String>>) expected.get("schema"); - checkSchemaIteamsAreEqual(conv, exp); + checkSchemaIteamsAreEqual(exp, conv); } - private void checkSchemaIteamsAreEqual(ArrayList<Map<String, String>> conv, List<Map<String, String>> exp) { - assertEquals(conv.size(), exp.size()); + private void checkSchemaIteamsAreEqual(ArrayList<Map<String, String>> exp, List<Map<String, String>> conv) { + assertEquals(exp.size(), conv.size()); conv.forEach((c) -> checkItemIn(c, exp)); } private void checkItemIn(Map<String, String> item, List<Map<String, String>> exp) { String itemPath = item.get("path"); - assertEquals(exp.stream().filter(e->itemPath.equals(e.get("path"))).count(), 1L); + assertEquals(itemPath + " is missed(or too many) see count", exp.stream().filter(e->itemPath.equals(e.get("path"))).count(), 1L); Map<String, String> found = exp.stream().filter(e->item.get("path").equals(e.get("path"))).findAny().get(); - assertEquals(found.get("kind"), item.get("kind"), "In " + itemPath); + assertEquals("In " + itemPath, found.get("kind"), item.get("kind")); } } \ No newline at end of file