### Question:
InformationItemPrimaryPropertyConverter { static String getParentName(final org.kie.dmn.model.api.DMNModelInstrumentedBase parent) { if (parent instanceof NamedElement) { final NamedElement namedElement = (NamedElement) parent; final Optional<String> name = Optional.ofNullable(namedElement.getName()); return name.orElse(DEFAULT_NAME); } return DEFAULT_NAME; }  static InformationItemPrimary wbFromDMN(final InformationItem dmn,
                                                   final org.kie.dmn.model.api.DMNModelInstrumentedBase parent); static TInformationItem dmnFromWB(final InformationItemPrimary wb,
                                             final DMNModelInstrumentedBase parent);  }### Answer:
@Test public void testDMNGetNameWhenParentDoesNotHaveName() { final org.kie.dmn.model.api.InformationItem parent = mock(org.kie.dmn.model.api.InformationItem.class); final String name = InformationItemPrimaryPropertyConverter.getParentName(parent); assertTrue(name.isEmpty()); }
@Test public void testDMNGetNameWhenParentHasNullName() { final org.kie.dmn.model.api.InputData parent = mock(org.kie.dmn.model.api.InputData.class); when(parent.getName()).thenReturn(null); final String name = InformationItemPrimaryPropertyConverter.getParentName(parent); assertTrue(name.isEmpty()); }
@Test public void testDMNGetNameWhenParentHasName() { final org.kie.dmn.model.api.InputData parent = mock(org.kie.dmn.model.api.InputData.class); final String expectedName = "name"; when(parent.getName()).thenReturn(expectedName); final String actualName = InformationItemPrimaryPropertyConverter.getParentName(parent); assertEquals(expectedName, actualName); }
@Test public void testWBGetNameWhenParentDoesNotHaveName() { final InformationItemPrimary parent = mock(InformationItemPrimary.class); final String name = InformationItemPrimaryPropertyConverter.getParentName(parent); assertTrue(name.isEmpty()); }
@Test public void testWBGetNameWhenParentHasNullName() { final InputData parent = mock(InputData.class); when(parent.getName()).thenReturn(null); final String name = InformationItemPrimaryPropertyConverter.getParentName(parent); assertTrue(name.isEmpty()); }
@Test public void testWBGetNameWhenParentHasName() { final InputData parent = mock(InputData.class); final Name parentName = mock(Name.class); final String expectedName = "name"; when(parent.getName()).thenReturn(parentName); when(parentName.getValue()).thenReturn(expectedName); final String actualName = InformationItemPrimaryPropertyConverter.getParentName(parent); assertEquals(expectedName, actualName); }