ConsumerTypeCurator extends AbstractHibernateCurator<ConsumerType> { public ConsumerType getByLabel(String label) { return this.getByLabel(label, false); } ConsumerTypeCurator(); ConsumerType getConsumerType(Consumer consumer); ConsumerType getByLabel(String label); ConsumerType getByLabel(String label, boolean createIfAbsent); @SuppressWarnings("unchecked") List<ConsumerType> getByLabels(Collection<String> labels);  }
@Test public void testgetByLabel() { String label = "test-label"; ConsumerType ctype = this.createConsumerType(label, false); ConsumerType test = this.consumerTypeCurator.getByLabel(label); assertSame(ctype, test); }
@Test public void testgetByLabelForBadLabel() { String label = "test-label"; ConsumerType ctype = this.createConsumerType(label, false); ConsumerType test = this.consumerTypeCurator.getByLabel("bad_label"); assertNull(test); }
@Test public void testgetByLabelExistingTypeWithCreation() { String label = "test-label"; ConsumerType ctype = this.createConsumerType(label, false); ConsumerType test = this.consumerTypeCurator.getByLabel(label, true); assertSame(ctype, test); }
@Test public void testgetByLabelNewTypeWithCreation() { String label = "new-ctype"; ConsumerType ctype = this.createConsumerType("test-type", true); ConsumerType test = this.consumerTypeCurator.getByLabel(label, true); assertNotNull(test); assertNotSame(ctype, test); assertEquals(label, test.getLabel()); }
@Test public void testgetByLabelNewTypeFromEnumWithCreation() { ConsumerTypeEnum cte = ConsumerTypeEnum.CANDLEPIN; ConsumerType ctype = this.createConsumerType("test-type", true); ConsumerType test = this.consumerTypeCurator.getByLabel(cte.getLabel(), true); assertNotNull(test); assertNotSame(ctype, test); assertEquals(cte.getLabel(), test.getLabel()); assertEquals(cte.isManifest(), test.isManifest()); }
@Test public void testgetByLabelWithNullLabel() { assertThrows(IllegalArgumentException.class, () -> consumerTypeCurator.getByLabel(null)); }
@Test public void testgetByLabelWithNullLabelAndCreation() { assertThrows(IllegalArgumentException.class, () -> consumerTypeCurator.getByLabel(null, true)); }
@Test public void testgetByLabelWithEmptyLabel() { assertThrows(IllegalArgumentException.class, () -> consumerTypeCurator.getByLabel("")); }
@Test public void testgetByLabelWithEmptyLabelAndCreation() { assertThrows(IllegalArgumentException.class, () -> consumerTypeCurator.getByLabel("", true)); }