Migrate to JUnit5
This commit is contained in:
@ -23,30 +23,36 @@
|
||||
|
||||
package com.iluwatar.featuretoggle.pattern.propertiesversion;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import com.iluwatar.featuretoggle.pattern.Service;
|
||||
import com.iluwatar.featuretoggle.user.User;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Properties;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
/**
|
||||
* Test Properties Toggle
|
||||
*/
|
||||
public class PropertiesFeatureToggleVersionTest {
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Test
|
||||
public void testNullPropertiesPassed() throws Exception {
|
||||
new PropertiesFeatureToggleVersion(null);
|
||||
assertThrows(IllegalArgumentException.class, () -> {
|
||||
new PropertiesFeatureToggleVersion(null);
|
||||
});
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Test
|
||||
public void testNonBooleanProperty() throws Exception {
|
||||
final Properties properties = new Properties();
|
||||
properties.setProperty("enhancedWelcome", "Something");
|
||||
new PropertiesFeatureToggleVersion(properties);
|
||||
assertThrows(IllegalArgumentException.class, () -> {
|
||||
final Properties properties = new Properties();
|
||||
properties.setProperty("enhancedWelcome", "Something");
|
||||
new PropertiesFeatureToggleVersion(properties);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -22,14 +22,14 @@
|
||||
*/
|
||||
package com.iluwatar.featuretoggle.pattern.tieredversion;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import com.iluwatar.featuretoggle.pattern.Service;
|
||||
import com.iluwatar.featuretoggle.user.User;
|
||||
import com.iluwatar.featuretoggle.user.UserGroup;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
/**
|
||||
* Test Tiered Feature Toggle
|
||||
@ -40,7 +40,7 @@ public class TieredFeatureToggleVersionTest {
|
||||
final User freeUser = new User("Alan Defect");
|
||||
final Service service = new TieredFeatureToggleVersion();
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() throws Exception {
|
||||
UserGroup.addUserToPaidGroup(paidUser);
|
||||
UserGroup.addUserToFreeGroup(freeUser);
|
||||
|
@ -22,10 +22,11 @@
|
||||
*/
|
||||
package com.iluwatar.featuretoggle.user;
|
||||
|
||||
import static junit.framework.TestCase.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.junit.Test;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
/**
|
||||
* Test User Group specific feature
|
||||
@ -46,17 +47,21 @@ public class UserGroupTest {
|
||||
assertTrue(UserGroup.isPaid(user));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Test
|
||||
public void testAddUserToPaidWhenOnFree() throws Exception {
|
||||
User user = new User("Paid User");
|
||||
UserGroup.addUserToFreeGroup(user);
|
||||
UserGroup.addUserToPaidGroup(user);
|
||||
assertThrows(IllegalArgumentException.class, () -> {
|
||||
UserGroup.addUserToPaidGroup(user);
|
||||
});
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Test
|
||||
public void testAddUserToFreeWhenOnPaid() throws Exception {
|
||||
User user = new User("Free User");
|
||||
UserGroup.addUserToPaidGroup(user);
|
||||
UserGroup.addUserToFreeGroup(user);
|
||||
assertThrows(IllegalArgumentException.class, () -> {
|
||||
UserGroup.addUserToFreeGroup(user);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user