Skip to content

Commit a1395a1

Browse files
authored
Remove unnecessary equals and hashcode tests (#34)
1 parent 7e12f16 commit a1395a1

7 files changed

Lines changed: 0 additions & 325 deletions

src/test/java/com/teragrep/cnf_01/ArgsConfigurationTest.java

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -134,58 +134,6 @@ public void testImmutability() {
134134
Assertions.assertThrows(UnsupportedOperationException.class, () -> map.put("foo", "bar")); // The map is immutable
135135
}
136136

137-
@Test
138-
public void testEquals() {
139-
String[] args = {
140-
"foo=bar", "bar=foo"
141-
};
142-
ArgsConfiguration config = new ArgsConfiguration(args);
143-
144-
String[] args2 = {
145-
"foo=bar", "bar=foo"
146-
};
147-
ArgsConfiguration config2 = new ArgsConfiguration(args2);
148-
149-
Assertions.assertDoesNotThrow(config::asMap);
150-
151-
Assertions.assertEquals(config, config2);
152-
}
153-
154-
@Test
155-
public void testNotEquals() {
156-
String[] args = {
157-
"foo=bar", "bar=foo"
158-
};
159-
String[] args2 = {
160-
""
161-
};
162-
163-
ArgsConfiguration config = new ArgsConfiguration(args);
164-
ArgsConfiguration config2 = new ArgsConfiguration(args2);
165-
166-
Assertions.assertNotEquals(config, config2);
167-
}
168-
169-
@Test
170-
public void testHashCode() {
171-
String[] args = {
172-
"foo=bar", "bar=foo"
173-
};
174-
String[] args2 = {
175-
"foo=bar", "bar=foo"
176-
};
177-
String[] args3 = {
178-
""
179-
};
180-
181-
ArgsConfiguration config = new ArgsConfiguration(args);
182-
ArgsConfiguration config2 = new ArgsConfiguration(args2);
183-
ArgsConfiguration config3 = new ArgsConfiguration(args3);
184-
185-
Assertions.assertEquals(config.hashCode(), config2.hashCode());
186-
Assertions.assertNotEquals(config.hashCode(), config3.hashCode());
187-
}
188-
189137
@Test
190138
public void testEqualsVerifier() {
191139
EqualsVerifier.forClass(ArgsConfiguration.class).withNonnullFields("args").verify();

src/test/java/com/teragrep/cnf_01/DefaultConfigurationTest.java

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -92,58 +92,6 @@ public void testInvalidConfiguration() {
9292
Assertions.assertEquals("test", result.get("test"));
9393
}
9494

95-
@Test
96-
public void testEquals() {
97-
PathConfiguration pathConfig1 = new PathConfiguration("src/test/resources/configuration.properties");
98-
ImmutableMap<String, String> defaults1 = Assertions
99-
.assertDoesNotThrow(() -> new ImmutabilitySupportedMap<>(pathConfig1.asMap()).toImmutableMap());
100-
PathConfiguration pathConfig2 = new PathConfiguration("src/test/resources/configuration.properties");
101-
ImmutableMap<String, String> defaults2 = Assertions
102-
.assertDoesNotThrow(() -> new ImmutabilitySupportedMap<>(pathConfig2.asMap()).toImmutableMap());
103-
104-
DefaultConfiguration defaultConfiguration1 = new DefaultConfiguration(pathConfig1, defaults1);
105-
DefaultConfiguration defaultConfiguration2 = new DefaultConfiguration(pathConfig2, defaults2);
106-
107-
defaultConfiguration1.asMap();
108-
109-
Assertions.assertEquals(defaultConfiguration1, defaultConfiguration2);
110-
}
111-
112-
@Test
113-
public void testNotEquals() {
114-
PathConfiguration pathConfig1 = new PathConfiguration("src/test/resources/configuration.properties");
115-
ImmutableMap<String, String> defaults1 = Assertions
116-
.assertDoesNotThrow(() -> new ImmutabilitySupportedMap<>(pathConfig1.asMap()).toImmutableMap());
117-
PathConfiguration pathConfig2 = new PathConfiguration("invalid.path");
118-
ImmutableMap<String, String> defaults2 = new ImmutabilitySupportedMap<String, String>(new HashMap<>())
119-
.toImmutableMap();
120-
121-
DefaultConfiguration defaultConfiguration1 = new DefaultConfiguration(pathConfig1, defaults1);
122-
DefaultConfiguration defaultConfiguration2 = new DefaultConfiguration(pathConfig2, defaults2);
123-
124-
Assertions.assertNotEquals(defaultConfiguration1, defaultConfiguration2);
125-
}
126-
127-
@Test
128-
public void testHashCode() {
129-
PathConfiguration pathConfig1 = new PathConfiguration("src/test/resources/configuration.properties");
130-
ImmutableMap<String, String> defaults1 = Assertions
131-
.assertDoesNotThrow(() -> new ImmutabilitySupportedMap<>(pathConfig1.asMap()).toImmutableMap());
132-
PathConfiguration pathConfig2 = new PathConfiguration("src/test/resources/configuration.properties");
133-
ImmutableMap<String, String> defaults2 = Assertions
134-
.assertDoesNotThrow(() -> new ImmutabilitySupportedMap<>(pathConfig2.asMap()).toImmutableMap());
135-
PathConfiguration difPathConfig = new PathConfiguration("invalid.path");
136-
ImmutableMap<String, String> difDefaults = new ImmutabilitySupportedMap<String, String>(new HashMap<>())
137-
.toImmutableMap();
138-
139-
DefaultConfiguration defaultConfiguration1 = new DefaultConfiguration(pathConfig1, defaults1);
140-
DefaultConfiguration defaultConfiguration2 = new DefaultConfiguration(pathConfig2, defaults2);
141-
DefaultConfiguration difDefaultConfiguration = new DefaultConfiguration(difPathConfig, difDefaults);
142-
143-
Assertions.assertEquals(defaultConfiguration1.hashCode(), defaultConfiguration2.hashCode());
144-
Assertions.assertNotEquals(defaultConfiguration1.hashCode(), difDefaultConfiguration.hashCode());
145-
}
146-
14795
@Test
14896
public void testEqualsVerifier() {
14997
EqualsVerifier

src/test/java/com/teragrep/cnf_01/EnvironmentConfigurationTest.java

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -91,55 +91,6 @@ public void testEmptyMap() {
9191
Assertions.assertTrue(result.isEmpty());
9292
}
9393

94-
@Test
95-
public void testEqualsEnvironment() {
96-
EnvironmentConfiguration env1 = new EnvironmentConfiguration();
97-
EnvironmentConfiguration env2 = new EnvironmentConfiguration();
98-
99-
env1.asMap();
100-
101-
Assertions.assertEquals(env1, env2);
102-
}
103-
104-
@Test
105-
public void testEqualsMap() {
106-
Map<String, String> map1 = new HashMap<>();
107-
map1.put("foo", "bar");
108-
Map<String, String> map2 = new HashMap<>();
109-
map2.put("foo", "bar");
110-
111-
EnvironmentConfiguration env1 = new EnvironmentConfiguration(map1);
112-
EnvironmentConfiguration env2 = new EnvironmentConfiguration(map2);
113-
114-
env1.asMap();
115-
116-
Assertions.assertEquals(env1, env2);
117-
}
118-
119-
@Test
120-
public void testNotEquals() {
121-
Map<String, String> map = new HashMap<>();
122-
map.put("foo", "bar");
123-
EnvironmentConfiguration env1 = new EnvironmentConfiguration();
124-
EnvironmentConfiguration env2 = new EnvironmentConfiguration(map);
125-
126-
Assertions.assertNotEquals(env1, env2);
127-
}
128-
129-
@Test
130-
public void testHashCode() {
131-
Map<String, String> map1 = new HashMap<>();
132-
map1.put("foo", "bar");
133-
Map<String, String> map2 = new HashMap<>();
134-
map2.put("foo", "bar");
135-
EnvironmentConfiguration env1 = new EnvironmentConfiguration(map1);
136-
EnvironmentConfiguration env2 = new EnvironmentConfiguration(map2);
137-
EnvironmentConfiguration difEnv = new EnvironmentConfiguration();
138-
139-
Assertions.assertEquals(env1.hashCode(), env2.hashCode());
140-
Assertions.assertNotEquals(env1.hashCode(), difEnv.hashCode());
141-
}
142-
14394
@Test
14495
public void testEqualsVerifier() {
14596
EqualsVerifier.forClass(EnvironmentConfiguration.class).withNonnullFields("environment").verify();

src/test/java/com/teragrep/cnf_01/ImmutabilitySupportedMapTest.java

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -73,54 +73,6 @@ public void testToImmutableMap() {
7373
Assertions.assertThrows(UnsupportedOperationException.class, () -> resultMap.put("foo", "baz"));
7474
}
7575

76-
@Test
77-
public void testEquals() {
78-
Map<String, String> map1 = new HashMap<>();
79-
Map<String, String> map2 = new HashMap<>();
80-
map1.put("foo", "bar");
81-
map2.put("foo", "bar");
82-
83-
ImmutabilitySupportedMap<String, String> immutabilitySupportedMap1 = new ImmutabilitySupportedMap<>(map1);
84-
ImmutabilitySupportedMap<String, String> immutabilitySupportedMap2 = new ImmutabilitySupportedMap<>(map2);
85-
86-
// It's a Map decorator so it is mutable, but the new function toImmutableMap shouldn't mutate the object
87-
immutabilitySupportedMap1.toImmutableMap();
88-
89-
Assertions.assertEquals(immutabilitySupportedMap1, immutabilitySupportedMap2);
90-
}
91-
92-
@Test
93-
public void testNotEquals() {
94-
Map<String, String> map1 = new HashMap<>();
95-
Map<String, String> map2 = new HashMap<>();
96-
Map<String, String> difMap = new HashMap<>();
97-
map1.put("foo", "bar");
98-
map2.put("foo", "bar");
99-
100-
ImmutabilitySupportedMap<String, String> immutabilitySupportedMap1 = new ImmutabilitySupportedMap<>(map1);
101-
ImmutabilitySupportedMap<String, String> immutabilitySupportedMap2 = new ImmutabilitySupportedMap<>(map2);
102-
ImmutabilitySupportedMap<String, String> difImmutabilitySupportedMap = new ImmutabilitySupportedMap<>(difMap);
103-
104-
Assertions.assertEquals(immutabilitySupportedMap1, immutabilitySupportedMap2);
105-
Assertions.assertNotEquals(immutabilitySupportedMap1, difImmutabilitySupportedMap);
106-
}
107-
108-
@Test
109-
public void testHashCode() {
110-
Map<String, String> map1 = new HashMap<>();
111-
Map<String, String> map2 = new HashMap<>();
112-
Map<String, String> difMap = new HashMap<>();
113-
map1.put("foo", "bar");
114-
map2.put("foo", "bar");
115-
116-
ImmutabilitySupportedMap<String, String> immutabilitySupportedMap1 = new ImmutabilitySupportedMap<>(map1);
117-
ImmutabilitySupportedMap<String, String> immutabilitySupportedMap2 = new ImmutabilitySupportedMap<>(map2);
118-
ImmutabilitySupportedMap<String, String> difImmutabilitySupportedMap = new ImmutabilitySupportedMap<>(difMap);
119-
120-
Assertions.assertEquals(immutabilitySupportedMap1.hashCode(), immutabilitySupportedMap2.hashCode());
121-
Assertions.assertNotEquals(immutabilitySupportedMap1.hashCode(), difImmutabilitySupportedMap.hashCode());
122-
}
123-
12476
@Test
12577
public void testEqualsVerifier() {
12678
EqualsVerifier.forClass(ImmutabilitySupportedMap.class).withNonnullFields("map").verify();

src/test/java/com/teragrep/cnf_01/ImmutableMapTest.java

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -72,49 +72,6 @@ public void testMap() {
7272
Assertions.assertThrows(UnsupportedOperationException.class, () -> immutableMap.put("foo", "baz"));
7373
}
7474

75-
@Test
76-
public void testEquals() {
77-
Map<String, String> map1 = new HashMap<>();
78-
map1.put("foo", "bar");
79-
Map<String, String> map2 = new HashMap<>();
80-
map2.put("foo", "bar");
81-
82-
ImmutableMap<String, String> immutableMap1 = new ImmutableMap<>(map1);
83-
ImmutableMap<String, String> immutableMap2 = new ImmutableMap<>(map2);
84-
85-
immutableMap1.map();
86-
87-
Assertions.assertEquals(immutableMap1, immutableMap2);
88-
}
89-
90-
@Test
91-
public void testNotEquals() {
92-
Map<String, String> map1 = new HashMap<>();
93-
map1.put("foo", "bar");
94-
Map<String, String> map2 = new HashMap<>();
95-
96-
ImmutableMap<String, String> immutableMap1 = new ImmutableMap<>(map1);
97-
ImmutableMap<String, String> immutableMap2 = new ImmutableMap<>(map2);
98-
99-
Assertions.assertNotEquals(immutableMap1, immutableMap2);
100-
}
101-
102-
@Test
103-
public void testHashCode() {
104-
Map<String, String> map1 = new HashMap<>();
105-
map1.put("foo", "bar");
106-
Map<String, String> map2 = new HashMap<>();
107-
map2.put("foo", "bar");
108-
Map<String, String> map3 = new HashMap<>();
109-
110-
ImmutableMap<String, String> immutableMap1 = new ImmutableMap<>(map1);
111-
ImmutableMap<String, String> immutableMap2 = new ImmutableMap<>(map2);
112-
ImmutableMap<String, String> difImmutableMap = new ImmutableMap<>(map3);
113-
114-
Assertions.assertEquals(immutableMap1.hashCode(), immutableMap2.hashCode());
115-
Assertions.assertNotEquals(immutableMap1.hashCode(), difImmutableMap.hashCode());
116-
}
117-
11875
@Test
11976
public void testEqualsVerifier() {
12077
EqualsVerifier.forClass(ImmutableMap.class).withNonnullFields("map").verify();

src/test/java/com/teragrep/cnf_01/PathConfigurationTest.java

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -72,33 +72,6 @@ public void testInvalidPath() {
7272
Assertions.assertEquals("Can't find the properties file at " + path, exception.getMessage());
7373
}
7474

75-
@Test
76-
public void testEquals() {
77-
PathConfiguration config1 = new PathConfiguration("src/test/resources/configuration.properties");
78-
PathConfiguration config2 = new PathConfiguration("src/test/resources/configuration.properties");
79-
80-
Assertions.assertDoesNotThrow(config1::asMap);
81-
Assertions.assertEquals(config1, config2);
82-
}
83-
84-
@Test
85-
public void testNotEquals() {
86-
PathConfiguration config1 = new PathConfiguration("src/test/resources/configuration.properties");
87-
PathConfiguration config2 = new PathConfiguration("invalid.path");
88-
89-
Assertions.assertNotEquals(config1, config2);
90-
}
91-
92-
@Test
93-
public void testHashCode() {
94-
PathConfiguration config1 = new PathConfiguration("src/test/resources/configuration.properties");
95-
PathConfiguration config2 = new PathConfiguration("src/test/resources/configuration.properties");
96-
PathConfiguration difConfig = new PathConfiguration("invalid.path");
97-
98-
Assertions.assertEquals(config1.hashCode(), config2.hashCode());
99-
Assertions.assertNotEquals(config1.hashCode(), difConfig.hashCode());
100-
}
101-
10275
@Test
10376
public void testEqualsVerifier() {
10477
EqualsVerifier.forClass(PathConfiguration.class).withNonnullFields("file").verify();

src/test/java/com/teragrep/cnf_01/PropertiesConfigurationTest.java

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -97,60 +97,6 @@ public void testEmptyProperties() {
9797
Assertions.assertEquals(0, result.size());
9898
}
9999

100-
@Test
101-
public void testEqualsWithSystemProperties() {
102-
PropertiesConfiguration config1 = new PropertiesConfiguration();
103-
PropertiesConfiguration config2 = new PropertiesConfiguration();
104-
105-
config1.asMap();
106-
Assertions.assertEquals(config1, config2);
107-
}
108-
109-
@Test
110-
public void testEqualsWithProperties() {
111-
Properties properties1 = new Properties();
112-
properties1.put("foo", "bar");
113-
114-
Properties properties2 = new Properties();
115-
properties2.put("foo", "bar");
116-
117-
PropertiesConfiguration config1 = new PropertiesConfiguration(properties1);
118-
// modifying properties1 doesn't modify immutable PropertiesConfiguration
119-
properties1.put("bar", "foo");
120-
121-
PropertiesConfiguration config2 = new PropertiesConfiguration(properties2);
122-
123-
config1.asMap();
124-
Assertions.assertEquals(config1, config2);
125-
}
126-
127-
@Test
128-
public void testNotEquals() {
129-
Properties properties = new Properties();
130-
properties.put("foo", "bar");
131-
132-
PropertiesConfiguration config1 = new PropertiesConfiguration();
133-
PropertiesConfiguration config2 = new PropertiesConfiguration(properties);
134-
135-
Assertions.assertNotEquals(config1, config2);
136-
}
137-
138-
@Test
139-
public void testHashCode() {
140-
Properties properties1 = new Properties();
141-
properties1.put("foo", "bar");
142-
143-
Properties properties2 = new Properties();
144-
properties2.put("foo", "bar");
145-
146-
PropertiesConfiguration config1 = new PropertiesConfiguration(properties1);
147-
PropertiesConfiguration config2 = new PropertiesConfiguration(properties2);
148-
PropertiesConfiguration difConfig = new PropertiesConfiguration();
149-
150-
Assertions.assertEquals(config1.hashCode(), config2.hashCode());
151-
Assertions.assertNotEquals(config1.hashCode(), difConfig.hashCode());
152-
}
153-
154100
@Test
155101
public void testEqualsVerifier() {
156102
EqualsVerifier.forClass(PropertiesConfiguration.class).withNonnullFields("configuration").verify();

0 commit comments

Comments
 (0)