ConfigurationDO.java

1
package org.europa.together.domain;
2
3
import java.io.Serializable;
4
import java.util.Objects;
5
import jakarta.persistence.Column;
6
import jakarta.persistence.Entity;
7
import jakarta.persistence.Id;
8
import jakarta.persistence.Index;
9
import jakarta.persistence.PrePersist;
10
import jakarta.persistence.Table;
11
import jakarta.persistence.UniqueConstraint;
12
import org.europa.together.application.LogbackLogger;
13
import org.europa.together.business.Logger;
14
import org.europa.together.utils.StringUtils;
15
16
/**
17
 * Application wide configuration with key=value entries. For an easier
18
 * maintenance are entries with module-name, module-version and a deprecated
19
 * marker extended.
20
 */
21
@Entity
22
@Table(name = "APP_CONFIG",
23
        //CHECKSTYLE:OFF
24
        indexes = {
25
            @Index(columnList = "CONF_KEY", name = "configuration_key"),
26
            @Index(columnList = "MODUL_NAME", name = "modul_name"),
27
            @Index(columnList = "CONF_SET", name = "configuration_set")
28
        },
29
        //CHECKSTYLE:ON
30
        uniqueConstraints = {
31
            @UniqueConstraint(columnNames
32
                    = {"MODUL_NAME", "SERVICE_VERSION", "CONF_KEY"})
33
        }
34
)
35
public class ConfigurationDO implements Serializable {
36
37
    private static final long serialVersionUID = 102L;
38
    private static final Logger LOGGER = new LogbackLogger(ConfigurationDO.class);
39
40
    /**
41
     * The name of the used database table for this domain object.
42
     */
43
    public static final String TABLE_NAME = "APP_CONFIG";
44
45
    @Id //validate uuid
46
    @Column(name = "IDX")
47
    private String uuid;
48
49
    @Column(name = "CONF_KEY", nullable = false)
50
    private String key;
51
52
    @Column(name = "CONF_VALUE")
53
    private String value;
54
55
    @Column(name = "DEFAULT_VALUE", nullable = false)
56
    private String defaultValue;
57
58
    @Column(name = "MODUL_NAME", nullable = false)
59
    private String modulName;
60
61
    @Column(name = "SERVICE_VERSION", nullable = false)
62
    private String version;
63
64
    @Column(name = "CONF_SET", nullable = false)
65
    private String configurationSet;
66
67
    @Column(name = "DEPRECATED", nullable = false)
68
    private boolean deprecated;
69
70
    @Column(name = "MANDATORY", nullable = false)
71
    private boolean mandatory;
72
73
    @Column(name = "COMMENT")
74
    private String comment;
75
76
    /**
77
     * Constructor.
78
     */
79
    public ConfigurationDO() {
80
        //PreSet
81
        this.uuid = StringUtils.generateUUID();
82
    }
83
84
    /**
85
     * Constructor.
86
     *
87
     * @param key as String
88
     * @param value as String
89
     * @param modulName as String
90
     * @param version as String
91
     */
92
    public ConfigurationDO(final String key, final String value, final String modulName,
93
            final String version) {
94
        //PreSet
95
        this.uuid = StringUtils.generateUUID();
96
        //mandatory
97
        this.modulName = modulName;
98
        this.version = version;
99
        this.key = key;
100
        this.value = value;
101
        //optional
102
        this.configurationSet = "default";
103
        this.defaultValue = "NIL";
104
        this.deprecated = false;
105
        this.mandatory = false;
106
        this.comment = "";
107
    }
108
109
    /**
110
     * Actions who have to performed before objects get persisted. e.g. cerate
111
     * default entries in the database.
112
     */
113
    @PrePersist
114
    public void prePersist() {
115
        this.configurationSet = "default";
116
        this.defaultValue = "NIL";
117
        this.deprecated = false;
118
        this.mandatory = false;
119
        LOGGER.log("@PrePersist [ConfigurationDO]", LogLevel.INFO);
120
    }
121
122
    //<editor-fold defaultstate="collapsed" desc="Getter / Setter">
123
    /**
124
     * Show if entry is deprecated.
125
     *
126
     * @return true if is deprecated
127
     */
128
    public boolean isDeprecated() {
129 2 1. isDeprecated : replaced boolean return with false for org/europa/together/domain/ConfigurationDO::isDeprecated → SURVIVED
2. isDeprecated : replaced boolean return with true for org/europa/together/domain/ConfigurationDO::isDeprecated → KILLED
        return deprecated;
130
    }
131
132
    /**
133
     * Mark if an configuration entry is mandatory.
134
     *
135
     * @return true if is mandatory
136
     */
137
    public boolean isMandatory() {
138 2 1. isMandatory : replaced boolean return with false for org/europa/together/domain/ConfigurationDO::isMandatory → KILLED
2. isMandatory : replaced boolean return with true for org/europa/together/domain/ConfigurationDO::isMandatory → KILLED
        return mandatory;
139
    }
140
141
    /**
142
     * Set the comment.
143
     *
144
     * @param comment as String
145
     */
146
    public void setComment(final String comment) {
147
        this.comment = comment;
148
    }
149
150
    /**
151
     * Set the configuration set.
152
     *
153
     * @param configurationSet as String
154
     */
155
    public void setConfigurationSet(final String configurationSet) {
156
        this.configurationSet = configurationSet;
157
    }
158
159
    /**
160
     * Set the default value.
161
     *
162
     * @param defaultValue as String
163
     */
164
    public void setDefaultValue(final String defaultValue) {
165
        this.defaultValue = defaultValue;
166
    }
167
168
    /**
169
     * Set if a entry is deprecated.
170
     *
171
     * @param deprecated as boolean
172
     */
173
    public void setDeprecated(final boolean deprecated) {
174
        this.deprecated = deprecated;
175
    }
176
177
    /**
178
     * Set if a entry is mandatory.
179
     *
180
     * @param mandatory as boolean
181
     */
182
    public void setMandatory(final boolean mandatory) {
183
        this.mandatory = mandatory;
184
    }
185
186
    /**
187
     * Set key.
188
     *
189
     * @param key as String
190
     */
191
    public void setKey(final String key) {
192
        this.key = key;
193
    }
194
195
    /**
196
     * Set module´name.
197
     *
198
     * @param modulName as String
199
     */
200
    public void setModulName(final String modulName) {
201
        this.modulName = modulName;
202
    }
203
204
    /**
205
     * Set the UUID.
206
     *
207
     * @param uuid as String
208
     */
209
    public void setUuid(final String uuid) {
210
        this.uuid = uuid;
211
    }
212
213
    /**
214
     * Set value.
215
     *
216
     * @param value as String
217
     */
218
    public void setValue(final String value) {
219
        this.value = value;
220
    }
221
222
    /**
223
     * Set version of module.
224
     *
225
     * @param version as String
226
     */
227
    public void setVersion(final String version) {
228
        this.version = version;
229
    }
230
231
    /**
232
     * Get the comment.
233
     *
234
     * @return comment as String
235
     */
236
    public String getComment() {
237 1 1. getComment : replaced return value with "" for org/europa/together/domain/ConfigurationDO::getComment → KILLED
        return comment;
238
    }
239
240
    /**
241
     * Get the configuration set.
242
     *
243
     * @return ConfigurationSet as String.
244
     */
245
    public String getConfigurationSet() {
246 1 1. getConfigurationSet : replaced return value with "" for org/europa/together/domain/ConfigurationDO::getConfigurationSet → KILLED
        return configurationSet;
247
    }
248
249
    /**
250
     * Get the default value.
251
     *
252
     * @return dafaultValue as String
253
     */
254
    public String getDefaultValue() {
255 1 1. getDefaultValue : replaced return value with "" for org/europa/together/domain/ConfigurationDO::getDefaultValue → KILLED
        return defaultValue;
256
    }
257
258
    /**
259
     * Get the key.
260
     *
261
     * @return key as String
262
     */
263
    public String getKey() {
264 1 1. getKey : replaced return value with "" for org/europa/together/domain/ConfigurationDO::getKey → KILLED
        return key;
265
    }
266
267
    /**
268
     * Get Modulename.
269
     *
270
     * @return modulename as String
271
     */
272
    public String getModulName() {
273 1 1. getModulName : replaced return value with "" for org/europa/together/domain/ConfigurationDO::getModulName → KILLED
        return modulName;
274
    }
275
276
    /**
277
     * Get the UUID.
278
     *
279
     * @return UUID as String
280
     */
281
    public String getUuid() {
282 1 1. getUuid : replaced return value with "" for org/europa/together/domain/ConfigurationDO::getUuid → KILLED
        return uuid;
283
    }
284
285
    /**
286
     * Get value.
287
     *
288
     * @return value as String
289
     */
290
    public String getValue() {
291 1 1. getValue : replaced return value with "" for org/europa/together/domain/ConfigurationDO::getValue → KILLED
        return value;
292
    }
293
294
    /**
295
     * Get module version.
296
     *
297
     * @return moduleversion as String
298
     */
299
    public String getVersion() {
300 1 1. getVersion : replaced return value with "" for org/europa/together/domain/ConfigurationDO::getVersion → KILLED
        return version;
301
    }
302
    //</editor-fold>
303
304
    @Override
305
    public boolean equals(final Object obj) {
306
307
        boolean success = false;
308 2 1. equals : negated conditional → KILLED
2. equals : negated conditional → KILLED
        if (obj != null && obj instanceof ConfigurationDO) {
309
310 1 1. equals : negated conditional → KILLED
            if (this == obj) {
311
                success = true;
312
            } else {
313
314
                final ConfigurationDO other = (ConfigurationDO) obj;
315 1 1. equals : negated conditional → KILLED
                if (Objects.equals(this.key, other.key)
316 1 1. equals : negated conditional → KILLED
                        && Objects.equals(this.modulName, other.modulName)
317 1 1. equals : negated conditional → KILLED
                        && Objects.equals(this.version, other.version)) {
318
                    success = true;
319
                }
320
            }
321
        }
322 2 1. equals : replaced boolean return with false for org/europa/together/domain/ConfigurationDO::equals → KILLED
2. equals : replaced boolean return with true for org/europa/together/domain/ConfigurationDO::equals → KILLED
        return success;
323
    }
324
325
    @Override
326
    public int hashCode() {
327
        int hash = Objects.hashCode(this.key);
328 1 1. hashCode : Replaced integer addition with subtraction → SURVIVED
        hash += Objects.hashCode(this.modulName);
329 1 1. hashCode : Replaced integer addition with subtraction → SURVIVED
        hash += Objects.hashCode(this.version);
330 1 1. hashCode : replaced int return with 0 for org/europa/together/domain/ConfigurationDO::hashCode → KILLED
        return hash;
331
    }
332
333
    @Override
334
    public String toString() {
335 1 1. toString : replaced return value with "" for org/europa/together/domain/ConfigurationDO::toString → KILLED
        return "ConfigurationDO{" + "uuid=" + uuid
336
                + ", key=" + key
337
                + ", value=" + value
338
                + ", defaultValue=" + defaultValue
339
                + ", modulName=" + modulName
340
                + ", configurationSet=" + configurationSet
341
                + ", version=" + version
342
                + ", deprecated=" + deprecated
343
                + ", mandatory=" + mandatory
344
                + ", comment=" + comment + '}';
345
    }
346
}

Mutations

129

1.1
Location : isDeprecated
Killed by : none
replaced boolean return with false for org/europa/together/domain/ConfigurationDO::isDeprecated → SURVIVED
Covering tests

2.2
Location : isDeprecated
Killed by : org.europa.together.domain.ConfigurationDOTest.[engine:junit-jupiter]/[class:org.europa.together.domain.ConfigurationDOTest]/[method:prePersist()]
replaced boolean return with true for org/europa/together/domain/ConfigurationDO::isDeprecated → KILLED

138

1.1
Location : isMandatory
Killed by : org.europa.together.service.ConfigurationServiceTest.[engine:junit-jupiter]/[class:org.europa.together.service.ConfigurationServiceTest]/[method:filterMandatoryFieldsOfConfigSet()]
replaced boolean return with false for org/europa/together/domain/ConfigurationDO::isMandatory → KILLED

2.2
Location : isMandatory
Killed by : org.europa.together.domain.ConfigurationDOTest.[engine:junit-jupiter]/[class:org.europa.together.domain.ConfigurationDOTest]/[method:prePersist()]
replaced boolean return with true for org/europa/together/domain/ConfigurationDO::isMandatory → KILLED

237

1.1
Location : getComment
Killed by : org.europa.together.domain.ConfigurationDOTest.[engine:junit-jupiter]/[class:org.europa.together.domain.ConfigurationDOTest]/[method:hasValidGetter()]
replaced return value with "" for org/europa/together/domain/ConfigurationDO::getComment → KILLED

246

1.1
Location : getConfigurationSet
Killed by : org.europa.together.domain.ConfigurationDOTest.[engine:junit-jupiter]/[class:org.europa.together.domain.ConfigurationDOTest]/[method:prePersist()]
replaced return value with "" for org/europa/together/domain/ConfigurationDO::getConfigurationSet → KILLED

255

1.1
Location : getDefaultValue
Killed by : org.europa.together.domain.ConfigurationDOTest.[engine:junit-jupiter]/[class:org.europa.together.domain.ConfigurationDOTest]/[method:prePersist()]
replaced return value with "" for org/europa/together/domain/ConfigurationDO::getDefaultValue → KILLED

264

1.1
Location : getKey
Killed by : org.europa.together.domain.ConfigurationDOTest.[engine:junit-jupiter]/[class:org.europa.together.domain.ConfigurationDOTest]/[method:hasValidGetter()]
replaced return value with "" for org/europa/together/domain/ConfigurationDO::getKey → KILLED

273

1.1
Location : getModulName
Killed by : org.europa.together.domain.ConfigurationDOTest.[engine:junit-jupiter]/[class:org.europa.together.domain.ConfigurationDOTest]/[method:hasValidGetter()]
replaced return value with "" for org/europa/together/domain/ConfigurationDO::getModulName → KILLED

282

1.1
Location : getUuid
Killed by : org.europa.together.application.ConfigurationHbmDAOTest.[engine:junit-jupiter]/[class:org.europa.together.application.ConfigurationHbmDAOTest]/[method:delete()]
replaced return value with "" for org/europa/together/domain/ConfigurationDO::getUuid → KILLED

291

1.1
Location : getValue
Killed by : org.europa.together.domain.ConfigurationDOTest.[engine:junit-jupiter]/[class:org.europa.together.domain.ConfigurationDOTest]/[method:hasValidGetter()]
replaced return value with "" for org/europa/together/domain/ConfigurationDO::getValue → KILLED

300

1.1
Location : getVersion
Killed by : org.europa.together.domain.ConfigurationDOTest.[engine:junit-jupiter]/[class:org.europa.together.domain.ConfigurationDOTest]/[method:hasValidGetter()]
replaced return value with "" for org/europa/together/domain/ConfigurationDO::getVersion → KILLED

308

1.1
Location : equals
Killed by : org.europa.together.domain.ConfigurationDOTest.[engine:junit-jupiter]/[class:org.europa.together.domain.ConfigurationDOTest]/[method:isEqual()]
negated conditional → KILLED

2.2
Location : equals
Killed by : org.europa.together.domain.ConfigurationDOTest.[engine:junit-jupiter]/[class:org.europa.together.domain.ConfigurationDOTest]/[method:isEqual()]
negated conditional → KILLED

310

1.1
Location : equals
Killed by : org.europa.together.domain.ConfigurationDOTest.[engine:junit-jupiter]/[class:org.europa.together.domain.ConfigurationDOTest]/[method:isNotEqual()]
negated conditional → KILLED

315

1.1
Location : equals
Killed by : org.europa.together.domain.ConfigurationDOTest.[engine:junit-jupiter]/[class:org.europa.together.domain.ConfigurationDOTest]/[method:isEqual()]
negated conditional → KILLED

316

1.1
Location : equals
Killed by : org.europa.together.domain.ConfigurationDOTest.[engine:junit-jupiter]/[class:org.europa.together.domain.ConfigurationDOTest]/[method:isEqual()]
negated conditional → KILLED

317

1.1
Location : equals
Killed by : org.europa.together.domain.ConfigurationDOTest.[engine:junit-jupiter]/[class:org.europa.together.domain.ConfigurationDOTest]/[method:isEqual()]
negated conditional → KILLED

322

1.1
Location : equals
Killed by : org.europa.together.domain.ConfigurationDOTest.[engine:junit-jupiter]/[class:org.europa.together.domain.ConfigurationDOTest]/[method:isEqual()]
replaced boolean return with false for org/europa/together/domain/ConfigurationDO::equals → KILLED

2.2
Location : equals
Killed by : org.europa.together.domain.ConfigurationDOTest.[engine:junit-jupiter]/[class:org.europa.together.domain.ConfigurationDOTest]/[method:isNotEqual()]
replaced boolean return with true for org/europa/together/domain/ConfigurationDO::equals → KILLED

328

1.1
Location : hashCode
Killed by : none
Replaced integer addition with subtraction → SURVIVED
Covering tests

329

1.1
Location : hashCode
Killed by : none
Replaced integer addition with subtraction → SURVIVED
Covering tests

330

1.1
Location : hashCode
Killed by : org.europa.together.domain.ConfigurationDOTest.[engine:junit-jupiter]/[class:org.europa.together.domain.ConfigurationDOTest]/[method:domainObject()]
replaced int return with 0 for org/europa/together/domain/ConfigurationDO::hashCode → KILLED

335

1.1
Location : toString
Killed by : org.europa.together.domain.ConfigurationDOTest.[engine:junit-jupiter]/[class:org.europa.together.domain.ConfigurationDOTest]/[method:domainObject()]
replaced return value with "" for org/europa/together/domain/ConfigurationDO::toString → KILLED

Active mutators

Tests examined


Report generated by PIT 1.22.0