tamaya-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anat...@apache.org
Subject [incubator-tamaya] branch master updated: Fixed metadataprovider and tests.
Date Sat, 15 Dec 2018 23:45:18 GMT
This is an automated email from the ASF dual-hosted git repository.

anatole pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-tamaya.git


The following commit(s) were added to refs/heads/master by this push:
     new 364ed42  Fixed metadataprovider and tests.
364ed42 is described below

commit 364ed423ef7d7c61e5e18991ece7959261e405b9
Author: Anatole Tresch <atsticks@gmail.com>
AuthorDate: Sun Dec 16 00:44:32 2018 +0100

    Fixed metadataprovider and tests.
---
 .../tamaya/spisupport/DefaultMetaDataProvider.java     | 12 +++++++++++-
 .../tamaya/spisupport/DefaultConfigurationTest.java    |  5 -----
 .../tamaya/spisupport/DefaultMetaDataProviderTest.java | 18 ++++++++++--------
 3 files changed, 21 insertions(+), 14 deletions(-)

diff --git a/code/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultMetaDataProvider.java
b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultMetaDataProvider.java
index c1c5be1..e1337bd 100644
--- a/code/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultMetaDataProvider.java
+++ b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/DefaultMetaDataProvider.java
@@ -75,7 +75,11 @@ public class DefaultMetaDataProvider implements MetadataProvider {
         // Override with manual properties
         for(Map.Entry<String,Map<String, String>> en: additionalProperties.entrySet())
{
             Map<String, String> meta = result.get(en.getKey());
-            meta.putAll(en.getValue());
+            if(meta==null){
+                result.put(en.getKey(), new HashMap<>(en.getValue()));
+            }else {
+                meta.putAll(en.getValue());
+            }
         }
         return Collections.unmodifiableMap(result);
     }
@@ -115,6 +119,9 @@ public class DefaultMetaDataProvider implements MetadataProvider {
 
     @Override
     public MetadataProvider setMeta(String property, String key, String value) {
+        Objects.requireNonNull(property, "property null");
+        Objects.requireNonNull(key, "key null");
+        Objects.requireNonNull(value, "value null");
         additionalProperties.computeIfAbsent(property, p -> new HashMap<>())
             .put(key, value);
         return this;
@@ -122,6 +129,8 @@ public class DefaultMetaDataProvider implements MetadataProvider {
 
     @Override
     public MetadataProvider setMeta(String property, Map<String, String> metaData)
{
+        Objects.requireNonNull(property, "property null");
+        Objects.requireNonNull(metaData, "metaData null");
         additionalProperties.computeIfAbsent(property, p -> new HashMap<>())
                 .putAll(metaData);
         return this;
@@ -129,6 +138,7 @@ public class DefaultMetaDataProvider implements MetadataProvider {
 
     @Override
     public MetadataProvider reset(String property) {
+        Objects.requireNonNull(property, "property null");
         additionalProperties.remove(property);
         return this;
     }
diff --git a/code/spi-support/src/test/java/org/apache/tamaya/spisupport/DefaultConfigurationTest.java
b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/DefaultConfigurationTest.java
index 50314f7..a771041 100644
--- a/code/spi-support/src/test/java/org/apache/tamaya/spisupport/DefaultConfigurationTest.java
+++ b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/DefaultConfigurationTest.java
@@ -18,19 +18,14 @@
  */
 package org.apache.tamaya.spisupport;
 
-import org.apache.tamaya.ConfigOperator;
-import org.apache.tamaya.Configuration;
 import org.apache.tamaya.TypeLiteral;
 import org.apache.tamaya.spi.*;
 import org.junit.Test;
 
 import java.util.Collections;
 import java.util.Map;
-import java.util.function.Function;
-import java.util.function.UnaryOperator;
 
 import static org.assertj.core.api.Assertions.*;
-import org.assertj.core.internal.cglib.core.Predicate;
 
 public class DefaultConfigurationTest {
 
diff --git a/code/spi-support/src/test/java/org/apache/tamaya/spisupport/DefaultMetaDataProviderTest.java
b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/DefaultMetaDataProviderTest.java
index 7ef54d4..32aba25 100644
--- a/code/spi-support/src/test/java/org/apache/tamaya/spisupport/DefaultMetaDataProviderTest.java
+++ b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/DefaultMetaDataProviderTest.java
@@ -41,13 +41,13 @@ public class DefaultMetaDataProviderTest {
     @Test
     public void init() {
         DefaultMetaDataProvider provider = new DefaultMetaDataProvider();
-        assertEquals(this, provider.init(ConfigurationContext.EMPTY));
+        assertEquals(provider, provider.init(ConfigurationContext.EMPTY));
     }
 
     @Test
     public void getMetaData() {
         DefaultMetaDataProvider provider = new DefaultMetaDataProvider();
-        assertEquals(this, provider.init(ConfigurationContext.EMPTY));
+        assertEquals(provider, provider.init(ConfigurationContext.EMPTY));
         assertNotNull(provider.getMetaData("foo"));
 
     }
@@ -55,7 +55,7 @@ public class DefaultMetaDataProviderTest {
     @Test
     public void setMeta() {
         DefaultMetaDataProvider provider = new DefaultMetaDataProvider();
-        assertEquals(this, provider.init(ConfigurationContext.EMPTY));
+        assertEquals(provider, provider.init(ConfigurationContext.EMPTY));
         provider.setMeta("foo", "a", "b");
         assertNotNull(provider.getMetaData("foo"));
         assertEquals(1, provider.getMetaData("foo").size());
@@ -64,7 +64,7 @@ public class DefaultMetaDataProviderTest {
     @Test
     public void setMeta_Map() {
         DefaultMetaDataProvider provider = new DefaultMetaDataProvider();
-        assertEquals(this, provider.init(ConfigurationContext.EMPTY));
+        assertEquals(provider, provider.init(ConfigurationContext.EMPTY));
         Map<String,String> map = new HashMap<>();
         map.put("a", "b");
         provider.setMeta("foo", map);
@@ -76,17 +76,19 @@ public class DefaultMetaDataProviderTest {
     @Test
     public void reset() {
         DefaultMetaDataProvider provider = new DefaultMetaDataProvider();
-        assertEquals(this, provider.init(ConfigurationContext.EMPTY));
+        assertEquals(provider, provider.init(ConfigurationContext.EMPTY));
         provider.reset();
-        assertNull(provider.getMetaData("foo"));
+        assertNotNull(provider.getMetaData("foo"));
+        assertTrue(provider.getMetaData("foo").isEmpty());
     }
 
     @Test
     public void reset1() {
         DefaultMetaDataProvider provider = new DefaultMetaDataProvider();
-        assertEquals(this, provider.init(ConfigurationContext.EMPTY));
+        assertEquals(provider, provider.init(ConfigurationContext.EMPTY));
         provider.reset();
-        assertNull(provider.getMetaData("foo"));
+        assertNotNull(provider.getMetaData("foo"));
+        assertTrue(provider.getMetaData("foo").isEmpty());
     }
 
 


Mime
View raw message