DefinitionsChildId extends GenericId { @Override public int compareTo(GenericId o1) { if (o1 instanceof DefinitionsChildId) { int res = this.getClass().getName().compareTo(o1.getClass().getName()); if (res == 0) { DefinitionsChildId o = (DefinitionsChildId) o1; res = VersionUtils.getNameWithoutVersion(this).compareTo(VersionUtils.getNameWithoutVersion(o)); if (res == 0) { res = VersionUtils.getVersion(this).compareTo(VersionUtils.getVersion(o)); } if (res == 0) { res = this.getNamespace().compareTo(o.getNamespace()); } } return res; } else { throw new IllegalStateException(); } } DefinitionsChildId(Namespace namespace, XmlId xmlId);  DefinitionsChildId(String ns, String id, boolean URLencoded);  DefinitionsChildId(QName qname); QName getQName(); Namespace getNamespace(); abstract String getGroup(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); String toReadableString(); @Override GenericId getParent(); @Override int compareTo(GenericId o1); static final List<Class<? extends DefinitionsChildId>> ALL_TOSCA_COMPONENT_ID_CLASSES; }
@Test public void testCompareToDifferentDefinitionsChildId() { String stId = "myDefinition"; String otherStId = "myOtherDefinition"; DefinitionsChildId serviceTemplate = new ServiceTemplateId("http: DefinitionsChildId otherServiceTemplate = new ServiceTemplateId("http: assertEquals(stId.compareTo(otherStId), serviceTemplate.compareTo(otherServiceTemplate)); }
@Test public void testCompareToDifferentNamespace() { String stNamespace = "http: String otherNamespace = "http: DefinitionsChildId serviceTemplate = new ServiceTemplateId(stNamespace, "myDefinition", false); DefinitionsChildId otherServiceTemplate = new ServiceTemplateId(otherNamespace, "myDefinition", false); assertEquals(stNamespace.compareTo(otherNamespace), serviceTemplate.compareTo(otherServiceTemplate)); }
@Test public void testCompareToDifferentSubClass() { DefinitionsChildId serviceTemplate = new ServiceTemplateId("http: DefinitionsChildId nodeType = new NodeTypeId("http: assertEquals("ServiceTemplate".compareTo("NodeType"), serviceTemplate.compareTo(nodeType)); }
@Test public void testCompareToEqualDefinitionsChildId() { DefinitionsChildId policyTemplate = new PolicyTemplateId("http: DefinitionsChildId secondPolicyTemplate = new PolicyTemplateId("http: assertEquals(0, policyTemplate.compareTo(secondPolicyTemplate)); }
@Test public void compareTwoDefinitionsWithDifferentVersions() { DefinitionsChildId newerVersion = new NodeTypeId("http: DefinitionsChildId olderVersion = new NodeTypeId("http: assertEquals(-1, olderVersion.compareTo(newerVersion)); assertEquals(1, newerVersion.compareTo(olderVersion)); }