brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hadr...@apache.org
Subject [20/21] incubator-brooklyn git commit: [BROOKLYN-183] Remove TestToSpecTransformer
Date Wed, 25 Nov 2015 01:55:30 GMT
[BROOKLYN-183] Remove TestToSpecTransformer

Slipped in while syncing with master


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

Branch: refs/heads/master
Commit: b514adbdbf4def6c601ce8aaf16879b3b19a11ad
Parents: 943c137
Author: Ciprian Ciubotariu <cheepeero@gmx.net>
Authored: Tue Nov 24 23:45:10 2015 +0200
Committer: Ciprian Ciubotariu <cheepeero@gmx.net>
Committed: Tue Nov 24 23:45:10 2015 +0200

----------------------------------------------------------------------
 .../catalog/internal/TestToSpecTransformer.java | 118 -------------------
 1 file changed, 118 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/b514adbd/core/src/test/java/org/apache/brooklyn/core/catalog/internal/TestToSpecTransformer.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/brooklyn/core/catalog/internal/TestToSpecTransformer.java
b/core/src/test/java/org/apache/brooklyn/core/catalog/internal/TestToSpecTransformer.java
deleted file mode 100644
index 86b0e0e..0000000
--- a/core/src/test/java/org/apache/brooklyn/core/catalog/internal/TestToSpecTransformer.java
+++ /dev/null
@@ -1,118 +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.
- */
-package org.apache.brooklyn.core.catalog.internal;
-
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-
-import org.apache.brooklyn.api.catalog.CatalogItem;
-import org.apache.brooklyn.api.entity.Application;
-import org.apache.brooklyn.api.entity.EntitySpec;
-import org.apache.brooklyn.api.internal.AbstractBrooklynObjectSpec;
-import org.apache.brooklyn.api.mgmt.ManagementContext;
-import org.apache.brooklyn.core.plan.PlanNotRecognizedException;
-import org.apache.brooklyn.core.plan.PlanToSpecTransformer;
-import org.apache.brooklyn.util.text.Identifiers;
-import org.apache.brooklyn.util.yaml.Yamls;
-
-/**
- * Resolves previously registered specs by id.
- * First create a spec and register it, keeping the returned ID:
- * <pre> {@code
- * String specId = TestToSpecTransformer.registerSpec(EntitySpec.create(BasicEntity.class));
- * }</pre>
- *
- * Then build a plan to be resolved such as:
- * <pre> {@code
- *  brooklyn.catalog:
- *    id: test.inputs
- *    version: 0.0.1
- *    item: <specId>
- * } </pre>
- */
-public class TestToSpecTransformer implements PlanToSpecTransformer {
-    private static final Map<String, AbstractBrooklynObjectSpec<?, ?>> REGISTERED_SPECS
= new ConcurrentHashMap<>();
-    public static String registerSpec(AbstractBrooklynObjectSpec<?, ?> spec) {
-        String id = Identifiers.makeRandomId(10);
-        REGISTERED_SPECS.put(id, spec);
-        return id;
-    }
-
-    @Override
-    public void setManagementContext(ManagementContext managementContext) {
-    }
-
-    @Override
-    public String getShortDescription() {
-        return "test";
-    }
-
-    @Override
-    public boolean accepts(String planType) {
-        return "test".equals(planType);
-    }
-
-    @SuppressWarnings("unchecked")
-    @Override
-    public EntitySpec<? extends Application> createApplicationSpec(String plan) throws
PlanNotRecognizedException {
-        return (EntitySpec<? extends Application>) getSpec(plan);
-    }
-
-    @SuppressWarnings("unchecked")
-    @Override
-    public <T, SpecT extends AbstractBrooklynObjectSpec<? extends T, SpecT>>
SpecT createCatalogSpec(CatalogItem<T, SpecT> item, Set<String> encounteredTypes)

-            throws PlanNotRecognizedException {
-        return (SpecT) getSpecFromPlan(item.getPlanYaml());
-    }
-
-    private AbstractBrooklynObjectSpec<?,?> getSpecFromPlan(String plan) {
-        if (plan != null) {
-            Object planRaw = Yamls.parseAll(plan).iterator().next();
-            if (planRaw instanceof String) {
-                return getSpec((String)planRaw);
-            } else if (planRaw instanceof Map) {
-                // The catalog parser assumes it's dealing with CAMP specs so will helpfully
-                // prepend "type: " if it's an inline item.
-                return getSpec((String)((Map<?, ?>)planRaw).get("type"));
-            } else {
-                throw notRecognized();
-            }
-        } else {
-            throw notRecognized();
-        }
-    }
-
-    private AbstractBrooklynObjectSpec<?,?> getSpec(String plan) {
-        if (plan == null) {
-            throw notRecognized();
-        }
-        AbstractBrooklynObjectSpec<?, ?> spec = REGISTERED_SPECS.get(plan);
-        if (spec != null) {
-            return spec;
-        } else {
-            throw notRecognized();
-        }
-    }
-
-    private PlanNotRecognizedException notRecognized() {
-        return new PlanNotRecognizedException("Not recognized as registered spec");
-    }
-
-}


Mime
View raw message