- if (delayMs > 0) {
- logger.debug("a1ControllerPutHandler sleeping {}", delayMs);
- Thread.sleep(delayMs);
- }
- String appName = inv.<String>getArgument(0);
- String policy = inv.<String>getArgument(1);
- appPolicyMap.put(appName, policy);
+ 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));
+ 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);
+ String policy = inv.<String>getArgument(2);
+ appPolicyMap.put(policyInstId, policy);