THis change adds a method to create a ToscaConceptIdentifer from a
ToscaEntityKey class. This method reduces the code vloume when
translating between these identifiers.
Issue-ID: POLICY-2971
Change-Id: Idd62339935d2ba78e6c60b40ee95fedac0642bef
Signed-off-by: liamfallon <liam.fallon@est.tech>
/*-
* ============LICENSE_START=======================================================
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
+ * Copyright (C) 2019, 2021 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
public class ToscaEntityKey {
private String name;
private String version;
public class ToscaEntityKey {
private String name;
private String version;
+
+ public ToscaConceptIdentifier asIdentifier() {
+ return new ToscaConceptIdentifier(name, version);
+ }
policy.setTypeVersion("3.2.1");
assertEquals("ToscaEntityKey(name=my_name, version=1.2.3)", policy.getKey().toString());
policy.setTypeVersion("3.2.1");
assertEquals("ToscaEntityKey(name=my_name, version=1.2.3)", policy.getKey().toString());
+ assertEquals(new ToscaConceptIdentifier("my_name", "1.2.3"), policy.getKey().asIdentifier());
ToscaConceptIdentifier ident = policy.getIdentifier();
assertEquals("my_name", ident.getName());
ToscaConceptIdentifier ident = policy.getIdentifier();
assertEquals("my_name", ident.getName());