-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add vdmj.mappings resource and ClassMapperTest
- Loading branch information
1 parent
d80fd9f
commit eea1cac
Showing
9 changed files
with
275 additions
and
10 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
58 changes: 58 additions & 0 deletions
58
vdmj/src/test/java/com/fujitsu/vdmj/mapper/ClassMapperTest.java
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,58 @@ | ||
/******************************************************************************* | ||
* | ||
* Copyright (c) 2024 Nick Battle. | ||
* | ||
* Author: Nick Battle | ||
* | ||
* This file is part of VDMJ. | ||
* | ||
* VDMJ is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* VDMJ is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with VDMJ. If not, see <http://www.gnu.org/licenses/>. | ||
* SPDX-License-Identifier: GPL-3.0-or-later | ||
* | ||
******************************************************************************/ | ||
|
||
package com.fujitsu.vdmj.mapper; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.fail; | ||
|
||
import org.junit.Test; | ||
|
||
import com.fujitsu.vdmj.mapper.extra.TestExtra; | ||
|
||
/** | ||
* Basic tests of the ClassMapper. | ||
*/ | ||
public class ClassMapperTest | ||
{ | ||
@Test | ||
public void test() | ||
{ | ||
// Properties.mapping_search_path = "/mapper"; | ||
// Also uses the vdmj.mappings resource to add extra search paths | ||
ClassMapper mapper = ClassMapper.getInstance("test.mappings"); | ||
assertEquals(0, mapper.getNodeCount()); | ||
|
||
try | ||
{ | ||
TestSource source = new TestSource("top", new TestSource("left"), new TestExtra("right")); | ||
TestDestination dest = mapper.convert(source); | ||
assertEquals("top[left[null,null],Extra:right[null,null]]", dest.toString()); | ||
} | ||
catch (Exception e) | ||
{ | ||
fail("Failed with " + e); | ||
} | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
vdmj/src/test/java/com/fujitsu/vdmj/mapper/TestDestination.java
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,53 @@ | ||
/******************************************************************************* | ||
* | ||
* Copyright (c) 2023 Nick Battle. | ||
* | ||
* Author: Nick Battle | ||
* | ||
* This file is part of VDMJ. | ||
* | ||
* VDMJ is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* VDMJ is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with VDMJ. If not, see <http://www.gnu.org/licenses/>. | ||
* SPDX-License-Identifier: GPL-3.0-or-later | ||
* | ||
******************************************************************************/ | ||
package com.fujitsu.vdmj.mapper; | ||
|
||
public class TestDestination implements Mappable | ||
{ | ||
public final String name; | ||
public final TestDestination left; | ||
public final TestDestination right; | ||
|
||
public TestDestination(String name, TestDestination left, TestDestination right) | ||
{ | ||
this.name = name; | ||
this.left = left; | ||
this.right = right; | ||
} | ||
|
||
@Override | ||
public String toString() | ||
{ | ||
StringBuilder s = new StringBuilder(); | ||
|
||
s.append(name); | ||
s.append("["); | ||
s.append(left); | ||
s.append(","); | ||
s.append(right); | ||
s.append("]"); | ||
|
||
return s.toString(); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
vdmj/src/test/java/com/fujitsu/vdmj/mapper/TestSource.java
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,43 @@ | ||
/******************************************************************************* | ||
* | ||
* Copyright (c) 2023 Nick Battle. | ||
* | ||
* Author: Nick Battle | ||
* | ||
* This file is part of VDMJ. | ||
* | ||
* VDMJ is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* VDMJ is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with VDMJ. If not, see <http://www.gnu.org/licenses/>. | ||
* SPDX-License-Identifier: GPL-3.0-or-later | ||
* | ||
******************************************************************************/ | ||
package com.fujitsu.vdmj.mapper; | ||
|
||
public class TestSource implements Mappable | ||
{ | ||
public final String name; | ||
public final TestSource left; | ||
public final TestSource right; | ||
|
||
public TestSource(String name, TestSource left, TestSource right) | ||
{ | ||
this.name = name; | ||
this.left = left; | ||
this.right = right; | ||
} | ||
|
||
public TestSource(String name) | ||
{ | ||
this(name, null, null); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
vdmj/src/test/java/com/fujitsu/vdmj/mapper/extra/TestDestExtra.java
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,40 @@ | ||
/******************************************************************************* | ||
* | ||
* Copyright (c) 2023 Nick Battle. | ||
* | ||
* Author: Nick Battle | ||
* | ||
* This file is part of VDMJ. | ||
* | ||
* VDMJ is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* VDMJ is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with VDMJ. If not, see <http://www.gnu.org/licenses/>. | ||
* SPDX-License-Identifier: GPL-3.0-or-later | ||
* | ||
******************************************************************************/ | ||
package com.fujitsu.vdmj.mapper.extra; | ||
|
||
import com.fujitsu.vdmj.mapper.TestDestination; | ||
|
||
public class TestDestExtra extends TestDestination | ||
{ | ||
public TestDestExtra(String name, TestDestination left, TestDestination right) | ||
{ | ||
super(name, left, right); | ||
} | ||
|
||
@Override | ||
public String toString() | ||
{ | ||
return "Extra:" + super.toString(); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
vdmj/src/test/java/com/fujitsu/vdmj/mapper/extra/TestExtra.java
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,39 @@ | ||
/******************************************************************************* | ||
* | ||
* Copyright (c) 2023 Nick Battle. | ||
* | ||
* Author: Nick Battle | ||
* | ||
* This file is part of VDMJ. | ||
* | ||
* VDMJ is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* VDMJ is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with VDMJ. If not, see <http://www.gnu.org/licenses/>. | ||
* SPDX-License-Identifier: GPL-3.0-or-later | ||
* | ||
******************************************************************************/ | ||
package com.fujitsu.vdmj.mapper.extra; | ||
|
||
import com.fujitsu.vdmj.mapper.TestSource; | ||
|
||
public class TestExtra extends TestSource | ||
{ | ||
public TestExtra(String name, TestExtra left, TestExtra right) | ||
{ | ||
super(name, right, right); | ||
} | ||
|
||
public TestExtra(String name) | ||
{ | ||
this(name, null, null); | ||
} | ||
} |
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,6 @@ | ||
# | ||
# Extra mappings for ClassMapperTest | ||
# | ||
|
||
package com.fujitsu.vdmj.mapper.extra to com.fujitsu.vdmj.mapper.extra; | ||
map TestExtra{name, left, right} to TestDestExtra(name, left, right); |
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,8 @@ | ||
# | ||
# Test mappings for ClassMapperTest | ||
# | ||
|
||
package com.fujitsu.vdmj.mapper to com.fujitsu.vdmj.mapper; | ||
map TestSource{name, left, right} to TestDestination(name, left, right); | ||
|
||
unmapped java.lang.String; |
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 @@ | ||
/mapper |