SfcServicePathId { public static long check_and_allocate_symmetric_pathid(long pathid) { if (SfcConcurrencyAPI.getPathIdLock()) { try { long symmetric_id = -1; GenerationAlgorithmEnum genAlg = getGenerationAlgorithm(); if(genAlg == GenerationAlgorithmEnum.Random) { symmetric_id = pathid ^ (1 << 23); if(!check_suitable_pathid(symmetric_id)) { symmetric_id = -1; } } else if(genAlg == GenerationAlgorithmEnum.Sequential) { symmetric_id = generatePathIdSequentialIncrements(); } if ((symmetric_id >= MIN_PATH_ID) && allocate_pathid(symmetric_id)) { return symmetric_id; } else { return -1; } } finally { SfcConcurrencyAPI.releasePathIdLock(); } } else { return -1; } }  static int generatePathIdRandomIncrements(); static int generatePathIdSequentialIncrements(); static long check_and_allocate_pathid(long pathid); static long check_and_allocate_symmetric_pathid(long pathid); static long check_and_allocate_pathid(); static boolean check_suitable_pathid(long pathid); static boolean allocate_pathid(long pathid); static boolean free_pathid(long pathid); static GenerationAlgorithmEnum getGenerationAlgorithm(); static boolean setGenerationAlgorithm(int genAlgorithm); static boolean setGenerationAlgorithm(GenerationAlgorithmEnum genAlgorithm);  }
@Test public void testCheck_and_allocate_symmetric_pathId() throws Exception { for (Integer pathId : pathIdList) { assertNotEquals(-1, SfcServicePathId.check_and_allocate_symmetric_pathid(pathId)); } for (Integer pathId : FlippedPathIdList) { assertFalse(SfcServicePathId.check_suitable_pathid(pathId)); } for (Integer pathId : FlippedPathIdList) { assertTrue(SfcServicePathId.free_pathid(pathId)); } }