-
Notifications
You must be signed in to change notification settings - Fork 586
/
abstractImmutablePrimitiveObjectMapTestCase.stg
117 lines (94 loc) · 4.02 KB
/
abstractImmutablePrimitiveObjectMapTestCase.stg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
import "copyright.stg"
import "primitiveHashCode.stg"
import "primitiveLiteral.stg"
isTest() ::= "true"
targetPath() ::= "org/eclipse/collections/impl/map/immutable/primitive"
fileName(primitive) ::= "AbstractImmutable<primitive.name>ObjectMapTestCase"
skipBoolean() ::= "true"
class(primitive) ::= <<
<body(primitive.type, primitive.name)>
>>
body(type, name) ::= <<
<copyright()>
package org.eclipse.collections.impl.map.immutable.primitive;
import java.util.Iterator;
import org.eclipse.collections.api.map.primitive.Immutable<name>ObjectMap;
import org.eclipse.collections.impl.factory.primitive.<name>ObjectMaps;
import org.eclipse.collections.impl.factory.primitive.Object<name>Maps;
import org.eclipse.collections.impl.map.mutable.primitive.<name>ObjectHashMap;
import org.eclipse.collections.impl.map.mutable.primitive.Object<name>HashMap;
import org.eclipse.collections.impl.map.primitive.Abstract<name>ObjectMapTestCase;
import org.eclipse.collections.impl.test.Verify;
import org.junit.Assert;
import org.junit.Test;
/**
* Abstract JUnit test for {@link Immutable<name>ObjectMap}.
* This file was automatically generated from template file abstractImmutablePrimitiveObjectMapTestCase.stg.
*/
public abstract class AbstractImmutable<name>ObjectMapTestCase extends Abstract<name>ObjectMapTestCase
{
@Override
protected abstract Immutable<name>ObjectMap\<String> classUnderTest();
@Override
protected \<T> Immutable<name>ObjectMap\<T> newWithKeysValues(<type> key1, T value1)
{
return <name>ObjectMaps.immutable.with(key1, value1);
}
@Override
protected \<T> Immutable<name>ObjectMap\<T> newWithKeysValues(<type> key1, T value1, <type> key2, T value2)
{
return <name>ObjectMaps.immutable.withAll(<name>ObjectHashMap.newWithKeysValues(key1, value1, key2, value2));
}
@Override
protected \<T> Immutable<name>ObjectMap\<T> newWithKeysValues(<type> key1, T value1, <type> key2, T value2, <type> key3, T value3)
{
return <name>ObjectMaps.immutable.withAll(<name>ObjectHashMap.newWithKeysValues(key1, value1, key2, value2, key3, value3));
}
@Override
protected \<T> Immutable<name>ObjectMap\<T> getEmptyMap()
{
return <name>ObjectMaps.immutable.with();
}
@Override
@Test
public void toImmutable()
{
super.toImmutable();
Immutable<name>ObjectMap\<String> map = this.classUnderTest();
Assert.assertSame(map, map.toImmutable());
}
@Override
@Test
public void iterator()
{
super.iterator();
Iterator\<String> iterator = this.classUnderTest().iterator();
iterator.next();
Verify.assertThrows(UnsupportedOperationException.class, iterator::remove);
}
@Override
@Test
public void keySet()
{
super.keySet();
Verify.assertThrows(UnsupportedOperationException.class, () -> { this.classUnderTest().keySet().remove(<(literal.(type))("0")>); });
}
@Override
public void values()
{
super.values();
Verify.assertThrows(UnsupportedOperationException.class, () -> { this.classUnderTest().values().remove("zero"); });
}
@Test
public void flipUniqueValues()
{
Assert.assertEquals(Object<name>Maps.immutable.empty(), <name>ObjectMaps.immutable.empty().flipUniqueValues());
Verify.assertInstanceOf(ImmutableObject<name>EmptyMap.class, <name>ObjectMaps.immutable.empty().flipUniqueValues());
Assert.assertEquals(Object<name>Maps.immutable.with("2", <(literal.(type))("1")>), this.newWithKeysValues(<(literal.(type))("1")>, "2").flipUniqueValues());
Assert.assertEquals(
Object<name>HashMap.newWithKeysValues("2", <(literal.(type))("1")>, "3", <(literal.(type))("2")>).toImmutable(),
this.newWithKeysValues(<(literal.(type))("1")>, "2", <(literal.(type))("2")>, "3").flipUniqueValues());
Verify.assertThrows(IllegalStateException.class, () -> this.newWithKeysValues(<(literal.(type))("1")>, "1", <(literal.(type))("2")>, "1").flipUniqueValues());
}
}
>>