This method has been migrated, make sure we use its new place.
Change-Id: Ib17471706233150f26a452b8bca36914a95fc8db
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
package org.opendaylight.controller.cluster.access.client;
import static org.hamcrest.CoreMatchers.hasItems;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.mock;
package org.opendaylight.controller.cluster.access.client;
import static org.hamcrest.CoreMatchers.everyItem;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.opendaylight.controller.cluster.access.client.ConnectionEntryMatcher.entryWithRequest;
package org.opendaylight.controller.cluster.access.client;
import static org.hamcrest.CoreMatchers.everyItem;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doAnswer;
import static java.lang.Boolean.TRUE;
import static org.hamcrest.CoreMatchers.anyOf;
import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.opendaylight.controller.cluster.datastore.MemberNode.verifyNoShardPresent;
*/
package org.opendaylight.controller.cluster.schema.provider.impl;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.instanceOf;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.doReturn;
import static org.hamcrest.CoreMatchers.allOf;
import static org.hamcrest.CoreMatchers.hasItem;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.isA;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import org.hamcrest.BaseMatcher;
import org.hamcrest.Description;
import org.junit.After;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
transaction.replayMessages(mockSuccessor, entries);
final ModifyTransactionRequest transformed = successor.expectTransactionRequest(ModifyTransactionRequest.class);
- Assert.assertNotNull(transformed);
- Assert.assertEquals(successful1.getSequence(), transformed.getSequence());
- Assert.assertTrue(transformed.getPersistenceProtocol().isPresent());
- Assert.assertEquals(PersistenceProtocol.ABORT, transformed.getPersistenceProtocol().get());
+ assertNotNull(transformed);
+ assertEquals(successful1.getSequence(), transformed.getSequence());
+ assertTrue(transformed.getPersistenceProtocol().isPresent());
+ assertEquals(PersistenceProtocol.ABORT, transformed.getPersistenceProtocol().get());
ReadTransactionRequest tmpRead = successor.expectTransactionRequest(ReadTransactionRequest.class);
- Assert.assertNotNull(tmpRead);
- Assert.assertEquals(successful2.getTarget(), tmpRead.getTarget());
- Assert.assertEquals(successful2.getSequence(), tmpRead.getSequence());
- Assert.assertEquals(successful2.getPath(), tmpRead.getPath());
- Assert.assertEquals(successor.localActor(), tmpRead.getReplyTo());
+ assertNotNull(tmpRead);
+ assertEquals(successful2.getTarget(), tmpRead.getTarget());
+ assertEquals(successful2.getSequence(), tmpRead.getSequence());
+ assertEquals(successful2.getPath(), tmpRead.getPath());
+ assertEquals(successor.localActor(), tmpRead.getReplyTo());
tmpRead = successor.expectTransactionRequest(ReadTransactionRequest.class);
- Assert.assertNotNull(tmpRead);
- Assert.assertEquals(request1.getTarget(), tmpRead.getTarget());
- Assert.assertEquals(request1.getSequence(), tmpRead.getSequence());
- Assert.assertEquals(request1.getPath(), tmpRead.getPath());
- Assert.assertEquals(successor.localActor(), tmpRead.getReplyTo());
+ assertNotNull(tmpRead);
+ assertEquals(request1.getTarget(), tmpRead.getTarget());
+ assertEquals(request1.getSequence(), tmpRead.getSequence());
+ assertEquals(request1.getPath(), tmpRead.getPath());
+ assertEquals(successor.localActor(), tmpRead.getReplyTo());
final ExistsTransactionRequest tmpExist = successor.expectTransactionRequest(ExistsTransactionRequest.class);
- Assert.assertNotNull(tmpExist);
- Assert.assertEquals(request2.getTarget(), tmpExist.getTarget());
- Assert.assertEquals(request2.getSequence(), tmpExist.getSequence());
- Assert.assertEquals(request2.getPath(), tmpExist.getPath());
- Assert.assertEquals(successor.localActor(), tmpExist.getReplyTo());
+ assertNotNull(tmpExist);
+ assertEquals(request2.getTarget(), tmpExist.getTarget());
+ assertEquals(request2.getSequence(), tmpExist.getSequence());
+ assertEquals(request2.getPath(), tmpExist.getPath());
+ assertEquals(successor.localActor(), tmpExist.getReplyTo());
}
protected void checkModifications(final ModifyTransactionRequest modifyRequest) {
final List<TransactionModification> modifications = modifyRequest.getModifications();
- Assert.assertEquals(3, modifications.size());
- Assert.assertThat(modifications, hasItem(allOf(isA(TransactionWrite.class), hasPath(PATH_1))));
- Assert.assertThat(modifications, hasItem(allOf(isA(TransactionMerge.class), hasPath(PATH_2))));
- Assert.assertThat(modifications, hasItem(allOf(isA(TransactionDelete.class), hasPath(PATH_3))));
+ assertEquals(3, modifications.size());
+ assertThat(modifications, hasItem(allOf(isA(TransactionWrite.class), hasPath(PATH_1))));
+ assertThat(modifications, hasItem(allOf(isA(TransactionMerge.class), hasPath(PATH_2))));
+ assertThat(modifications, hasItem(allOf(isA(TransactionDelete.class), hasPath(PATH_3))));
}
@SuppressWarnings("checkstyle:hiddenField")
transaction.handleReplayedRemoteRequest(request, createCallbackMock(), Ticker.systemTicker().read());
final RequestEnvelope envelope = backendProbe.expectMsgClass(RequestEnvelope.class);
final R received = (R) envelope.getMessage();
- Assert.assertTrue(received.getClass().equals(request.getClass()));
- Assert.assertEquals(TRANSACTION_ID, received.getTarget());
- Assert.assertEquals(clientContextProbe.ref(), received.getReplyTo());
+ assertTrue(received.getClass().equals(request.getClass()));
+ assertEquals(TRANSACTION_ID, received.getTarget());
+ assertEquals(clientContextProbe.ref(), received.getReplyTo());
return received;
}
}
protected static BaseMatcher<TransactionModification> hasPath(final YangInstanceIdentifier path) {
- return new BaseMatcher<TransactionModification>() {
+ return new BaseMatcher<>() {
@Override
public boolean matches(final Object item) {
import static org.hamcrest.CoreMatchers.both;
import static org.hamcrest.CoreMatchers.hasItem;
import static org.hamcrest.CoreMatchers.isA;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
import static org.opendaylight.controller.cluster.databroker.actors.dds.TestUtils.assertFutureEquals;
import akka.testkit.TestProbe;
import com.google.common.util.concurrent.ListenableFuture;
import java.util.List;
import java.util.Optional;
-import org.junit.Assert;
import org.junit.Test;
import org.opendaylight.controller.cluster.access.commands.ExistsTransactionRequest;
import org.opendaylight.controller.cluster.access.commands.ExistsTransactionSuccess;
final ListenableFuture<Boolean> result = transaction.directCommit();
final TransactionTester<RemoteProxyTransaction> tester = getTester();
final ModifyTransactionRequest req = tester.expectTransactionRequest(ModifyTransactionRequest.class);
- Assert.assertTrue(req.getPersistenceProtocol().isPresent());
- Assert.assertEquals(PersistenceProtocol.SIMPLE, req.getPersistenceProtocol().get());
+ assertTrue(req.getPersistenceProtocol().isPresent());
+ assertEquals(PersistenceProtocol.SIMPLE, req.getPersistenceProtocol().get());
tester.replySuccess(new TransactionCommitSuccess(TRANSACTION_ID, req.getSequence()));
assertFutureEquals(true, result);
}
builder.setCommit(false);
final ModifyTransactionRequest request = builder.build();
final ModifyTransactionRequest received = testForwardToRemote(request, ModifyTransactionRequest.class);
- Assert.assertEquals(request.getPersistenceProtocol(), received.getPersistenceProtocol());
- Assert.assertEquals(request.getModifications(), received.getModifications());
- Assert.assertEquals(request.getTarget(), received.getTarget());
+ assertEquals(request.getPersistenceProtocol(), received.getPersistenceProtocol());
+ assertEquals(request.getModifications(), received.getModifications());
+ assertEquals(request.getTarget(), received.getTarget());
}
@Test
builder.setCommit(true);
final ModifyTransactionRequest request = builder.build();
final ModifyTransactionRequest received = testForwardToRemote(request, ModifyTransactionRequest.class);
- Assert.assertEquals(request.getPersistenceProtocol(), received.getPersistenceProtocol());
- Assert.assertEquals(request.getModifications(), received.getModifications());
- Assert.assertEquals(request.getTarget(), received.getTarget());
+ assertEquals(request.getPersistenceProtocol(), received.getPersistenceProtocol());
+ assertEquals(request.getModifications(), received.getModifications());
+ assertEquals(request.getTarget(), received.getTarget());
}
@Test
builder.setAbort();
final ModifyTransactionRequest request = builder.build();
final ModifyTransactionRequest received = testForwardToRemote(request, ModifyTransactionRequest.class);
- Assert.assertEquals(request.getTarget(), received.getTarget());
- Assert.assertTrue(received.getPersistenceProtocol().isPresent());
- Assert.assertEquals(PersistenceProtocol.ABORT, received.getPersistenceProtocol().get());
+ assertEquals(request.getTarget(), received.getTarget());
+ assertTrue(received.getPersistenceProtocol().isPresent());
+ assertEquals(PersistenceProtocol.ABORT, received.getPersistenceProtocol().get());
}
@Test
final ReadTransactionRequest request =
new ReadTransactionRequest(TRANSACTION_ID, 0L, probe.ref(), PATH_1, false);
final ReadTransactionRequest received = testForwardToRemote(request, ReadTransactionRequest.class);
- Assert.assertEquals(request.getTarget(), received.getTarget());
- Assert.assertEquals(request.getPath(), received.getPath());
+ assertEquals(request.getTarget(), received.getTarget());
+ assertEquals(request.getPath(), received.getPath());
}
@Test
final ExistsTransactionRequest request =
new ExistsTransactionRequest(TRANSACTION_ID, 0L, probe.ref(), PATH_1, false);
final ExistsTransactionRequest received = testForwardToRemote(request, ExistsTransactionRequest.class);
- Assert.assertEquals(request.getTarget(), received.getTarget());
- Assert.assertEquals(request.getPath(), received.getPath());
+ assertEquals(request.getTarget(), received.getTarget());
+ assertEquals(request.getPath(), received.getPath());
}
@Test
final TransactionPreCommitRequest request =
new TransactionPreCommitRequest(TRANSACTION_ID, 0L, probe.ref());
final TransactionPreCommitRequest received = testForwardToRemote(request, TransactionPreCommitRequest.class);
- Assert.assertEquals(request.getTarget(), received.getTarget());
+ assertEquals(request.getTarget(), received.getTarget());
}
@Test
final TransactionDoCommitRequest request =
new TransactionDoCommitRequest(TRANSACTION_ID, 0L, probe.ref());
final TransactionDoCommitRequest received = testForwardToRemote(request, TransactionDoCommitRequest.class);
- Assert.assertEquals(request.getTarget(), received.getTarget());
+ assertEquals(request.getTarget(), received.getTarget());
}
- private <T extends TransactionModification> void testModification(final Runnable modification,
- final Class<T> cls,
- final YangInstanceIdentifier expectedPath) {
+ private <T extends TransactionModification> void testModification(final Runnable modification, final Class<T> cls,
+ final YangInstanceIdentifier expectedPath) {
modification.run();
final ModifyTransactionRequest request = transaction.commitRequest(false);
final List<TransactionModification> modifications = request.getModifications();
- Assert.assertEquals(1, modifications.size());
- Assert.assertThat(modifications, hasItem(both(isA(cls)).and(hasPath(expectedPath))));
+ assertEquals(1, modifications.size());
+ assertThat(modifications, hasItem(both(isA(cls)).and(hasPath(expectedPath))));
}
-
}
* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
package org.opendaylight.controller.cluster.datastore.utils;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
}
public Matcher<Double> approximately(final double val) {
- return new BaseMatcher<Double>() {
+ return new BaseMatcher<>() {
@Override
- public boolean matches(Object obj) {
+ public boolean matches(final Object obj) {
Double value = (Double) obj;
return value >= val && value <= val + 1;
}
@Override
- public void describeTo(Description description) {
+ public void describeTo(final Description description) {
description.appendText("> " + val + " < " + (val + 1));
}
};
*/
package org.opendaylight.controller.cluster.entityownership;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.mockito.AdditionalMatchers.or;
import static org.mockito.Mockito.doNothing;