@Test public void shouldGenerateGcpAttachedDiskResourceWhenPartsProvided() { Object[] parts = {"stack", "group", 3, 2}; String resourceName = subject.resourceName(ResourceType.GCP_ATTACHED_DISKSET, parts); Assert.assertNotNull("The generated name must not be null!", resourceName); Assert.assertEquals("The timestamp must be appended", 5L, resourceName.split("-").length); Assert.assertTrue("The resource name is not the expected one!", resourceName.startsWith("stack-g-3-2")); }
@Override public String resourceName(ResourceType resourceType, Object... parts) { String resourceName; switch (resourceType) { case GCP_NETWORK: resourceName = gcpNetworkResourceName(parts); break; case GCP_SUBNET: resourceName = gcpSubnetResourceName(parts); break; case GCP_FIREWALL_INTERNAL: resourceName = stackBasedResourceWithSuffix(FIREWALL_INTERNAL_NAME_SUFFIX, parts); break; case GCP_FIREWALL_IN: resourceName = stackBasedResourceWithSuffix(FIREWALL_IN_NAME_SUFFIX, parts); break; case GCP_RESERVED_IP: resourceName = instanceName(parts); break; case GCP_INSTANCE: resourceName = instanceName(parts); break; case GCP_DISK: resourceName = instanceName(parts); break; case GCP_ATTACHED_DISKSET: resourceName = attachedDiskResourceName(parts); break; case GCP_DATABASE: resourceName = deploymentTemplateName(parts); break; default: throw new IllegalStateException("Unsupported resource type: " + resourceType); } return resourceName; }
GcpResourceNameService extends CloudbreakResourceNameService { @Override public String resourceName(ResourceType resourceType, Object... parts) { String resourceName; switch (resourceType) { case GCP_NETWORK: resourceName = gcpNetworkResourceName(parts); break; case GCP_SUBNET: resourceName = gcpSubnetResourceName(parts); break; case GCP_FIREWALL_INTERNAL: resourceName = stackBasedResourceWithSuffix(FIREWALL_INTERNAL_NAME_SUFFIX, parts); break; case GCP_FIREWALL_IN: resourceName = stackBasedResourceWithSuffix(FIREWALL_IN_NAME_SUFFIX, parts); break; case GCP_RESERVED_IP: resourceName = instanceName(parts); break; case GCP_INSTANCE: resourceName = instanceName(parts); break; case GCP_DISK: resourceName = instanceName(parts); break; case GCP_ATTACHED_DISKSET: resourceName = attachedDiskResourceName(parts); break; case GCP_DATABASE: resourceName = deploymentTemplateName(parts); break; default: throw new IllegalStateException("Unsupported resource type: " + resourceType); } return resourceName; } }
GcpResourceNameService extends CloudbreakResourceNameService { @Override public String resourceName(ResourceType resourceType, Object... parts) { String resourceName; switch (resourceType) { case GCP_NETWORK: resourceName = gcpNetworkResourceName(parts); break; case GCP_SUBNET: resourceName = gcpSubnetResourceName(parts); break; case GCP_FIREWALL_INTERNAL: resourceName = stackBasedResourceWithSuffix(FIREWALL_INTERNAL_NAME_SUFFIX, parts); break; case GCP_FIREWALL_IN: resourceName = stackBasedResourceWithSuffix(FIREWALL_IN_NAME_SUFFIX, parts); break; case GCP_RESERVED_IP: resourceName = instanceName(parts); break; case GCP_INSTANCE: resourceName = instanceName(parts); break; case GCP_DISK: resourceName = instanceName(parts); break; case GCP_ATTACHED_DISKSET: resourceName = attachedDiskResourceName(parts); break; case GCP_DATABASE: resourceName = deploymentTemplateName(parts); break; default: throw new IllegalStateException("Unsupported resource type: " + resourceType); } return resourceName; }  }
GcpResourceNameService extends CloudbreakResourceNameService { @Override public String resourceName(ResourceType resourceType, Object... parts) { String resourceName; switch (resourceType) { case GCP_NETWORK: resourceName = gcpNetworkResourceName(parts); break; case GCP_SUBNET: resourceName = gcpSubnetResourceName(parts); break; case GCP_FIREWALL_INTERNAL: resourceName = stackBasedResourceWithSuffix(FIREWALL_INTERNAL_NAME_SUFFIX, parts); break; case GCP_FIREWALL_IN: resourceName = stackBasedResourceWithSuffix(FIREWALL_IN_NAME_SUFFIX, parts); break; case GCP_RESERVED_IP: resourceName = instanceName(parts); break; case GCP_INSTANCE: resourceName = instanceName(parts); break; case GCP_DISK: resourceName = instanceName(parts); break; case GCP_ATTACHED_DISKSET: resourceName = attachedDiskResourceName(parts); break; case GCP_DATABASE: resourceName = deploymentTemplateName(parts); break; default: throw new IllegalStateException("Unsupported resource type: " + resourceType); } return resourceName; }  @Override String resourceName(ResourceType resourceType, Object... parts); }
GcpResourceNameService extends CloudbreakResourceNameService { @Override public String resourceName(ResourceType resourceType, Object... parts) { String resourceName; switch (resourceType) { case GCP_NETWORK: resourceName = gcpNetworkResourceName(parts); break; case GCP_SUBNET: resourceName = gcpSubnetResourceName(parts); break; case GCP_FIREWALL_INTERNAL: resourceName = stackBasedResourceWithSuffix(FIREWALL_INTERNAL_NAME_SUFFIX, parts); break; case GCP_FIREWALL_IN: resourceName = stackBasedResourceWithSuffix(FIREWALL_IN_NAME_SUFFIX, parts); break; case GCP_RESERVED_IP: resourceName = instanceName(parts); break; case GCP_INSTANCE: resourceName = instanceName(parts); break; case GCP_DISK: resourceName = instanceName(parts); break; case GCP_ATTACHED_DISKSET: resourceName = attachedDiskResourceName(parts); break; case GCP_DATABASE: resourceName = deploymentTemplateName(parts); break; default: throw new IllegalStateException("Unsupported resource type: " + resourceType); } return resourceName; }  @Override String resourceName(ResourceType resourceType, Object... parts);  }