This is an automated email from the ASF dual-hosted git repository.

heneveld pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/brooklyn-server.git

commit 61d759ded934d770bf316b9afd32948ab0a6db10
Author: Alex Heneveld <a...@cloudsoft.io>
AuthorDate: Mon Apr 8 17:44:10 2024 +0100

    tidy deprecated and unused
    
    versioned name fields
---
 .../brooklyn/camp/brooklyn/WorkflowYamlTest.java   |  8 -----
 .../core/mgmt/rebind/MiscClassesRebindTest.java    | 20 -----------
 ...2017-06-versionedname-entity-n7p20t5h4o.memento | 42 ----------------------
 .../apache/brooklyn/util/osgi/VersionedName.java   | 21 ++++-------
 4 files changed, 7 insertions(+), 84 deletions(-)

diff --git 
a/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/WorkflowYamlTest.java
 
b/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/WorkflowYamlTest.java
index a4dc8d3bc1..f69138a4f8 100644
--- 
a/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/WorkflowYamlTest.java
+++ 
b/camp/camp-brooklyn/src/test/java/org/apache/brooklyn/camp/brooklyn/WorkflowYamlTest.java
@@ -109,14 +109,6 @@ public class WorkflowYamlTest extends AbstractYamlTest {
                 new 
BasicTypeImplementationPlan(JavaClassNameTypePlanTransformer.FORMAT, 
clazz.getName()));
     }
 
-    static RegisteredType addRegisteredTypeSpec(ManagementContext mgmt, String 
symName, Class<?> clazz, Class<? extends BrooklynObject> superClazz) {
-        RegisteredType rt = RegisteredTypes.spec(symName, VERSION,
-                new 
BasicTypeImplementationPlan(JavaClassNameTypePlanTransformer.FORMAT, 
clazz.getName()));
-        RegisteredTypes.addSuperType(rt, superClazz);
-        mgmt.getCatalog().validateType(rt, null, false);
-        return mgmt.getTypeRegistry().get(rt.getSymbolicName(), 
rt.getVersion());
-    }
-
     public static void addWorkflowTypes(ManagementContext mgmt) {
         WorkflowBasicTest.addWorkflowStepTypes(mgmt);
 
diff --git 
a/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/MiscClassesRebindTest.java
 
b/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/MiscClassesRebindTest.java
index bbc40d0717..b945dca72c 100644
--- 
a/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/MiscClassesRebindTest.java
+++ 
b/core/src/test/java/org/apache/brooklyn/core/mgmt/rebind/MiscClassesRebindTest.java
@@ -103,25 +103,5 @@ public class MiscClassesRebindTest extends 
RebindTestFixtureWithApp {
         return (T) e.getConfig(TEST_KEY);
     }
 
-    
-    @Test
-    public void testVersionedName() throws Exception {
-        VersionedName vn = 
getTestKeyFromEntityMemento("2017-06-versionedname", "n7p20t5h4o", 
VersionedName.class);
-        Assert.assertEquals(vn, new VersionedName("foo", "1.0.0-foo"));
-        Assert.assertNotEquals(vn, new VersionedName("foo", "1.0.0.foo"));
-        Assert.assertTrue(vn.equalsOsgi(new VersionedName("foo", 
Version.parseVersion("1.0.0.foo"))));
-        
-        String newEntityContent = getEntityMementoContent();
-        // log.info("New VN persistence is\n"+newEntityContent);
-        Asserts.assertStringContains(newEntityContent, "1.0.0-foo");
-        // phrases from original persisted state are changed
-        Asserts.assertStringDoesNotContain(newEntityContent, 
"<symbolicName>foo");
-        Asserts.assertStringDoesNotContain(newEntityContent, "<version>1.0.0");
-        Asserts.assertStringDoesNotContain(newEntityContent, "1.0.0.foo");
-        // they should now be this
-        Asserts.assertStringContains(newEntityContent, "<name>foo");
-        Asserts.assertStringContains(newEntityContent, "<v>1.0.0-foo");
-    }
-
 }
 
diff --git 
a/core/src/test/resources/org/apache/brooklyn/core/mgmt/rebind/MiscClassesRebindTest-2017-06-versionedname-entity-n7p20t5h4o.memento
 
b/core/src/test/resources/org/apache/brooklyn/core/mgmt/rebind/MiscClassesRebindTest-2017-06-versionedname-entity-n7p20t5h4o.memento
deleted file mode 100644
index 0b98cbd353..0000000000
--- 
a/core/src/test/resources/org/apache/brooklyn/core/mgmt/rebind/MiscClassesRebindTest-2017-06-versionedname-entity-n7p20t5h4o.memento
+++ /dev/null
@@ -1,42 +0,0 @@
-<!--
-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.
--->
-
-<entity>
-  <brooklynVersion>0.12.0-SNAPSHOT</brooklynVersion>
-  
<type>org.apache.brooklyn.core.test.entity.TestApplicationNoEnrichersImpl</type>
-  <id>n7p20t5h4o</id>
-  <displayName>TestApplicationNoEnrichersImpl:n7p2</displayName>
-  <config>
-    <testKey>
-      <org.apache.brooklyn.util.osgi.VersionedName>
-        <symbolicName>foo</symbolicName>
-        <version>
-          <major>1</major>
-          <minor>0</minor>
-          <micro>0</micro>
-          <qualifier>foo</qualifier>
-        </version>
-      </org.apache.brooklyn.util.osgi.VersionedName>
-    </testKey>
-  </config>
-  <attributes>
-    <entity.id>n7p20t5h4o</entity.id>
-    <application.id>n7p20t5h4o</application.id>
-  </attributes>
-</entity>
diff --git 
a/utils/common/src/main/java/org/apache/brooklyn/util/osgi/VersionedName.java 
b/utils/common/src/main/java/org/apache/brooklyn/util/osgi/VersionedName.java
index de3a64b0d3..3c8bda55f8 100644
--- 
a/utils/common/src/main/java/org/apache/brooklyn/util/osgi/VersionedName.java
+++ 
b/utils/common/src/main/java/org/apache/brooklyn/util/osgi/VersionedName.java
@@ -21,6 +21,8 @@ import java.util.Comparator;
 
 import javax.annotation.Nullable;
 
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
 import org.apache.brooklyn.util.guava.Maybe;
 import org.apache.brooklyn.util.text.BrooklynVersionSyntax;
 import org.apache.brooklyn.util.text.NaturalOrderComparator;
@@ -34,26 +36,17 @@ import com.google.common.collect.ComparisonChain;
 
 /** Records a name (string) and version (string),
  * with conveniences for pretty-printing and converting to OSGi format. */
+@JsonInclude(Include.NON_EMPTY)
 public class VersionedName implements Comparable<VersionedName> {
     private final String name;
     private final String v;
-    
-    @Deprecated // since 0.12.0 - remove along with version and readResolve in 
1.0.0
+
+    @Deprecated // since 0.12.0 - but null was not omitted in jackson 
serialization, so remove these fields after 1.2
     private final String symbolicName = null;
-    @Deprecated // since 0.12.0
+    @Deprecated // since 0.12.0 - but null was not omitted in jackson 
serialization, so remove these fields after 1.2
     private final Version version = null;
-    
 
-    private Object readResolve() {
-        if (symbolicName!=null || version!=null) {
-            // remove legacy fields, and convert to brooklyn recommended 
version in the process
-            // (might be slightly weird if bundles are persisted, but code 
will forgive that,
-            // and if types were persisted this will do the right thing)
-            return new VersionedName(symbolicName, 
BrooklynVersionSyntax.toGoodBrooklynVersion( version.toString() ));
-        }
-        return this;
-    }
-    
+
     public VersionedName(Bundle b) {
         this(b.getSymbolicName(), b.getVersion().toString());
     }

Reply via email to