-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fe4cb3e
commit ccddd3a
Showing
10 changed files
with
365 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* | ||
* | ||
* * Copyright 2019 Max Berkelmans | ||
* * | ||
* * Licensed under the Apache License, Version 2.0 (the "License"); | ||
* * you may not use this file except in compliance with the License. | ||
* * You may obtain a copy of the License at | ||
* * | ||
* * http://www.apache.org/licenses/LICENSE-2.0 | ||
* * | ||
* * Unless required by applicable law or agreed to in writing, software | ||
* * distributed under the License is distributed on an "AS IS" BASIS, | ||
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* * See the License for the specific language governing permissions and | ||
* * limitations under the License. | ||
* | ||
*/ | ||
|
||
package me.max.migrational; | ||
|
||
import me.max.migrational.testobjects.ClassObject; | ||
import org.junit.AfterClass; | ||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
|
||
import java.lang.reflect.InvocationTargetException; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
/** | ||
* This is test class and will check if migration is still working correctly | ||
* This was made to not need to manually test if it still works after making changes | ||
* | ||
* @author Max Berkelmans | ||
* @since 1.1.0 | ||
*/ | ||
public class ClassMigrationTest { | ||
|
||
private static ClassObject testObject; | ||
|
||
@BeforeClass | ||
public static void setUp() throws IllegalAccessException, InstantiationException, InvocationTargetException { | ||
Map<String, Object> data = new HashMap<>(); | ||
data.put("name", "Stijn"); | ||
|
||
testObject = (ClassObject) new Migrator(ClassObject.class, data).migrateToClass(); | ||
|
||
} | ||
|
||
@AfterClass | ||
public static void tearDown() { | ||
testObject = null; | ||
} | ||
|
||
@Test | ||
public void migrate_Name_ReturnsStijn() { | ||
final String expected = "Stijn"; | ||
|
||
final String actual = testObject.getName(); | ||
|
||
assertEquals(expected, actual); | ||
} | ||
|
||
@Test | ||
public void migrate_Age_ReturnsTwentySeven() { | ||
final int expected = 27; | ||
|
||
final int actual = testObject.getAge(); | ||
|
||
assertEquals(expected, actual); | ||
} | ||
|
||
@Test | ||
public void migrate_IsCool_ReturnsTrue() { | ||
final boolean actual = testObject.isCool(); | ||
|
||
assertTrue(actual); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* | ||
* | ||
* * Copyright 2019 Max Berkelmans | ||
* * | ||
* * Licensed under the Apache License, Version 2.0 (the "License"); | ||
* * you may not use this file except in compliance with the License. | ||
* * You may obtain a copy of the License at | ||
* * | ||
* * http://www.apache.org/licenses/LICENSE-2.0 | ||
* * | ||
* * Unless required by applicable law or agreed to in writing, software | ||
* * distributed under the License is distributed on an "AS IS" BASIS, | ||
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* * See the License for the specific language governing permissions and | ||
* * limitations under the License. | ||
* | ||
*/ | ||
|
||
package me.max.migrational; | ||
|
||
import me.max.migrational.testobjects.FieldObject; | ||
import org.junit.AfterClass; | ||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
|
||
import java.lang.reflect.InvocationTargetException; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
/** | ||
* This test class will check for migration of {@link me.max.migrational.annotations.Migratable} {@link java.lang.reflect.Field}s. | ||
* | ||
* @author Max Berkelmans | ||
* @since 1.1.0 | ||
*/ | ||
public class FieldMigrationTest { | ||
|
||
private static FieldObject testObject; | ||
|
||
@BeforeClass | ||
public static void setUp() throws IllegalAccessException, InstantiationException, InvocationTargetException { | ||
Map<String, Object> data = new HashMap<>(); | ||
data.put("name", "Stijn"); | ||
data.put("age", 20); | ||
|
||
testObject = (FieldObject) new Migrator(FieldObject.class, data).migrateToClass(); | ||
} | ||
|
||
@AfterClass | ||
public static void tearDown() { | ||
testObject = null; | ||
} | ||
|
||
@Test | ||
public void migrate_Name_ReturnsStijn() { | ||
final String expected = "Stijn"; | ||
|
||
final String actual = testObject.getName(); | ||
|
||
assertEquals(expected, actual); | ||
} | ||
|
||
@Test | ||
public void migrate_Age_ReturnsTwenty() { | ||
final int expected = 20; | ||
|
||
final int actual = testObject.getAge(); | ||
|
||
assertEquals(expected, actual); | ||
} | ||
|
||
@Test | ||
public void migrate_Country_ReturnsNetherlands() { | ||
final String expected = "Netherlands"; | ||
|
||
final String actual = testObject.getCountry(); | ||
|
||
assertEquals(expected, actual); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* | ||
* * Copyright 2019 Max Berkelmans | ||
* * | ||
* * Licensed under the Apache License, Version 2.0 (the "License"); | ||
* * you may not use this file except in compliance with the License. | ||
* * You may obtain a copy of the License at | ||
* * | ||
* * http://www.apache.org/licenses/LICENSE-2.0 | ||
* * | ||
* * Unless required by applicable law or agreed to in writing, software | ||
* * distributed under the License is distributed on an "AS IS" BASIS, | ||
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* * See the License for the specific language governing permissions and | ||
* * limitations under the License. | ||
* | ||
*/ | ||
|
||
/** | ||
* This is the root package for testing migrational. | ||
* This package contains all tests for migrating. | ||
* These classes are made to not have to manually check if migration is still working. | ||
* <p> | ||
* The package {@link me.max.migrational.testobjects} contains all the test objects used by the test classes. | ||
* | ||
* @author Max Berkelmans | ||
* @since 1.1.0 | ||
*/ | ||
package me.max.migrational; |
Oops, something went wrong.