@Test public void prettifyKey_withTwoLevelParentKey() { KeyDto childKeyDto = mock(KeyDto.class); given(childKeyDto.getKind()).willReturn("child_kind"); given(childKeyDto.getId()).willReturn(3L); KeyDto parentKeyDto = mock(KeyDto.class); given(parentKeyDto.getKind()).willReturn("parent_kind"); given(parentKeyDto.getId()).willReturn(1L); KeyDto grandParentKeyDto = mock(KeyDto.class); given(grandParentKeyDto.getKind()).willReturn("grandparent_kind"); given(grandParentKeyDto.getName()).willReturn("some_name"); given(childKeyDto.getParentKey()).willReturn(parentKeyDto); given(parentKeyDto.getParentKey()).willReturn(grandParentKeyDto); String prettifiedKey = keyPrettifier.prettifyKey(childKeyDto); assertEquals("grandparent_kind (some_name) > parent_kind (1) > child_kind (3)", prettifiedKey); }
public String prettifyKey(KeyDto key) { if (key == null) { return ""; } String parentValue = writeParentKeys(key); String kind = key.getKind(); long id = key.getId(); String name = key.getName(); String idName = getIdName(id, name); return parentValue + appMessages.keyPrettifyTemplate(kind, idName); }
KeyPrettifier { public String prettifyKey(KeyDto key) { if (key == null) { return ""; } String parentValue = writeParentKeys(key); String kind = key.getKind(); long id = key.getId(); String name = key.getName(); String idName = getIdName(id, name); return parentValue + appMessages.keyPrettifyTemplate(kind, idName); } }
KeyPrettifier { public String prettifyKey(KeyDto key) { if (key == null) { return ""; } String parentValue = writeParentKeys(key); String kind = key.getKind(); long id = key.getId(); String name = key.getName(); String idName = getIdName(id, name); return parentValue + appMessages.keyPrettifyTemplate(kind, idName); } @Inject  KeyPrettifier(
            AppMessages appMessages); }
KeyPrettifier { public String prettifyKey(KeyDto key) { if (key == null) { return ""; } String parentValue = writeParentKeys(key); String kind = key.getKind(); long id = key.getId(); String name = key.getName(); String idName = getIdName(id, name); return parentValue + appMessages.keyPrettifyTemplate(kind, idName); } @Inject  KeyPrettifier(
            AppMessages appMessages); String prettifyKey(KeyDto key); }
KeyPrettifier { public String prettifyKey(KeyDto key) { if (key == null) { return ""; } String parentValue = writeParentKeys(key); String kind = key.getKind(); long id = key.getId(); String name = key.getName(); String idName = getIdName(id, name); return parentValue + appMessages.keyPrettifyTemplate(kind, idName); } @Inject  KeyPrettifier(
            AppMessages appMessages); String prettifyKey(KeyDto key);  }