### Question:
FhirUriUtils { @Nonnull public static IIdType createIdFromUri( @Nonnull String uri, @Nullable FhirResourceType fhirResourceType ) throws IllegalArgumentException { final Matcher matcher = CANONICAL_PATTERN.matcher( uri ); if ( !matcher.matches() ) { throw new IllegalArgumentException( "URI is invalid: " + uri ); } String resourceTypeName = matcher.group( 1 ); final String id = matcher.group( 2 ); if ( resourceTypeName == null && fhirResourceType != null ) { resourceTypeName = fhirResourceType.getResourceTypeName(); } if ( resourceTypeName == null ) { throw new IllegalArgumentException( "URI must include a valid FHIR resource type: " + uri ); } if ( fhirResourceType != null && !fhirResourceType.getResourceTypeName().equals( resourceTypeName ) ) { throw new IllegalArgumentException( "Resource type in URI differs from expected resource type " + fhirResourceType + ": " + uri ); } return new IdDt( resourceTypeName, id ); } private  FhirUriUtils(); @Nonnull static IIdType createIdFromUri( @Nonnull String uri, @Nullable FhirResourceType fhirResourceType );  }### Answer:
@Test public void createIdFromUri() { final IIdType id = FhirUriUtils.createIdFromUri( "Location/4711", null ); Assert.assertEquals( "Location/4711", id.getValue() ); }
@Test public void createIdFromUriWithType() { final IIdType id = FhirUriUtils.createIdFromUri( "Location/4711", FhirResourceType.LOCATION ); Assert.assertEquals( "Location/4711", id.getValue() ); }
@Test public void createIdFromUriWithUnspecifiedType() { final IIdType id = FhirUriUtils.createIdFromUri( "4711", FhirResourceType.LOCATION ); Assert.assertEquals( "Location/4711", id.getValue() ); }
@Test( expected = IllegalArgumentException.class ) public void createIdFromUriWithNonMatchingType() { FhirUriUtils.createIdFromUri( "Location/4711", FhirResourceType.ORGANIZATION ); }
@Test( expected = IllegalArgumentException.class ) public void createIdFromUriWithMissingType() { FhirUriUtils.createIdFromUri( "4711", null ); }
@Test( expected = IllegalArgumentException.class ) public void createIdFromUriInvalid() { FhirUriUtils.createIdFromUri( "No/Location/4711", FhirResourceType.LOCATION ); }