ContentDashboardItemTypeUtil { public static Optional<ContentDashboardItemType> toContentDashboardItemTypeOptional( ContentDashboardItemTypeFactoryTracker contentDashboardItemTypeFactoryTracker, Document document) { return toContentDashboardItemTypeOptional( contentDashboardItemTypeFactoryTracker, new InfoItemReference( GetterUtil.getString(document.get(Field.ENTRY_CLASS_NAME)), GetterUtil.getLong(document.get(Field.ENTRY_CLASS_PK)))); }  static Optional<ContentDashboardItemType> toContentDashboardItemTypeOptional(
			ContentDashboardItemTypeFactoryTracker
				contentDashboardItemTypeFactoryTracker,
			Document document); static Optional<ContentDashboardItemType> toContentDashboardItemTypeOptional(
			ContentDashboardItemTypeFactoryTracker
				contentDashboardItemTypeFactoryTracker,
			InfoItemReference infoItemReference); static Optional<ContentDashboardItemType> toContentDashboardItemTypeOptional(
			ContentDashboardItemTypeFactoryTracker
				contentDashboardItemTypeFactoryTracker,
			JSONObject contentDashboardItemTypePayloadJSONObject); static Optional<ContentDashboardItemType> toContentDashboardItemTypeOptional(
			ContentDashboardItemTypeFactoryTracker
				contentDashboardItemTypeFactoryTracker,
			String contentDashboardItemTypePayload);  }
@Test public void testToContentDashboardItemTypeOptionalByClassNameAndClassPK() throws PortalException { ContentDashboardItemType contentDashboardItemType = _getContentDashboardItemType(); ContentDashboardItemTypeFactory contentDashboardItemTypeFactory = _getContentDashboardItemTypeFactory(contentDashboardItemType); ContentDashboardItemTypeFactoryTracker contentDashboardItemTypeFactoryTracker = _getContentDashboardItemTypeFactoryTracker( contentDashboardItemType, contentDashboardItemTypeFactory); Optional<ContentDashboardItemType> contentDashboardItemTypeOptional = ContentDashboardItemTypeUtil.toContentDashboardItemTypeOptional( contentDashboardItemTypeFactoryTracker, contentDashboardItemType.getInfoItemReference()); Assert.assertEquals( contentDashboardItemType, contentDashboardItemTypeOptional.get()); }
@Test public void testToContentDashboardItemTypeOptionalByClassNameAndClassPKWithoutContentDashboardItemTypeFactory() { ContentDashboardItemType contentDashboardItemType = _getContentDashboardItemType(); ContentDashboardItemTypeFactoryTracker contentDashboardItemTypeFactoryTracker = _getContentDashboardItemTypeFactoryTracker( contentDashboardItemType, null); Optional<ContentDashboardItemType> contentDashboardItemTypeOptional = ContentDashboardItemTypeUtil.toContentDashboardItemTypeOptional( contentDashboardItemTypeFactoryTracker, contentDashboardItemType.getInfoItemReference()); Assert.assertFalse(contentDashboardItemTypeOptional.isPresent()); }
@Test public void testToContentDashboardItemTypeOptionalByDocument() throws PortalException { ContentDashboardItemType contentDashboardItemType = _getContentDashboardItemType(); InfoItemReference infoItemReference = contentDashboardItemType.getInfoItemReference(); Document document = Mockito.mock(Document.class); Mockito.when( document.get(Field.ENTRY_CLASS_NAME) ).thenReturn( infoItemReference.getClassName() ); Mockito.when( document.get(Field.ENTRY_CLASS_PK) ).thenReturn( String.valueOf(infoItemReference.getClassPK()) ); ContentDashboardItemTypeFactory contentDashboardItemTypeFactory = _getContentDashboardItemTypeFactory(contentDashboardItemType); ContentDashboardItemTypeFactoryTracker contentDashboardItemTypeFactoryTracker = _getContentDashboardItemTypeFactoryTracker( contentDashboardItemType, contentDashboardItemTypeFactory); Optional<ContentDashboardItemType> contentDashboardItemTypeOptional = ContentDashboardItemTypeUtil.toContentDashboardItemTypeOptional( contentDashboardItemTypeFactoryTracker, document); Assert.assertEquals( contentDashboardItemType, contentDashboardItemTypeOptional.get()); }
@Test public void testToContentDashboardItemTypeOptionalByJSONObject() throws PortalException { ContentDashboardItemType contentDashboardItemType = _getContentDashboardItemType(); ContentDashboardItemTypeFactory contentDashboardItemTypeFactory = _getContentDashboardItemTypeFactory(contentDashboardItemType); ContentDashboardItemTypeFactoryTracker contentDashboardItemTypeFactoryTracker = _getContentDashboardItemTypeFactoryTracker( contentDashboardItemType, contentDashboardItemTypeFactory); Optional<? extends ContentDashboardItemType> contentDashboardItemTypeOptional = ContentDashboardItemTypeUtil.toContentDashboardItemTypeOptional( contentDashboardItemTypeFactoryTracker, JSONFactoryUtil.createJSONObject( contentDashboardItemType.toJSONString(LocaleUtil.US))); Assert.assertEquals( contentDashboardItemType, contentDashboardItemTypeOptional.get()); }
@Test public void testToContentDashboardItemTypeOptionalByJSONObjectWithoutContentDashboardItemTypeFactory() throws JSONException { ContentDashboardItemType contentDashboardItemType = _getContentDashboardItemType(); ContentDashboardItemTypeFactoryTracker contentDashboardItemTypeFactoryTracker = _getContentDashboardItemTypeFactoryTracker( contentDashboardItemType, null); Optional<ContentDashboardItemType> contentDashboardItemTypeOptional = ContentDashboardItemTypeUtil.toContentDashboardItemTypeOptional( contentDashboardItemTypeFactoryTracker, JSONFactoryUtil.createJSONObject( contentDashboardItemType.toJSONString(LocaleUtil.US))); Assert.assertFalse(contentDashboardItemTypeOptional.isPresent()); }
@Test public void testToContentDashboardItemTypeOptionalByStringWithoutContentDashboardItemTypeFactory() throws JSONException { ContentDashboardItemType contentDashboardItemType = _getContentDashboardItemType(); ContentDashboardItemTypeFactoryTracker contentDashboardItemTypeFactoryTracker = _getContentDashboardItemTypeFactoryTracker( contentDashboardItemType, null); Optional<ContentDashboardItemType> contentDashboardItemTypeOptional = ContentDashboardItemTypeUtil.toContentDashboardItemTypeOptional( contentDashboardItemTypeFactoryTracker, contentDashboardItemType.toJSONString(LocaleUtil.US)); Assert.assertFalse(contentDashboardItemTypeOptional.isPresent()); }