@Test(expected = IllegalArgumentException.class) public void mapValueTypeNotString() throws Exception { List<Integer> grants = singletonList(0); Map<String, List<Integer>> value = singletonMap("AUTHORITY", grants); PatchOperation op = PatchOperation.add(PATH, value); underTest.convertOperation(null, op); }
@Override public PatchOperation convertOperation(Road road, PatchOperation modelOperation) { checkArgument(modelOperation.getOperation() != REMOVE, "only add or replace are supported"); checkArgument(modelOperation.getValue() instanceof Map, "value must be a map"); Map<?, ?> map = (Map<?, ?>) modelOperation.getValue(); if (!map.isEmpty()) { Object firstItem = map.values().iterator().next(); checkArgument(firstItem instanceof List, "map value must be an array"); List<?> list = (List<?>) firstItem; checkArgument(!list.isEmpty(), "array type must not be empty"); checkArgument(list.get(0) instanceof String, "array type must be a string"); } return PatchOperation.replace(PATH, modelOperation.getValue()); }
OfframpAuthPatchMapping extends PatchMapping { @Override public PatchOperation convertOperation(Road road, PatchOperation modelOperation) { checkArgument(modelOperation.getOperation() != REMOVE, "only add or replace are supported"); checkArgument(modelOperation.getValue() instanceof Map, "value must be a map"); Map<?, ?> map = (Map<?, ?>) modelOperation.getValue(); if (!map.isEmpty()) { Object firstItem = map.values().iterator().next(); checkArgument(firstItem instanceof List, "map value must be an array"); List<?> list = (List<?>) firstItem; checkArgument(!list.isEmpty(), "array type must not be empty"); checkArgument(list.get(0) instanceof String, "array type must be a string"); } return PatchOperation.replace(PATH, modelOperation.getValue()); } }
OfframpAuthPatchMapping extends PatchMapping { @Override public PatchOperation convertOperation(Road road, PatchOperation modelOperation) { checkArgument(modelOperation.getOperation() != REMOVE, "only add or replace are supported"); checkArgument(modelOperation.getValue() instanceof Map, "value must be a map"); Map<?, ?> map = (Map<?, ?>) modelOperation.getValue(); if (!map.isEmpty()) { Object firstItem = map.values().iterator().next(); checkArgument(firstItem instanceof List, "map value must be an array"); List<?> list = (List<?>) firstItem; checkArgument(!list.isEmpty(), "array type must not be empty"); checkArgument(list.get(0) instanceof String, "array type must be a string"); } return PatchOperation.replace(PATH, modelOperation.getValue()); }  }
OfframpAuthPatchMapping extends PatchMapping { @Override public PatchOperation convertOperation(Road road, PatchOperation modelOperation) { checkArgument(modelOperation.getOperation() != REMOVE, "only add or replace are supported"); checkArgument(modelOperation.getValue() instanceof Map, "value must be a map"); Map<?, ?> map = (Map<?, ?>) modelOperation.getValue(); if (!map.isEmpty()) { Object firstItem = map.values().iterator().next(); checkArgument(firstItem instanceof List, "map value must be an array"); List<?> list = (List<?>) firstItem; checkArgument(!list.isEmpty(), "array type must not be empty"); checkArgument(list.get(0) instanceof String, "array type must be a string"); } return PatchOperation.replace(PATH, modelOperation.getValue()); }  @Override String getPath(); @Override PatchOperation convertOperation(Road road, PatchOperation modelOperation); }
OfframpAuthPatchMapping extends PatchMapping { @Override public PatchOperation convertOperation(Road road, PatchOperation modelOperation) { checkArgument(modelOperation.getOperation() != REMOVE, "only add or replace are supported"); checkArgument(modelOperation.getValue() instanceof Map, "value must be a map"); Map<?, ?> map = (Map<?, ?>) modelOperation.getValue(); if (!map.isEmpty()) { Object firstItem = map.values().iterator().next(); checkArgument(firstItem instanceof List, "map value must be an array"); List<?> list = (List<?>) firstItem; checkArgument(!list.isEmpty(), "array type must not be empty"); checkArgument(list.get(0) instanceof String, "array type must be a string"); } return PatchOperation.replace(PATH, modelOperation.getValue()); }  @Override String getPath(); @Override PatchOperation convertOperation(Road road, PatchOperation modelOperation);  }