@Test
public void testToExperimentWithSegmentsExperimentWithNondefaultExperience()
	throws PortalException {

	Locale locale = LocaleUtil.ENGLISH;
	Layout layout = _createLayout(locale);
	SegmentsEntry segmentsEntry = _createSegmentsEntry(locale);
	long segmentsEntryId = RandomTestUtil.randomLong();
	Mockito.when(
		_segmentsEntryLocalService.getSegmentsEntry(segmentsEntryId)
	).thenReturn(
		segmentsEntry
	);
	SegmentsExperience segmentsExperience = _createSegmentsExperience(
		locale, segmentsEntryId);
	long segmentsExperienceId = RandomTestUtil.randomLong();
	Mockito.when(
		_segmentsExperienceLocalService.getSegmentsExperience(
			segmentsExperienceId)
	).thenReturn(
		segmentsExperience
	);
	SegmentsExperiment segmentsExperiment = _createSegmentsExperiment(
		segmentsExperienceId,
		SegmentsExperimentConstants.Goal.BOUNCE_RATE.getLabel(),
		SegmentsExperimentConstants.STATUS_DRAFT);
	String channelId = RandomTestUtil.randomString();
	String dataSourceId = RandomTestUtil.randomString();
	String pageURL = RandomTestUtil.randomString();
	Experiment experiment = ExperimentUtil.toExperiment(
		channelId, dataSourceId, RandomTestUtil.randomString(),
		RandomTestUtil.randomString(), layout, LocaleUtil.ENGLISH, pageURL,
		_segmentsEntryLocalService, _segmentsExperienceLocalService,
		segmentsExperiment);
	Assert.assertEquals(channelId, experiment.getChannelId());
	Assert.assertEquals(
		segmentsExperiment.getCreateDate(), experiment.getCreateDate());
	Assert.assertEquals(dataSourceId, experiment.getDataSourceId());
	Assert.assertEquals(
		segmentsExperiment.getDescription(), experiment.getDescription());
	Assert.assertEquals(
		segmentsExperience.getSegmentsExperienceKey(),
		experiment.getDXPExperienceId());
	Assert.assertEquals(
		segmentsExperience.getName(locale),
		experiment.getDXPExperienceName());
	Assert.assertEquals(
		(Long)layout.getGroupId(), experiment.getDXPGroupId());
	Assert.assertEquals(layout.getUuid(), experiment.getDXPLayoutId());
	Assert.assertEquals(
		segmentsEntry.getSegmentsEntryKey(), experiment.getDXPSegmentId());
	Assert.assertEquals(
		segmentsEntry.getName(locale), experiment.getDXPSegmentName());
	Assert.assertEquals(
		ExperimentStatus.DRAFT, experiment.getExperimentStatus());
	Assert.assertEquals(ExperimentType.AB, experiment.getExperimentType());
	Goal goal = experiment.getGoal();
	GoalMetric goalMetric = goal.getGoalMetric();
	Assert.assertEquals(
		SegmentsExperimentConstants.Goal.BOUNCE_RATE.name(),
		goalMetric.name());
	Assert.assertEquals(
		segmentsExperiment.getSegmentsExperimentKey(), experiment.getId());
	Assert.assertEquals(
		segmentsExperiment.getModifiedDate(), experiment.getModifiedDate());
	Assert.assertEquals(segmentsExperiment.getName(), experiment.getName());
	Assert.assertEquals(
		layout.getFriendlyURL(), experiment.getPageRelativePath());
	Assert.assertEquals(layout.getTitle(locale), experiment.getPageTitle());
	Assert.assertEquals(pageURL, experiment.getPageURL());
	Assert.assertNull(experiment.getPublishedDXPVariantId());
}