Migrate to JUnit5

This commit is contained in:
Artur Mogozov
2017-12-31 16:29:48 +09:00
parent a20e54d0a7
commit 6694d742a3
408 changed files with 2656 additions and 2165 deletions

View File

@ -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

View File

@ -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);

View File

@ -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);
});
}
}