- if (delayMs > 0) {
- logger.debug("a1ControllerGetHandler sleeping {}", delayMs);
- Thread.sleep(delayMs);
- }
- String appName = inv.<String>getArgument(0);
- return appPolicyMap.get(appName);
- }).when(mockApi).a1ControllerGetHandler(any(String.class));
+ delay();
+ return policyTypeIds;
+ }).when(mockApi).a1ControllerGetAllPolicyTypes();
+ doAnswer(inv -> {
+ delay();
+ Integer policyTypeId = inv.<Integer>getArgument(0);
+ if (policyTypeId.compareTo(ADMISSION_CONTROL_POLICY_ID) != 0)
+ throw new IllegalArgumentException("Unexpected policy type: " + policyTypeId);
+ return rateControlPolicyType;
+ }).when(mockApi).a1ControllerGetPolicyType(any(Integer.class));
+ doAnswer(inv -> {
+ delay();
+ Integer policyTypeId = inv.<Integer>getArgument(0);
+ if (policyTypeId.compareTo(ADMISSION_CONTROL_POLICY_ID) != 0)
+ throw new IllegalArgumentException("Unexpected policy type: " + policyTypeId);
+ String policyInstId = inv.<String>getArgument(1);
+ if (!AC_CONTROL_NAME.equals(policyInstId))
+ throw new IllegalArgumentException("Unexpected policy instance: " + policyInstId);
+ return appPolicyMap.get(policyInstId);
+ }).when(mockApi).a1ControllerGetPolicyInstance(any(Integer.class), any(String.class));