ServiceTypes { public synchronized static ServiceType get(Record record) { load(); String type = record.getType(); Objects.requireNonNull(type); ServiceType found = get(type); if (found != null) { return found; } else { throw new IllegalArgumentException("Unsupported service type " + type); } }  synchronized static ServiceType get(Record record); synchronized static Iterator<ServiceType> all(); synchronized static ServiceType get(String type);  }
@Test(expected = IllegalArgumentException.class) public void unknown() { Record record = new Record(); record.setType(ServiceType.UNKNOWN); ServiceTypes.get(record); }
@Test(expected = IllegalArgumentException.class) public void notAKnownType() { Record record = new Record(); record.setType("bob"); ServiceTypes.get(record); }