brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject [1/8] incubator-brooklyn git commit: Introduce relationships between brooklyn objects
Date Tue, 27 Oct 2015 14:48:23 GMT
Repository: incubator-brooklyn
Updated Branches:
  refs/heads/master c6273b891 -> 52241ae61


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/772e707f/core/src/test/java/org/apache/brooklyn/core/relations/RelationshipTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/relations/RelationshipTest.java b/core/src/test/java/org/apache/brooklyn/core/relations/RelationshipTest.java
new file mode 100644
index 0000000..ba114dd
--- /dev/null
+++ b/core/src/test/java/org/apache/brooklyn/core/relations/RelationshipTest.java
@@ -0,0 +1,58 @@
+/*
+ * 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.brooklyn.core.relations;
+
+import org.apache.brooklyn.api.entity.Entity;
+import org.apache.brooklyn.core.test.entity.TestEntity;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import brooklyn.basic.relations.Relationship;
+
+@Test
+public class RelationshipTest {
+
+    static Relationship<Entity, TestEntity> AUNTIE_OF = Relationships.newRelationshipPair(
+        "auntie", "aunties", Entity.class, "auntie_of_nephew",
+        "nephew", "nephews", TestEntity.class, "nephew_of_auntie");
+    
+    static Relationship<TestEntity, Entity> NEPHEW_OF = AUNTIE_OF.getInverseRelationship();
+    
+    public void testFields() {
+        Assert.assertEquals(AUNTIE_OF.getRelationshipTypeName(), "auntie_of_nephew");
+        Assert.assertEquals(AUNTIE_OF.getSourceType(), Entity.class);
+        Assert.assertEquals(AUNTIE_OF.getTargetType(), TestEntity.class);
+        Assert.assertEquals(AUNTIE_OF.getSourceName(), "auntie");
+        Assert.assertEquals(AUNTIE_OF.getTargetName(), "nephew");
+        Assert.assertEquals(AUNTIE_OF.getSourceNamePlural(), "aunties");
+        Assert.assertEquals(AUNTIE_OF.getTargetNamePlural(), "nephews");
+        
+        Assert.assertEquals(NEPHEW_OF.getRelationshipTypeName(), "nephew_of_auntie");
+        Assert.assertEquals(NEPHEW_OF.getSourceType(), TestEntity.class);
+        Assert.assertEquals(NEPHEW_OF.getTargetType(), Entity.class);
+        Assert.assertEquals(NEPHEW_OF.getSourceName(), "nephew");
+        Assert.assertEquals(NEPHEW_OF.getTargetName(), "auntie");
+        Assert.assertEquals(NEPHEW_OF.getSourceNamePlural(), "nephews");
+        Assert.assertEquals(NEPHEW_OF.getTargetNamePlural(), "aunties");
+        
+        Assert.assertEquals(NEPHEW_OF.getInverseRelationship(), AUNTIE_OF);
+        Assert.assertEquals(AUNTIE_OF.getInverseRelationship(), NEPHEW_OF);
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/772e707f/core/src/test/java/org/apache/brooklyn/util/core/internal/FlagUtilsTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/util/core/internal/FlagUtilsTest.java
b/core/src/test/java/org/apache/brooklyn/util/core/internal/FlagUtilsTest.java
index 81c760e..a75db17 100644
--- a/core/src/test/java/org/apache/brooklyn/util/core/internal/FlagUtilsTest.java
+++ b/core/src/test/java/org/apache/brooklyn/util/core/internal/FlagUtilsTest.java
@@ -272,6 +272,11 @@ public class FlagUtilsTest {
             return configSupport;
         }
         
+        @Override
+        public <T> T getConfig(ConfigKey<T> key) {
+            return config().get(key);
+        }
+        
         public <T> T setConfig(ConfigKey<T> key, T val) {
             return config().set(key, val);
         }

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/772e707f/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/ObjectsYamlTest.java
----------------------------------------------------------------------
diff --git a/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/ObjectsYamlTest.java
b/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/ObjectsYamlTest.java
index b278f02..e16d825 100644
--- a/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/ObjectsYamlTest.java
+++ b/usage/camp/src/test/java/org/apache/brooklyn/camp/brooklyn/ObjectsYamlTest.java
@@ -97,6 +97,11 @@ public class ObjectsYamlTest extends AbstractYamlTest {
         public void setDouble(Double value) { this.value = value; }
 
         @Override
+        public <T> T getConfig(ConfigKey<T> key) {
+            return config().get(key);
+        }
+        
+        @Override
         public <T> T setConfig(ConfigKey<T> key, T value) {
             return config().set(key, value);
         }


Mime
View raw message