Repository: incubator-tamaya
Updated Branches:
  refs/heads/master 2f2aabe1b -> ccabc905d


Added tests for the default implementation of PropertyValueCombinationPolicy.


Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/ccabc905
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/ccabc905
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/ccabc905

Branch: refs/heads/master
Commit: ccabc905d765336fef5a4c780c17ce74988b11c1
Parents: 2f2aabe
Author: Oliver B. Fischer <[email protected]>
Authored: Mon Oct 9 00:38:35 2017 +0200
Committer: Oliver B. Fischer <[email protected]>
Committed: Mon Oct 9 00:38:35 2017 +0200

----------------------------------------------------------------------
 code/api/pom.xml                                |  4 +
 .../spi/PropertyValueCombinationPolicyTest.java | 86 +++++++++++++++++++-
 .../DefaultConfigurationContextBuilderTest.java |  5 ++
 .../internal/converters/EnumConverterTest.java  |  2 +-
 pom.xml                                         |  2 +-
 5 files changed, 96 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/ccabc905/code/api/pom.xml
----------------------------------------------------------------------
diff --git a/code/api/pom.xml b/code/api/pom.xml
index cccaae2..99f08dd 100644
--- a/code/api/pom.xml
+++ b/code/api/pom.xml
@@ -47,6 +47,10 @@ under the License.
             <artifactId>java-hamcrest</artifactId>
         </dependency>
         <dependency>
+            <groupId>org.assertj</groupId>
+            <artifactId>assertj-core</artifactId>
+        </dependency>
+        <dependency>
             <groupId>org.mockito</groupId>
             <artifactId>mockito-core</artifactId>
         </dependency>

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/ccabc905/code/api/src/test/java/org/apache/tamaya/spi/PropertyValueCombinationPolicyTest.java
----------------------------------------------------------------------
diff --git 
a/code/api/src/test/java/org/apache/tamaya/spi/PropertyValueCombinationPolicyTest.java
 
b/code/api/src/test/java/org/apache/tamaya/spi/PropertyValueCombinationPolicyTest.java
index 332a2ee..c725e1b 100644
--- 
a/code/api/src/test/java/org/apache/tamaya/spi/PropertyValueCombinationPolicyTest.java
+++ 
b/code/api/src/test/java/org/apache/tamaya/spi/PropertyValueCombinationPolicyTest.java
@@ -1,5 +1,89 @@
-import static org.junit.Assert.*;
+/*
+ * 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.
+ */
+package org.apache.tamaya.spi;
+
+import org.junit.Test;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.assertj.core.api.Assertions.assertThat;
 
 public class PropertyValueCombinationPolicyTest {
 
+    @Test
+    public void 
defaulPolicyOverridesCurrentValueByTheOneOfTheGivenProperySource() throws 
Exception {
+        PropertyValueCombinationPolicy policy = 
PropertyValueCombinationPolicy.DEFAULT_OVERRIDING_COLLECTOR;
+
+        PropertyValue current = PropertyValue.of("a", "AAA", "Test");
+        PropertyValue result = policy.collect(current, "a", new 
DummyPropertySource());
+
+        assertThat(result.getKey()).isEqualTo("a");
+        assertThat(result.getValue()).isEqualTo("Ami");
+    }
+
+    @Test
+    public void 
defaulPolicyOverridesKeepsTheCurrentValueIfGivenProperySourceDoesNotHaveIt() 
throws Exception {
+        PropertyValueCombinationPolicy policy = 
PropertyValueCombinationPolicy.DEFAULT_OVERRIDING_COLLECTOR;
+
+        PropertyValue current = PropertyValue.of("a", "AAA", "Test");
+        PropertyValue result = policy.collect(current, "a", 
PropertySource.EMPTY);
+
+        assertThat(result.getKey()).isEqualTo("a");
+        assertThat(result.getValue()).isEqualTo("AAA");
+        assertThat(result).isEqualTo(current);
+    }
+
+
+    static class DummyPropertySource implements PropertySource {
+        @Override
+        public int getOrdinal() {
+            return 10;
+        }
+
+        @Override
+        public String getName() {
+            return "NAME";
+        }
+
+        @Override
+        public PropertyValue get(String key) {
+            return getProperties().get(key);
+        }
+
+        @Override
+        public Map<String, PropertyValue> getProperties() {
+            PropertyValue a = PropertyValue.of("a", "Ami", "Test");
+            PropertyValue b = PropertyValue.of("b", "Big", "Test");
+
+            HashMap<String, PropertyValue> properties = new HashMap<>();
+
+            properties.put(a.getKey(), a);
+            properties.put(b.getKey(), b);
+
+            return properties;
+        }
+
+        @Override
+        public boolean isScannable() {
+            return true;
+        }
+    }
+
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/ccabc905/code/core/src/test/java/org/apache/tamaya/core/internal/DefaultConfigurationContextBuilderTest.java
----------------------------------------------------------------------
diff --git 
a/code/core/src/test/java/org/apache/tamaya/core/internal/DefaultConfigurationContextBuilderTest.java
 
b/code/core/src/test/java/org/apache/tamaya/core/internal/DefaultConfigurationContextBuilderTest.java
index 9c9e9a7..83a15a7 100644
--- 
a/code/core/src/test/java/org/apache/tamaya/core/internal/DefaultConfigurationContextBuilderTest.java
+++ 
b/code/core/src/test/java/org/apache/tamaya/core/internal/DefaultConfigurationContextBuilderTest.java
@@ -193,6 +193,11 @@ public class DefaultConfigurationContextBuilderTest {
         assertNotNull(b.build());
     }
 
+    @Test
+    public void bla() throws Exception {
+        ConfigurationContextBuilder builder = 
ConfigurationProvider.getConfigurationContextBuilder();
+        builder.addDefaultPropertyConverters();
+    }
 
     private static class TestPropertySource implements PropertySource{
 

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/ccabc905/code/core/src/test/java/org/apache/tamaya/core/internal/converters/EnumConverterTest.java
----------------------------------------------------------------------
diff --git 
a/code/core/src/test/java/org/apache/tamaya/core/internal/converters/EnumConverterTest.java
 
b/code/core/src/test/java/org/apache/tamaya/core/internal/converters/EnumConverterTest.java
index 915ead9..6618961 100644
--- 
a/code/core/src/test/java/org/apache/tamaya/core/internal/converters/EnumConverterTest.java
+++ 
b/code/core/src/test/java/org/apache/tamaya/core/internal/converters/EnumConverterTest.java
@@ -33,7 +33,7 @@ import static org.junit.Assert.assertNull;
  */
 public class EnumConverterTest {
 
-    private final EnumConverter testConverter = new 
EnumConverter(RoundingMode.class);
+    private final EnumConverter<RoundingMode> testConverter = new 
EnumConverter<>(RoundingMode.class);
 
     private final ConversionContext DUMMY_CONTEXT = new 
ConversionContext.Builder("someKey", TypeLiteral.of(Enum.class)).build();
 

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/ccabc905/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 21797e3..fb73908 100644
--- a/pom.xml
+++ b/pom.xml
@@ -325,7 +325,7 @@
                     <artifactId>pitest-maven</artifactId>
                     <version>${pitest-plugin.version}</version>
                     <configuration>
-                        <mutationThreshold>52</mutationThreshold>
+                        <mutationThreshold>53</mutationThreshold>
                         <timestampedReports>false</timestampedReports>
                         <targetClasses>
                             <param>org.apache.tamaya.*</param>

Reply via email to