@Test public void testFixWeight() { Assert.assertEquals(ServiceGroups.DEFAULT_WEIGHT_VALUE, ServiceGroups.fixWeight(null)); Assert.assertEquals(ServiceGroups.MIN_WEIGHT_VALUE, ServiceGroups.fixWeight(ServiceGroups.MIN_WEIGHT_VALUE)); Assert.assertEquals(ServiceGroups.MAX_WEIGHT_VALUE, ServiceGroups.fixWeight(ServiceGroups.MAX_WEIGHT_VALUE)); Assert.assertEquals(ServiceGroups.MIN_WEIGHT_VALUE + 1, ServiceGroups.fixWeight(ServiceGroups.MIN_WEIGHT_VALUE + 1)); Assert.assertEquals(ServiceGroups.MAX_WEIGHT_VALUE - 1, ServiceGroups.fixWeight(ServiceGroups.MAX_WEIGHT_VALUE - 1)); Assert.assertEquals(ServiceGroups.DEFAULT_WEIGHT_VALUE, ServiceGroups.fixWeight(ServiceGroups.MIN_WEIGHT_VALUE - 1)); Assert.assertEquals(ServiceGroups.MAX_WEIGHT_VALUE, ServiceGroups.fixWeight(ServiceGroups.MAX_WEIGHT_VALUE + 1)); }
public static int fixWeight(Integer weight) { if (weight == null || weight < MIN_WEIGHT_VALUE) { return DEFAULT_WEIGHT_VALUE; } if (weight > MAX_WEIGHT_VALUE) { return MAX_WEIGHT_VALUE; } return weight; }
ServiceGroups { public static int fixWeight(Integer weight) { if (weight == null || weight < MIN_WEIGHT_VALUE) { return DEFAULT_WEIGHT_VALUE; } if (weight > MAX_WEIGHT_VALUE) { return MAX_WEIGHT_VALUE; } return weight; } }
ServiceGroups { public static int fixWeight(Integer weight) { if (weight == null || weight < MIN_WEIGHT_VALUE) { return DEFAULT_WEIGHT_VALUE; } if (weight > MAX_WEIGHT_VALUE) { return MAX_WEIGHT_VALUE; } return weight; } private  ServiceGroups(); }
ServiceGroups { public static int fixWeight(Integer weight) { if (weight == null || weight < MIN_WEIGHT_VALUE) { return DEFAULT_WEIGHT_VALUE; } if (weight > MAX_WEIGHT_VALUE) { return MAX_WEIGHT_VALUE; } return weight; } private  ServiceGroups(); static int fixWeight(Integer weight); static boolean isDefaultGroupId(String groupId); static boolean isGroupCanaryInstance(String groupKey, Instance instance); static boolean isLocalZone(ServiceGroup serviceGroup); }
ServiceGroups { public static int fixWeight(Integer weight) { if (weight == null || weight < MIN_WEIGHT_VALUE) { return DEFAULT_WEIGHT_VALUE; } if (weight > MAX_WEIGHT_VALUE) { return MAX_WEIGHT_VALUE; } return weight; } private  ServiceGroups(); static int fixWeight(Integer weight); static boolean isDefaultGroupId(String groupId); static boolean isGroupCanaryInstance(String groupKey, Instance instance); static boolean isLocalZone(ServiceGroup serviceGroup); static final String DEFAULT_GROUP_ID; static final int MAX_WEIGHT_VALUE; static final int MIN_WEIGHT_VALUE; static final int DEFAULT_WEIGHT_VALUE; }