@@ -0,0 +1,3513 @@
+/*%0A * Copyright 1&1 Internet AG, https://github.com/1and1/%0A * %0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *   http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage net.oneandone.troilus.api;%0A%0A%0A%0A%0Aimport java.nio.ByteBuffer;%0A%0Aimport java.util.concurrent.CompletableFuture;%0Aimport java.util.concurrent.atomic.AtomicReference;%0A%0Aimport net.oneandone.troilus.AbstractCassandraBasedTest;%0Aimport net.oneandone.troilus.Dao;%0Aimport net.oneandone.troilus.DaoImpl;%0Aimport net.oneandone.troilus.interceptor.DeleteQueryData;%0Aimport net.oneandone.troilus.interceptor.DeleteQueryRequestInterceptor;%0Aimport net.oneandone.troilus.interceptor.WriteQueryData;%0Aimport net.oneandone.troilus.interceptor.WriteQueryRequestInterceptor;%0Aimport net.oneandone.troilus.persistence.User;%0A%0Aimport org.junit.Assert;%0Aimport org.junit.Test;%0A%0A%0Apublic class InterceptorTest extends AbstractCassandraBasedTest %7B%0A    %0A%0A        %0A    %0A    @Test%0A    public void testInterceptor() throws Exception %7B%0A        MyWriteQueryRequestInterceptor writeRequestInterceptor = new MyWriteQueryRequestInterceptor(); %0A        MyDeleteQueryRequestInterceptor deleteRequestInterceptor = new MyDeleteQueryRequestInterceptor(); %0A        %0A        Dao usersDao = new DaoImpl(getSession(), UsersTable.TABLE)%0A                                 .withInterceptor(writeRequestInterceptor)%0A                                 .withInterceptor(deleteRequestInterceptor);%0A        %0A        usersDao.writeEntity(new User(%2234334234234%22, %22tom%22, false, ByteBuffer.allocate(0), new byte%5B0%5D, System.currentTimeMillis(), null, null))%0A                .execute();%0A        Assert.assertEquals(%22tom%22, writeRequestInterceptor.getQueryData().getValuesToMutate().get(%22name%22).get());%0A%0A        %0A        %0A        usersDao.deleteWithKey(%22user_id%22, %2234334234234%22)%0A                .execute();%0A        Assert.assertEquals(%2234334234234%22, deleteRequestInterceptor.getQueryData().getKeys().get(%22user_id%22));%0A    %7D%0A    %0A    %0A    %0A    private static final class MyWriteQueryRequestInterceptor implements WriteQueryRequestInterceptor %7B%0A        %0A        private AtomicReference%3CWriteQueryData%3E queryDataRef = new AtomicReference%3C%3E();%0A%0A        @Override%0A        public CompletableFuture%3CWriteQueryData%3E onWriteRequestAsync(WriteQueryData queryData) %7B%0A            this.queryDataRef.set(queryData);%0A            return CompletableFuture.completedFuture(queryData);%0A        %7D%0A        %0A        public WriteQueryData getQueryData() %7B%0A            return queryDataRef.get();%0A        %7D%0A    %7D%0A    %0A    %0A    private static final class MyDeleteQueryRequestInterceptor implements DeleteQueryRequestInterceptor %7B%0A        %0A        private AtomicReference%3CDeleteQueryData%3E queryDataRef = new AtomicReference%3C%3E();%0A%0A%0A        @Override%0A        public CompletableFuture%3CDeleteQueryData%3E onDeleteRequestAsync( DeleteQueryData queryData) %7B%0A            this.queryDataRef.set(queryData);%0A            return CompletableFuture.completedFuture(queryData);%0A        %7D%0A        %0A        public DeleteQueryData getQueryData() %7B%0A            return queryDataRef.get();%0A        %7D%0A    %7D%0A%7D%0A%0A%0A

test added to improve test coverage