*/
package org.opendaylight.yangtools.rfc6643.parser;
+import static org.junit.Assert.assertThrows;
+
import org.junit.Test;
import org.opendaylight.yangtools.rfc6643.model.api.ObjectIdentifier;
public class ObjectIdentifierTest {
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testObjectIdentifierCreationWithBadOID() {
- ObjectIdentifier.forString("bad oid");
+ assertThrows(IllegalArgumentException.class, () -> ObjectIdentifier.forString("bad oid"));
}
}
* 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.yangtools.rfc8040.parser;
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.hamcrest.CoreMatchers.startsWith;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
import com.google.common.collect.ImmutableSet;
import java.io.IOException;
import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
+import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor.BuildAction;
public class YangDataExtensionTest {
@Test
public void testYangDataWithMissingTopLevelContainer() {
- try {
- reactor.newBuild().addSources(FOO_INVALID_1_MODULE, IETF_RESTCONF_MODULE).buildEffective();
- fail("Exception should have been thrown because of missing top-level container in yang-data statement.");
- } catch (final ReactorException ex) {
- final Throwable cause = ex.getCause();
- assertTrue(cause instanceof MissingSubstatementException);
- assertTrue(cause.getMessage().startsWith("YANG_DATA is missing CONTAINER. Minimal count is 1."));
- }
+ final BuildAction build = reactor.newBuild().addSources(FOO_INVALID_1_MODULE, IETF_RESTCONF_MODULE);
+ final ReactorException ex = assertThrows(ReactorException.class, () -> build.buildEffective());
+ final Throwable cause = ex.getCause();
+ assertThat(cause, instanceOf(MissingSubstatementException.class));
+ assertThat(cause.getMessage(), startsWith("YANG_DATA is missing CONTAINER. Minimal count is 1."));
}
@Test
public void testYangDataWithTwoTopLevelContainers() {
- try {
- reactor.newBuild().addSources(FOO_INVALID_2_MODULE, IETF_RESTCONF_MODULE).buildEffective();
- fail("Exception should have been thrown because of two top-level containers in yang-data statement.");
- } catch (final ReactorException ex) {
- final Throwable cause = ex.getCause();
- assertTrue(cause instanceof InvalidSubstatementException);
- assertTrue(cause.getMessage().startsWith("Maximal count of CONTAINER for YANG_DATA is 1, detected 2."));
- }
+ final BuildAction build = reactor.newBuild().addSources(FOO_INVALID_2_MODULE, IETF_RESTCONF_MODULE);
+ final ReactorException ex = assertThrows(ReactorException.class, () -> build.buildEffective());
+ final Throwable cause = ex.getCause();
+ assertThat(cause, instanceOf(InvalidSubstatementException.class));
+ assertTrue(cause.getMessage().startsWith("Maximal count of CONTAINER for YANG_DATA is 1, detected 2."));
}
@Test
public void testYangDataWithInvalidToplevelNode() {
- try {
- reactor.newBuild().addSources(FOO_INVALID_3_MODULE, IETF_RESTCONF_MODULE).buildEffective();
- fail("Exception should have been thrown because of invalid top-level node in yang-data statement.");
- } catch (final ReactorException ex) {
- final Throwable cause = ex.getCause();
- assertTrue(cause instanceof InvalidSubstatementException);
- assertTrue(cause.getMessage().startsWith("LEAF is not valid for YANG_DATA."));
- }
+ final BuildAction build = reactor.newBuild().addSources(FOO_INVALID_3_MODULE, IETF_RESTCONF_MODULE);
+ final ReactorException ex = assertThrows(ReactorException.class, () -> build.buildEffective());
+ final Throwable cause = ex.getCause();
+ assertThat(cause, instanceOf(InvalidSubstatementException.class));
+ assertThat(cause.getMessage(), startsWith("LEAF is not valid for YANG_DATA."));
}
private static StatementStreamSource sourceForResource(final String resourceName) {
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
import com.google.common.collect.UnmodifiableIterator;
import java.net.URI;
private static final class TestClass extends PathArgumentList {
@Override
public UnmodifiableIterator<PathArgument> iterator() {
- return new UnmodifiableIterator<PathArgument>() {
+ return new UnmodifiableIterator<>() {
@Override
public boolean hasNext() {
return false;
public void testProtections() {
final PathArgumentList l = new TestClass();
- try {
- l.remove(null);
- fail();
- } catch (UnsupportedOperationException e) {
- // Expected
- }
-
- try {
- l.addAll(Collections.emptyList());
- fail();
- } catch (UnsupportedOperationException e) {
- // Expected
- }
-
- try {
- l.removeAll(Collections.emptyList());
- fail();
- } catch (UnsupportedOperationException e) {
- // Expected
- }
-
- try {
- l.retainAll(Collections.emptyList());
- fail();
- } catch (UnsupportedOperationException e) {
- // Expected
- }
-
- try {
- l.clear();
- fail();
- } catch (UnsupportedOperationException e) {
- // Expected
- }
-
- try {
- l.addAll(0, null);
- fail();
- } catch (UnsupportedOperationException e) {
- // Expected
- }
+ assertThrows(UnsupportedOperationException.class, () -> l.remove(null));
+ assertThrows(UnsupportedOperationException.class, () -> l.addAll(Collections.emptyList()));
+ assertThrows(UnsupportedOperationException.class, () -> l.removeAll(Collections.emptyList()));
+ assertThrows(UnsupportedOperationException.class, () -> l.retainAll(Collections.emptyList()));
+ assertThrows(UnsupportedOperationException.class, () -> l.clear());
+ assertThrows(UnsupportedOperationException.class, () -> l.addAll(0, null));
}
@Test
assertEquals(stackedYangInstanceIdentifier, stackedYangInstanceIdentifierClone);
assertEquals(stackedReversePathArguments, yangInstanceIdentifier1.getReversePathArguments());
- try {
- stackedYangInstanceIdentifier.getAncestor(12);
- fail();
- } catch (IllegalArgumentException e) {
- // Expected
- }
+ assertThrows(IllegalArgumentException.class, () -> stackedYangInstanceIdentifier.getAncestor(12));
}
}
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import com.google.common.collect.ImmutableMap;
assertFalse("isPresent", relative.isPresent());
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testContainsNull() {
final YangInstanceIdentifier id = YangInstanceIdentifier.create(new NodeIdentifier(NODENAME1));
- id.contains(null);
+ assertThrows(IllegalArgumentException.class, () -> id.contains(null));
}
@Test
assertNotNull(node1.toString());
}
- @Test(expected = UnsupportedOperationException.class)
+ @Test
public void testAugmentationIdentifierNodeType() {
AugmentationIdentifier node1 = new AugmentationIdentifier(ImmutableSet.of(NODENAME1, NODENAME2));
- node1.getNodeType();
+ assertThrows(UnsupportedOperationException.class, () -> node1.getNodeType());
}
@Test
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doCallRealMethod;
import static org.mockito.Mockito.doReturn;
assertEquals(loggingNormalizedNodeStreamWriter, orderedNormalizedNodeWriter.getWriter());
- final NormalizedNode<?, ?> mockedNormalizedNode = mock(NormalizedNode.class);
- try {
- orderedNormalizedNodeWriter.write(mockedNormalizedNode);
- fail("An IllegalStateException should have been thrown!");
- } catch (IllegalStateException ex) {
- assertTrue(ex.getMessage().startsWith("It wasn't possible to serialize node"));
- }
+ final IllegalStateException ex = assertThrows(IllegalStateException.class,
+ () -> orderedNormalizedNodeWriter.write(mock(NormalizedNode.class)));
+ assertTrue(ex.getMessage().startsWith("It wasn't possible to serialize node"));
final NormalizedNode<?, ?> mockedLeafSetEntryNode = mock(LeafSetEntryNode.class);
doReturn(new NodeWithValue<>(myLeafList, "leaflist-value-1")).when(mockedLeafSetEntryNode).getIdentifier();
*/
package org.opendaylight.yangtools.yang.data.api.schema.tree;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.Assert.assertThrows;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.isNull;
import static org.mockito.Mockito.doReturn;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
public class DataTreeCandidateNodesTest {
-
@Test
public void testFromNormalizedNode() {
final NormalizedNode<?, ?> mockedNormalizedNode = mock(NormalizedNode.class);
final DataTreeModificationCursor mockedCursor = mock(DataTreeModificationCursor.class);
doReturn(ModificationType.APPEARED).when(mockedDataTreeCandidateNode).getModificationType();
- try {
- DataTreeCandidateNodes.applyToCursor(mockedCursor, mockedDataTreeCandidateNode);
- fail("An IllegalArgumentException should have been thrown!");
- } catch (IllegalArgumentException ex) {
- assertTrue(ex.getMessage().contains("Unsupported modification"));
- }
+ final IllegalArgumentException ex = assertThrows(IllegalArgumentException.class,
+ () -> DataTreeCandidateNodes.applyToCursor(mockedCursor, mockedDataTreeCandidateNode));
+ assertThat(ex.getMessage(), containsString("Unsupported modification"));
}
@Test
final DataTreeModificationCursor mockedCursor = mock(DataTreeModificationCursor.class);
doReturn(ModificationType.APPEARED).when(mockedDataTreeCandidateNode).getModificationType();
- try {
- DataTreeCandidateNodes.applyRootedNodeToCursor(mockedCursor, mockedRootPath, mockedDataTreeCandidateNode);
- fail("An IllegalArgumentException should have been thrown!");
- } catch (IllegalArgumentException ex) {
- assertTrue(ex.getMessage().contains("Unsupported modification"));
- }
+ final IllegalArgumentException ex = assertThrows(IllegalArgumentException.class,
+ () -> DataTreeCandidateNodes.applyRootedNodeToCursor(mockedCursor, mockedRootPath,
+ mockedDataTreeCandidateNode));
+ assertThat(ex.getMessage(), containsString("Unsupported modification"));
}
@Test
final DataTreeModificationCursor mockedCursor = mock(DataTreeModificationCursor.class);
doReturn(ModificationType.DELETE).when(mockedDataTreeCandidateNode).getModificationType();
- try {
- DataTreeCandidateNodes.applyRootToCursor(mockedCursor, mockedDataTreeCandidateNode);
- fail("An IllegalArgumentException should have been thrown!");
- } catch (IllegalArgumentException ex) {
- assertTrue(ex.getMessage().contains("Can not delete root"));
- }
+ final IllegalArgumentException ex = assertThrows(IllegalArgumentException.class,
+ () -> DataTreeCandidateNodes.applyRootToCursor(mockedCursor, mockedDataTreeCandidateNode));
+ assertThat(ex.getMessage(), containsString("Can not delete root"));
}
@Test
final DataTreeModificationCursor mockedCursor = mock(DataTreeModificationCursor.class);
doReturn(ModificationType.APPEARED).when(mockedDataTreeCandidateNode).getModificationType();
- try {
- DataTreeCandidateNodes.applyRootToCursor(mockedCursor, mockedDataTreeCandidateNode);
- fail("An IllegalArgumentException should have been thrown!");
- } catch (IllegalArgumentException ex) {
- assertTrue(ex.getMessage().contains("Unsupported modification"));
- }
+ final IllegalArgumentException ex = assertThrows(IllegalArgumentException.class,
+ () -> DataTreeCandidateNodes.applyRootToCursor(mockedCursor, mockedDataTreeCandidateNode));
+ assertThat(ex.getMessage(), containsString("Unsupported modification"));
}
}
package org.opendaylight.yangtools.yang.data.api.schema.tree;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThrows;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
assertEquals(Optional.empty(), aggregationResult.getRootNode().getDataAfter());
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testLeafUnmodifiedDeleteWithoutDataBefore() {
DataTreeCandidateNode node1 = dataTreeCandidateNode(null, null,
ModificationType.UNMODIFIED);
ModificationType.DELETE);
DataTreeCandidate candidate2 = new DefaultDataTreeCandidate(ROOT_PATH, node2);
- DataTreeCandidates.aggregate(Arrays.asList(candidate1, candidate2));
+ assertThrows(IllegalArgumentException.class,
+ () -> DataTreeCandidates.aggregate(Arrays.asList(candidate1, candidate2)));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testLeafUnmodifiedSubtreeModifiedWithoutDataBefore() {
DataTreeCandidateNode node1 = dataTreeCandidateNode(null, null,
ModificationType.UNMODIFIED);
ModificationType.SUBTREE_MODIFIED);
DataTreeCandidate candidate2 = new DefaultDataTreeCandidate(ROOT_PATH, node2);
- DataTreeCandidates.aggregate(Arrays.asList(candidate1, candidate2));
+ assertThrows(IllegalArgumentException.class,
+ () -> DataTreeCandidates.aggregate(Arrays.asList(candidate1, candidate2)));
}
@Test
assertEquals("value2", aggregationResult.getRootNode().getDataAfter().get().getValue());
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testLeafDeleteDelete() {
NormalizedNode<?, ?> normalizedNode1 = normalizedNode("value1");
ModificationType.DELETE);
DataTreeCandidate candidate2 = new DefaultDataTreeCandidate(ROOT_PATH, node2);
- DataTreeCandidates.aggregate(Arrays.asList(candidate1, candidate2));
+ assertThrows(IllegalArgumentException.class,
+ () -> DataTreeCandidates.aggregate(Arrays.asList(candidate1, candidate2)));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testLeafDeleteDisappear() {
NormalizedNode<?, ?> normalizedNode1 = normalizedNode("value1");
ModificationType.DISAPPEARED);
DataTreeCandidate candidate2 = new DefaultDataTreeCandidate(ROOT_PATH, node2);
- DataTreeCandidates.aggregate(Arrays.asList(candidate1, candidate2));
+ assertThrows(IllegalArgumentException.class,
+ () -> DataTreeCandidates.aggregate(Arrays.asList(candidate1, candidate2)));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testLeafDeleteSubtreeModified() {
NormalizedNode<?, ?> normalizedNode1 = normalizedNode("value1");
ModificationType.SUBTREE_MODIFIED);
DataTreeCandidate candidate2 = new DefaultDataTreeCandidate(ROOT_PATH, node2);
- DataTreeCandidates.aggregate(Arrays.asList(candidate1, candidate2));
+ assertThrows(IllegalArgumentException.class,
+ () -> DataTreeCandidates.aggregate(Arrays.asList(candidate1, candidate2)));
}
@Test
assertEquals(ModificationType.WRITE, aggregationResult.getRootNode().getModificationType());
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testUnmodifiedSubtreeModifiedWithoutDataBefore() {
NormalizedNode<?, ?> parentNode = normalizedNode("container");
NormalizedNode<?, ?> childNode = normalizedNode("child");
setChildNodes(node2, Collections.singletonList(child2));
DataTreeCandidate candidate2 = new DefaultDataTreeCandidate(ROOT_PATH, node2);
- DataTreeCandidates.aggregate(Arrays.asList(candidate1, candidate2));
+ assertThrows(IllegalArgumentException.class,
+ () -> DataTreeCandidates.aggregate(Arrays.asList(candidate1, candidate2)));
}
//FIXME
assertEquals(ModificationType.SUBTREE_MODIFIED, aggregationResult.getRootNode().getModificationType());
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testUnmodifiedAppearedWithDataBefore() {
NormalizedNode<?, ?> parentNode1 = normalizedNode("container1");
NormalizedNode<?, ?> childNode1 = normalizedNode("child1");
setChildNodes(node2, Collections.singletonList(child2));
DataTreeCandidate candidate2 = new DefaultDataTreeCandidate(ROOT_PATH, node2);
- DataTreeCandidates.aggregate(Arrays.asList(candidate1, candidate2));
+ assertThrows(IllegalArgumentException.class,
+ () -> DataTreeCandidates.aggregate(Arrays.asList(candidate1, candidate2)));
}
//FIXME
assertEquals(ModificationType.APPEARED, aggregationResult.getRootNode().getModificationType());
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testUnmodifiedDisappearWithoutDataBefore() {
NormalizedNode<?, ?> parentNode = normalizedNode("container");
NormalizedNode<?, ?> childNode = normalizedNode("child");
setChildNodes(node2, Collections.singletonList(child2));
DataTreeCandidate candidate2 = new DefaultDataTreeCandidate(ROOT_PATH, node2);
- DataTreeCandidates.aggregate(Arrays.asList(candidate1, candidate2));
+ assertThrows(IllegalArgumentException.class,
+ () -> DataTreeCandidates.aggregate(Arrays.asList(candidate1, candidate2)));
}
@Test
assertEquals(ModificationType.WRITE, aggregationResult.getRootNode().getModificationType());
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testWriteAppear() {
NormalizedNode<?, ?> parentNode1 = normalizedNode("container1");
NormalizedNode<?, ?> parentNode2 = normalizedNode("container2");
setChildNodes(node2, Collections.singletonList(child2));
DataTreeCandidate candidate2 = new DefaultDataTreeCandidate(ROOT_PATH, node2);
- DataTreeCandidates.aggregate(Arrays.asList(candidate1, candidate2));
+ assertThrows(IllegalArgumentException.class,
+ () -> DataTreeCandidates.aggregate(Arrays.asList(candidate1, candidate2)));
}
@Test
assertEquals(ModificationType.SUBTREE_MODIFIED, aggregationResult.getRootNode().getModificationType());
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testSubtreeModifiedAppear() {
NormalizedNode<?, ?> parentNode1 = normalizedNode("container");
NormalizedNode<?, ?> parentNode2 = normalizedNode("value2");
setChildNodes(node2, Collections.singletonList(child2));
DataTreeCandidate candidate2 = new DefaultDataTreeCandidate(ROOT_PATH, node2);
- DataTreeCandidates.aggregate(Arrays.asList(candidate1, candidate2));
+ assertThrows(IllegalArgumentException.class,
+ () -> DataTreeCandidates.aggregate(Arrays.asList(candidate1, candidate2)));
}
@Test
assertEquals(ModificationType.APPEARED, aggregationResult.getRootNode().getModificationType());
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testAppearedAppeared() {
NormalizedNode<?, ?> parentNode1 = normalizedNode("container");
NormalizedNode<?, ?> childNode1 = normalizedNode("child1");
setChildNodes(node2, Collections.singletonList(child2));
DataTreeCandidate candidate2 = new DefaultDataTreeCandidate(ROOT_PATH, node2);
- DataTreeCandidates.aggregate(Arrays.asList(candidate1, candidate2));
+ assertThrows(IllegalArgumentException.class,
+ () -> DataTreeCandidates.aggregate(Arrays.asList(candidate1, candidate2)));
}
@Test
assertEquals(ModificationType.DISAPPEARED, aggregationResult.getRootNode().getModificationType());
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testDisappearedDelete() {
NormalizedNode<?, ?> parentNode1 = normalizedNode("container");
NormalizedNode<?, ?> childNode1 = normalizedNode("child1");
setChildNodes(node2, Collections.singletonList(child2));
DataTreeCandidate candidate2 = new DefaultDataTreeCandidate(ROOT_PATH, node2);
- DataTreeCandidates.aggregate(Arrays.asList(candidate1, candidate2));
+ assertThrows(IllegalArgumentException.class,
+ () -> DataTreeCandidates.aggregate(Arrays.asList(candidate1, candidate2)));
}
@Test
assertEquals(ModificationType.WRITE, aggregationResult.getRootNode().getModificationType());
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testDisappearedSubtreeModified() {
NormalizedNode<?, ?> parentNode1 = normalizedNode("container");
NormalizedNode<?, ?> childNode1 = normalizedNode("child1");
setChildNodes(node2, Collections.singletonList(child2));
DataTreeCandidate candidate2 = new DefaultDataTreeCandidate(ROOT_PATH, node2);
- DataTreeCandidates.aggregate(Arrays.asList(candidate1, candidate2));
+ assertThrows(IllegalArgumentException.class,
+ () -> DataTreeCandidates.aggregate(Arrays.asList(candidate1, candidate2)));
}
@Test
assertEquals(ModificationType.SUBTREE_MODIFIED, aggregationResult.getRootNode().getModificationType());
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testDisappearedDisappear() {
NormalizedNode<?, ?> parentNode1 = normalizedNode("container");
NormalizedNode<?, ?> childNode1 = normalizedNode("child1");
setChildNodes(node2, Collections.singletonList(child2));
DataTreeCandidate candidate2 = new DefaultDataTreeCandidate(ROOT_PATH, node2);
- DataTreeCandidates.aggregate(Arrays.asList(candidate1, candidate2));
+ assertThrows(IllegalArgumentException.class,
+ () -> DataTreeCandidates.aggregate(Arrays.asList(candidate1, candidate2)));
}
private static NormalizedNode<?, ?> normalizedNode(final String value) {
* 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.yangtools.yang.data.api.schema.tree;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.isNull;
import static org.mockito.Mockito.doReturn;
doReturn(ModificationType.APPEARED).when(mockedDataTreeCandidateNode).getModificationType();
- try {
- DataTreeCandidates.applyToModification(mockedModification, mockedDataTreeCandidate);
- fail("An IllegalArgumentException should have been thrown!");
- } catch (IllegalArgumentException ex) {
- assertTrue(ex.getMessage().contains("Unsupported modification"));
- }
+ final IllegalArgumentException ex = assertThrows(IllegalArgumentException.class,
+ () -> DataTreeCandidates.applyToModification(mockedModification, mockedDataTreeCandidate));
+ assertThat(ex.getMessage(), containsString("Unsupported modification"));
}
}
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import org.junit.Before;
source.getCost());
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testNegativeCost() {
- PotentialSchemaSource.create(sourceIdentifier, TestSchemaSourceRepresentation.class, -1);
+ assertThrows(IllegalArgumentException.class,
+ () -> PotentialSchemaSource.create(sourceIdentifier, TestSchemaSourceRepresentation.class, -1));
}
@Test