DXPVariantSettingsUtil { public static DXPVariantSettings toDXPVariantSettings( String controlSegmentsExperienceKey, String segmentsExperienceKey, Double split) { DXPVariantSettings dxpVariantSettings = new DXPVariantSettings(); dxpVariantSettings.setControl( Objects.equals( controlSegmentsExperienceKey, segmentsExperienceKey)); dxpVariantSettings.setDXPVariantId(segmentsExperienceKey); dxpVariantSettings.setTrafficSplit(split * 100); return dxpVariantSettings; }  static DXPVariantSettings toDXPVariantSettings(
		String controlSegmentsExperienceKey, String segmentsExperienceKey,
		Double split);  }
@Test public void testToDXPVariantSettingsWithControlVariant() { String controlSegmentsExperienceKey = RandomTestUtil.randomString(); double split = RandomTestUtil.randomDouble(); DXPVariantSettings dxpVariantSettings = DXPVariantSettingsUtil.toDXPVariantSettings( controlSegmentsExperienceKey, controlSegmentsExperienceKey, split); Assert.assertEquals( controlSegmentsExperienceKey, dxpVariantSettings.getDXPVariantId()); Assert.assertEquals( split, dxpVariantSettings.getTrafficSplit() / 100, 0.001); Assert.assertTrue(dxpVariantSettings.isControl()); }
@Test public void testToDXPVariantSettingsWithNoncontrolVariant() { String controlSegmentsExperienceKey = RandomTestUtil.randomString(); String segmentsExperienceKey = RandomTestUtil.randomString(); double split = RandomTestUtil.randomDouble(); DXPVariantSettings dxpVariantSettings = DXPVariantSettingsUtil.toDXPVariantSettings( controlSegmentsExperienceKey, segmentsExperienceKey, split); Assert.assertEquals( segmentsExperienceKey, dxpVariantSettings.getDXPVariantId()); Assert.assertEquals( split, dxpVariantSettings.getTrafficSplit() / 100, 0.001); Assert.assertFalse(dxpVariantSettings.isControl()); }