@SuppressWarnings("null")
@Test
public void testFragment() throws Exception {

    MetadataKey metadataKey = new MetadataKey("stateDescription", ITEM_NAME);
    Map<String, Object> metadataConfig = new HashMap<>();
    metadataConfig.put("pattern", "%.1f %unit%");
    metadataConfig.put("min", 18.5);
    metadataConfig.put("max", "34");
    metadataConfig.put("step", 3);
    metadataConfig.put("readOnly", "true");
    metadataConfig.put("options", "OPTION1,OPTION2 , 3 =Option 3 ");
    Metadata metadata = new Metadata(metadataKey, "N/A", metadataConfig);
    metadataRegistry.added(managedProvider, metadata);
    StateDescriptionFragment stateDescriptionFragment = stateDescriptionFragmentProvider
            .getStateDescriptionFragment(ITEM_NAME, null);
    assertNotNull(stateDescriptionFragment);
    assertEquals("%.1f %unit%", stateDescriptionFragment.getPattern());
    assertEquals(new BigDecimal(18.5), stateDescriptionFragment.getMinimum());
    assertEquals(new BigDecimal(34), stateDescriptionFragment.getMaximum());
    assertEquals(new BigDecimal(3), stateDescriptionFragment.getStep());
    assertEquals(true, stateDescriptionFragment.isReadOnly());
    assertNotNull(stateDescriptionFragment.getOptions());
    Iterator<StateOption> it = stateDescriptionFragment.getOptions().iterator();
    StateOption stateOption = it.next();
    assertEquals("OPTION1", stateOption.getValue());
    assertNull(stateOption.getLabel());
    stateOption = it.next();
    assertEquals("OPTION2", stateOption.getValue());
    assertNull(stateOption.getLabel());
    stateOption = it.next();
    assertEquals("3", stateOption.getValue());
    assertEquals("Option 3", stateOption.getLabel());
}