DDMFormDisplayContext { public boolean isFormAvailable() throws PortalException { if (isPreview()) { return true; } DDMFormInstance formInstance = getFormInstance(); if (formInstance != null) { Group group = _groupLocalService.getGroup( formInstance.getGroupId()); Group scopeGroup = _groupLocalService.getGroup( _portal.getScopeGroupId(_renderRequest)); if ((group != null) && (scopeGroup != null) && group.isStagingGroup() && !scopeGroup.isStagingGroup()) { return false; } if ((group != null) && group.isStagedRemotely()) { ThemeDisplay themeDisplay = getThemeDisplay(); if (!DDMFormInstanceStagingUtil. isFormInstancePublishedToRemoteLive( group, themeDisplay.getUser(), formInstance.getUuid())) { return false; } } } if (isSharedURL()) { if (isFormPublished() && isFormShared()) { return true; } return false; } if (formInstance != null) { return true; } return false; } DDMFormDisplayContext(
		RenderRequest renderRequest, RenderResponse renderResponse,
		DDMFormFieldTypeServicesTracker ddmFormFieldTypeServicesTracker,
		DDMFormInstanceLocalService ddmFormInstanceLocalService,
		DDMFormInstanceRecordLocalService ddmFormInstanceRecordLocalService,
		DDMFormInstanceRecordVersionLocalService
			ddmFormInstanceRecordVersionLocalService,
		DDMFormInstanceService ddmFormInstanceService,
		DDMFormInstanceVersionLocalService ddmFormInstanceVersionLocalService,
		DDMFormRenderer ddmFormRenderer,
		DDMFormValuesFactory ddmFormValuesFactory,
		DDMFormValuesMerger ddmFormValuesMerger,
		DDMFormWebConfiguration ddmFormWebConfiguration,
		DDMStorageAdapterTracker ddmStorageAdapterTracker,
		GroupLocalService groupLocalService, JSONFactory jsonFactory,
		WorkflowDefinitionLinkLocalService workflowDefinitionLinkLocalService,
		Portal portal); int getAutosaveInterval(); String[] getAvailableLanguageIds(); String getContainerId(); String getDDMFormHTML(); DDMFormSuccessPageSettings getDDMFormSuccessPageSettings(); String getDefaultLanguageId(); DDMFormInstance getFormInstance(); long getFormInstanceId(); DDMFormInstanceRecord getFormInstanceRecord(); long getFormInstanceRecordId(); String getRedirectURL(); String getSubmitLabel(); boolean hasAddFormInstanceRecordPermission(); boolean hasValidStorageType(DDMFormInstance ddmFormInstance); boolean hasViewPermission(); boolean isAutosaveEnabled(); boolean isFormAvailable(); boolean isFormShared(); boolean isPreview(); Boolean isRequireAuthentication(); boolean isShowConfigurationIcon(); boolean isShowSubmitButton(); boolean isShowSuccessPage();  }
@Test public void testIsFormAvailableForGuest() throws Exception { DDMFormInstance ddmFormInstance = mockDDMFormInstance(); when( _ddmFormInstanceLocalService.fetchFormInstance(Matchers.anyLong()) ).thenReturn( ddmFormInstance ); when( _ddmFormInstanceService.fetchFormInstance(Matchers.anyLong()) ).thenReturn( null ); DDMFormDisplayContext ddmFormDisplayContext = createDDMFormDisplayContext(); Assert.assertFalse(ddmFormDisplayContext.isFormAvailable()); }
@Test public void testIsFormAvailableForLoggedUser() throws Exception { DDMFormInstance ddmFormInstance = mockDDMFormInstance(); when( _ddmFormInstanceLocalService.fetchFormInstance(Matchers.anyLong()) ).thenReturn( ddmFormInstance ); when( _ddmFormInstanceService.fetchFormInstance(Matchers.anyLong()) ).thenReturn( ddmFormInstance ); DDMFormDisplayContext ddmFormDisplayContext = createDDMFormDisplayContext(); Assert.assertTrue(ddmFormDisplayContext.isFormAvailable()); }