Skip to content

Commit

Permalink
Support java.util.Date in TestGen
Browse files Browse the repository at this point in the history
  • Loading branch information
rsynek authored and ge0ffrey committed Jul 11, 2019
1 parent 4205853 commit 5e8ccd8
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright 2019 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.optaplanner.core.impl.score.director.drools.testgen.fact;

import java.util.Date;

public class TestGenDateValueProvider extends TestGenAbstractValueProvider<Date> {

public TestGenDateValueProvider(Date value) {
super(value);
}

@Override
public String toString() {
return '"' + value.toString() + '"';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;
Expand Down Expand Up @@ -94,6 +95,9 @@ private void setUpField(Field field, Map<Object, TestGenFact> existingInstances)
TestGenMapValueProvider mapValueProvider = new TestGenMapValueProvider(
(Map) value, id, typeArgs, existingInstances);
fields.add(new TestGenFactField(this, fieldName, mapValueProvider));
} else if (field.getType().equals(Date.class)) {
TestGenDateValueProvider dateValueProvider = new TestGenDateValueProvider((Date) value);
fields.add(new TestGenFactField(this, fieldName, dateValueProvider));
} else {
Method parseMethod = getParseMethod(field);
if (parseMethod != null) {
Expand Down

0 comments on commit 5e8ccd8

Please sign in to comment.