@Test public void testToKafkaResourcePatternForGroupResource() { SimpleAclRuleResource groupResourceRules = new SimpleAclRuleResource("my-group", SimpleAclRuleResourceType.GROUP, AclResourcePatternType.LITERAL); ResourcePattern expectedKafkaResourcePattern = new ResourcePattern(ResourceType.GROUP, "my-group", PatternType.LITERAL); assertThat(groupResourceRules.toKafkaResourcePattern(), is(expectedKafkaResourcePattern)); groupResourceRules = new SimpleAclRuleResource("my-", SimpleAclRuleResourceType.GROUP, AclResourcePatternType.PREFIX); expectedKafkaResourcePattern = new ResourcePattern(ResourceType.GROUP, "my-", PatternType.PREFIXED); assertThat(groupResourceRules.toKafkaResourcePattern(), is(expectedKafkaResourcePattern)); }
public ResourcePattern toKafkaResourcePattern() { org.apache.kafka.common.resource.ResourceType kafkaType; String kafkaName; PatternType kafkaPattern = PatternType.LITERAL; switch (type) { case TOPIC: kafkaType = org.apache.kafka.common.resource.ResourceType.TOPIC; kafkaName = name; if (AclResourcePatternType.PREFIX.equals(pattern)) { kafkaPattern = PatternType.PREFIXED; } break; case GROUP: kafkaType = org.apache.kafka.common.resource.ResourceType.GROUP; kafkaName = name; if (AclResourcePatternType.PREFIX.equals(pattern)) { kafkaPattern = PatternType.PREFIXED; } break; case CLUSTER: kafkaType = org.apache.kafka.common.resource.ResourceType.CLUSTER; kafkaName = "kafka-cluster"; break; case TRANSACTIONAL_ID: kafkaType = org.apache.kafka.common.resource.ResourceType.TRANSACTIONAL_ID; kafkaName = name; if (AclResourcePatternType.PREFIX.equals(pattern)) { kafkaPattern = PatternType.PREFIXED; } break; default: throw new IllegalArgumentException("Invalid Acl resource type: " + type); } return new ResourcePattern(kafkaType, kafkaName, kafkaPattern); }
SimpleAclRuleResource { public ResourcePattern toKafkaResourcePattern() { org.apache.kafka.common.resource.ResourceType kafkaType; String kafkaName; PatternType kafkaPattern = PatternType.LITERAL; switch (type) { case TOPIC: kafkaType = org.apache.kafka.common.resource.ResourceType.TOPIC; kafkaName = name; if (AclResourcePatternType.PREFIX.equals(pattern)) { kafkaPattern = PatternType.PREFIXED; } break; case GROUP: kafkaType = org.apache.kafka.common.resource.ResourceType.GROUP; kafkaName = name; if (AclResourcePatternType.PREFIX.equals(pattern)) { kafkaPattern = PatternType.PREFIXED; } break; case CLUSTER: kafkaType = org.apache.kafka.common.resource.ResourceType.CLUSTER; kafkaName = "kafka-cluster"; break; case TRANSACTIONAL_ID: kafkaType = org.apache.kafka.common.resource.ResourceType.TRANSACTIONAL_ID; kafkaName = name; if (AclResourcePatternType.PREFIX.equals(pattern)) { kafkaPattern = PatternType.PREFIXED; } break; default: throw new IllegalArgumentException("Invalid Acl resource type: " + type); } return new ResourcePattern(kafkaType, kafkaName, kafkaPattern); } }
SimpleAclRuleResource { public ResourcePattern toKafkaResourcePattern() { org.apache.kafka.common.resource.ResourceType kafkaType; String kafkaName; PatternType kafkaPattern = PatternType.LITERAL; switch (type) { case TOPIC: kafkaType = org.apache.kafka.common.resource.ResourceType.TOPIC; kafkaName = name; if (AclResourcePatternType.PREFIX.equals(pattern)) { kafkaPattern = PatternType.PREFIXED; } break; case GROUP: kafkaType = org.apache.kafka.common.resource.ResourceType.GROUP; kafkaName = name; if (AclResourcePatternType.PREFIX.equals(pattern)) { kafkaPattern = PatternType.PREFIXED; } break; case CLUSTER: kafkaType = org.apache.kafka.common.resource.ResourceType.CLUSTER; kafkaName = "kafka-cluster"; break; case TRANSACTIONAL_ID: kafkaType = org.apache.kafka.common.resource.ResourceType.TRANSACTIONAL_ID; kafkaName = name; if (AclResourcePatternType.PREFIX.equals(pattern)) { kafkaPattern = PatternType.PREFIXED; } break; default: throw new IllegalArgumentException("Invalid Acl resource type: " + type); } return new ResourcePattern(kafkaType, kafkaName, kafkaPattern); } SimpleAclRuleResource(String name, SimpleAclRuleResourceType type, AclResourcePatternType pattern); }
SimpleAclRuleResource { public ResourcePattern toKafkaResourcePattern() { org.apache.kafka.common.resource.ResourceType kafkaType; String kafkaName; PatternType kafkaPattern = PatternType.LITERAL; switch (type) { case TOPIC: kafkaType = org.apache.kafka.common.resource.ResourceType.TOPIC; kafkaName = name; if (AclResourcePatternType.PREFIX.equals(pattern)) { kafkaPattern = PatternType.PREFIXED; } break; case GROUP: kafkaType = org.apache.kafka.common.resource.ResourceType.GROUP; kafkaName = name; if (AclResourcePatternType.PREFIX.equals(pattern)) { kafkaPattern = PatternType.PREFIXED; } break; case CLUSTER: kafkaType = org.apache.kafka.common.resource.ResourceType.CLUSTER; kafkaName = "kafka-cluster"; break; case TRANSACTIONAL_ID: kafkaType = org.apache.kafka.common.resource.ResourceType.TRANSACTIONAL_ID; kafkaName = name; if (AclResourcePatternType.PREFIX.equals(pattern)) { kafkaPattern = PatternType.PREFIXED; } break; default: throw new IllegalArgumentException("Invalid Acl resource type: " + type); } return new ResourcePattern(kafkaType, kafkaName, kafkaPattern); } SimpleAclRuleResource(String name, SimpleAclRuleResourceType type, AclResourcePatternType pattern); String getName(); SimpleAclRuleResourceType getType(); AclResourcePatternType getPattern(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); ResourcePattern toKafkaResourcePattern(); static SimpleAclRuleResource fromKafkaResourcePattern(ResourcePattern kafkaResourcePattern); static SimpleAclRuleResource fromCrd(AclRuleResource resource); }
SimpleAclRuleResource { public ResourcePattern toKafkaResourcePattern() { org.apache.kafka.common.resource.ResourceType kafkaType; String kafkaName; PatternType kafkaPattern = PatternType.LITERAL; switch (type) { case TOPIC: kafkaType = org.apache.kafka.common.resource.ResourceType.TOPIC; kafkaName = name; if (AclResourcePatternType.PREFIX.equals(pattern)) { kafkaPattern = PatternType.PREFIXED; } break; case GROUP: kafkaType = org.apache.kafka.common.resource.ResourceType.GROUP; kafkaName = name; if (AclResourcePatternType.PREFIX.equals(pattern)) { kafkaPattern = PatternType.PREFIXED; } break; case CLUSTER: kafkaType = org.apache.kafka.common.resource.ResourceType.CLUSTER; kafkaName = "kafka-cluster"; break; case TRANSACTIONAL_ID: kafkaType = org.apache.kafka.common.resource.ResourceType.TRANSACTIONAL_ID; kafkaName = name; if (AclResourcePatternType.PREFIX.equals(pattern)) { kafkaPattern = PatternType.PREFIXED; } break; default: throw new IllegalArgumentException("Invalid Acl resource type: " + type); } return new ResourcePattern(kafkaType, kafkaName, kafkaPattern); } SimpleAclRuleResource(String name, SimpleAclRuleResourceType type, AclResourcePatternType pattern); String getName(); SimpleAclRuleResourceType getType(); AclResourcePatternType getPattern(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); ResourcePattern toKafkaResourcePattern(); static SimpleAclRuleResource fromKafkaResourcePattern(ResourcePattern kafkaResourcePattern); static SimpleAclRuleResource fromCrd(AclRuleResource resource);  }