diff options
author | Jim Hahn <jrh3@att.com> | 2019-01-08 17:15:07 -0500 |
---|---|---|
committer | Jim Hahn <jrh3@att.com> | 2019-01-08 17:16:01 -0500 |
commit | a392ecb9bd7deca0791f4c16f5fee11ba53dc4e3 (patch) | |
tree | 48c849ada86552e21ccb6d1153f232d24a1e1bae /policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/TopicFactoryTestBase.java | |
parent | 7b150f6820d61b8c65b6ddd5f4952ad3d4d17c6c (diff) |
Replace expectException with AssertJ
Change-Id: I73c186f181960ac7ac8cd985e55db1831963910f
Issue-ID: POLICY-1392
Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/TopicFactoryTestBase.java')
-rw-r--r-- | policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/TopicFactoryTestBase.java | 38 |
1 files changed, 8 insertions, 30 deletions
diff --git a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/TopicFactoryTestBase.java b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/TopicFactoryTestBase.java index 29816c6e..419f9506 100644 --- a/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/TopicFactoryTestBase.java +++ b/policy-endpoints/src/test/java/org/onap/policy/common/endpoints/event/comm/bus/TopicFactoryTestBase.java @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * policy-endpoints * ================================================================================ - * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. + * Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,10 +20,11 @@ package org.onap.policy.common.endpoints.event.comm.bus; +import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; +import static org.assertj.core.api.Assertions.assertThatIllegalStateException; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; import static org.onap.policy.common.endpoints.properties.PolicyEndPointProperties.PROPERTY_TOPIC_SERVERS_SUFFIX; import java.util.List; @@ -175,12 +176,10 @@ public abstract class TopicFactoryTestBase<T extends Topic> extends TopicTestBas */ public void testDestroyString_Ex() { // null topic - RuntimeException actual = expectException(() -> destroyTopic(null)); - assertEquals(IllegalArgumentException.class, actual.getClass()); + assertThatIllegalArgumentException().as("null topic").isThrownBy(() -> destroyTopic(null)); // empty topic - actual = expectException(() -> destroyTopic("")); - assertEquals(IllegalArgumentException.class, actual.getClass()); + assertThatIllegalArgumentException().as("empty topic").isThrownBy(() -> destroyTopic("")); } /** @@ -210,36 +209,15 @@ public abstract class TopicFactoryTestBase<T extends Topic> extends TopicTestBas */ public void testGet_Ex() { // null topic - RuntimeException actual = expectException(() -> getTopic(null)); - assertEquals("null topic", IllegalArgumentException.class, actual.getClass()); + assertThatIllegalArgumentException().as("null topic").isThrownBy(() -> getTopic(null)); // empty topic - actual = expectException(() -> getTopic("")); - assertEquals("empty topic", IllegalArgumentException.class, actual.getClass()); + assertThatIllegalArgumentException().as("empty topic").isThrownBy(() -> getTopic("")); // unknown topic initFactory(); buildTopics(makePropBuilder().makeTopic(MY_TOPIC).build()); - actual = expectException(() -> getTopic(TOPIC2)); - assertEquals("unknown topic", IllegalStateException.class, actual.getClass()); - } - - /** - * Runs a function that is expected to throw an exception. Invokes fail() if the - * function does not throw an exception. - * - * @param function the function to run - * @return the exception thrown by the function - */ - public RuntimeException expectException(Runnable function) { - try { - function.run(); - fail("missing exception"); - return null; - - } catch (RuntimeException e) { - return e; - } + assertThatIllegalStateException().as("unknown topic").isThrownBy(() -> getTopic(TOPIC2)); } } |