Skip to content

Commit c19d7a0

Browse files
committed
Remove powermock from metadata-utils
1 parent 8494c67 commit c19d7a0

4 files changed

Lines changed: 98 additions & 178 deletions

File tree

core/utils/metadata-utils/pom.xml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -63,18 +63,6 @@
6363
<groupId>gov.nsa.datawave.core</groupId>
6464
<artifactId>type-utils</artifactId>
6565
</dependency>
66-
<dependency>
67-
<groupId>org.easymock</groupId>
68-
<artifactId>easymock</artifactId>
69-
</dependency>
70-
<dependency>
71-
<groupId>org.powermock</groupId>
72-
<artifactId>powermock-api-easymock</artifactId>
73-
</dependency>
74-
<dependency>
75-
<groupId>org.powermock</groupId>
76-
<artifactId>powermock-module-junit4</artifactId>
77-
</dependency>
7866
<dependency>
7967
<groupId>commons-collections</groupId>
8068
<artifactId>commons-collections</artifactId>

core/utils/metadata-utils/src/main/java/datawave/query/model/ModelKeyParser.java

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import java.util.Arrays;
66
import java.util.List;
77
import java.util.Set;
8+
import java.util.function.LongSupplier;
89
import java.util.stream.Collectors;
910

1011
import org.apache.accumulo.core.data.Key;
@@ -49,6 +50,9 @@ public class ModelKeyParser {
4950
public static final String NULL_BYTE = "\0";
5051
public static final Value NULL_VALUE = new Value(new byte[0]);
5152

53+
// Package-private to allow test override
54+
static LongSupplier clock = System::currentTimeMillis;
55+
5256
@Deprecated
5357
public static final String INDEX_ONLY = "index_only";
5458

@@ -133,7 +137,7 @@ public static Key createKey(FieldMapping mapping, String modelName) {
133137
modelName + dataType, // ColFam
134138
outName + NULL_BYTE + mapping.getDirection().getValue(), // ColQual
135139
cv, // Visibility
136-
System.currentTimeMillis() // Timestamp
140+
clock.getAsLong() // Timestamp
137141
);
138142
} else {
139143
String fieldName = mapping.getModelFieldName() == null ? ModelKeyParser.MODEL : mapping.getModelFieldName();
@@ -142,7 +146,7 @@ public static Key createKey(FieldMapping mapping, String modelName) {
142146
modelName + dataType, // ColFam
143147
attr, // ColQ
144148
cv, // Visibility
145-
System.currentTimeMillis() // Timestamp
149+
clock.getAsLong() // Timestamp
146150
);
147151
}
148152
}
@@ -189,17 +193,16 @@ public static Mutation createMutation(FieldMapping mapping, String modelName) {
189193
if (Direction.REVERSE.equals(mapping.getDirection())) {
190194
// Reverse mappings should not have indexOnly designators. If they do, scrub it off.
191195
m = new Mutation(mapping.getFieldName());
192-
m.put(modelName + dataType, mapping.getModelFieldName() + NULL_BYTE + mapping.getDirection().getValue(), cv, System.currentTimeMillis(),
193-
NULL_VALUE);
196+
m.put(modelName + dataType, mapping.getModelFieldName() + NULL_BYTE + mapping.getDirection().getValue(), cv, clock.getAsLong(), NULL_VALUE);
194197
} else {
195198
m = new Mutation(mapping.getModelFieldName());
196-
m.put(modelName + dataType, mapping.getFieldName() + NULL_BYTE + mapping.getDirection().getValue(), cv, System.currentTimeMillis(), NULL_VALUE);
199+
m.put(modelName + dataType, mapping.getFieldName() + NULL_BYTE + mapping.getDirection().getValue(), cv, clock.getAsLong(), NULL_VALUE);
197200
}
198201
} else {
199202
String fieldName = mapping.getModelFieldName() == null ? ModelKeyParser.MODEL : mapping.getModelFieldName();
200203
String[] attr = getAttrCqValue(mapping.getAttributes());
201204
m = new Mutation(fieldName);
202-
m.put(modelName + dataType, attr[0], cv, System.currentTimeMillis(), new Value(attr[1]));
205+
m.put(modelName + dataType, attr[0], cv, clock.getAsLong(), new Value(attr[1]));
203206
}
204207
return m;
205208
}
@@ -212,24 +215,24 @@ public static Mutation createDeleteMutation(FieldMapping mapping, String modelNa
212215
if (mapping.isFieldMapping()) {
213216
if (Direction.REVERSE.equals(mapping.getDirection())) {
214217
m = new Mutation(mapping.getFieldName());
215-
m.putDelete(modelName + dataType, mapping.getModelFieldName() + NULL_BYTE + mapping.getDirection().getValue(), cv, System.currentTimeMillis());
218+
m.putDelete(modelName + dataType, mapping.getModelFieldName() + NULL_BYTE + mapping.getDirection().getValue(), cv, clock.getAsLong());
216219
} else {
217220
m = new Mutation(mapping.getModelFieldName());
218-
m.putDelete(modelName + dataType, mapping.getFieldName() + NULL_BYTE + mapping.getDirection().getValue(), cv, System.currentTimeMillis());
221+
m.putDelete(modelName + dataType, mapping.getFieldName() + NULL_BYTE + mapping.getDirection().getValue(), cv, clock.getAsLong());
219222
m.putDelete(modelName + dataType, mapping.getFieldName() + NULL_BYTE + INDEX_ONLY + NULL_BYTE + mapping.getDirection().getValue(), cv,
220-
System.currentTimeMillis());
223+
clock.getAsLong());
221224
}
222225
} else {
223226
String fieldName = mapping.getModelFieldName() == null ? ModelKeyParser.MODEL : mapping.getModelFieldName();
224227
m = new Mutation(fieldName);
225-
m.putDelete(modelName + dataType, ATTRIBUTES, cv, System.currentTimeMillis());
228+
m.putDelete(modelName + dataType, ATTRIBUTES, cv, clock.getAsLong());
226229
if (mapping.getAttributes().isEmpty()) {
227-
m.putDelete(modelName + dataType, "", cv, System.currentTimeMillis());
230+
m.putDelete(modelName + dataType, "", cv, clock.getAsLong());
228231
} else {
229232
for (String attr : mapping.getAttributes()) {
230-
m.putDelete(modelName + dataType, attr, cv, System.currentTimeMillis());
233+
m.putDelete(modelName + dataType, attr, cv, clock.getAsLong());
231234
if (attr.indexOf('=') >= 0) {
232-
m.putDelete(modelName + dataType, attr.substring(0, attr.indexOf('=')), cv, System.currentTimeMillis());
235+
m.putDelete(modelName + dataType, attr.substring(0, attr.indexOf('=')), cv, clock.getAsLong());
233236
}
234237
}
235238
}

0 commit comments

Comments
 (0)