@Override
    public Meter submit(MeterRequest request) {
        checkNotNull(request, "request cannot be null.");
        MeterCellId cellId;
        if (request.index().isPresent()) {
            checkArgument(userDefinedIndex, "Index cannot be provided when userDefinedIndex mode is disabled");
            // User provides index
            if (request.scope().isGlobal()) {
                cellId = MeterId.meterId(request.index().get());
            } else {
                cellId = PiMeterCellId.ofIndirect(
                    PiMeterId.of(request.scope().id()), request.index().get());
            }
        } else {
            checkArgument(!userDefinedIndex, "Index cannot be allocated when userDefinedIndex mode is enabled");
            // Allocate an id
            cellId = allocateMeterId(request.deviceId(), request.scope());
        }
        Meter.Builder mBuilder = DefaultMeter.builder()
                .forDevice(request.deviceId())
                .fromApp(request.appId())
                .withBands(request.bands())
                .withCellId(cellId)
                .withUnit(request.unit());
        if (request.isBurst()) {
            mBuilder.burst();
        }
        if (request.annotations() != null && !request.annotations().keys().isEmpty()) {
            mBuilder.withAnnotations(request.annotations());
        }
        DefaultMeter m = (DefaultMeter) mBuilder.build();
        // Meter installation logic (happy ending case)
        // PENDING -> stats -> ADDED -> future completes
        m.setState(MeterState.PENDING_ADD);
        store.addOrUpdateMeter(m).whenComplete((result, error) ->
                                                 onComplete.accept(request, result, error));
        return m;
    }
@Test(expected = IllegalArgumentException.class)
    public void testWrongAdd() {
        initMeterStore();

        manager.submit(userDefinedRequest.add());
    }