-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BZ1301051: Column values are deleted after changing the operator in a Guided Decision Table #656
Merged
+168
−3
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
131 changes: 131 additions & 0 deletions
131
...c/test/java/org/drools/workbench/models/guided/dtable/shared/model/DTCellValue52Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
/* | ||
* Copyright 2016 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.drools.workbench.models.guided.dtable.shared.model; | ||
|
||
import java.lang.reflect.Field; | ||
import java.util.Calendar; | ||
import java.util.Date; | ||
|
||
import org.drools.workbench.models.datamodel.oracle.DataType; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
// These tests check legacy (pre-6.4.CR1) objects that have been de-serialized can be correctly read. | ||
// DTCellValue52.valueString was set to an empty String statically and hence when the object was de-serialized | ||
// it was possible for instances to have both a 'valueString (=="")' and '<another>Value' for types other than | ||
// DataTypes.DataType.TYPE_STRING. For example. valueBoolean=true, valueString="", dataType=BOOLEAN. | ||
public class DTCellValue52Test { | ||
|
||
private DTCellValue52 dcv; | ||
|
||
private Field fieldBoolean; | ||
private Field fieldDate; | ||
private Field fieldNumeric; | ||
private Field fieldString; | ||
private Field fieldDataType; | ||
|
||
private static final Date now = Calendar.getInstance().getTime(); | ||
|
||
@Before | ||
public void setup() throws Exception { | ||
dcv = new DTCellValue52(); | ||
final Class<?> c = dcv.getClass(); | ||
fieldBoolean = c.getDeclaredField( "valueBoolean" ); | ||
fieldDate = c.getDeclaredField( "valueDate" ); | ||
fieldNumeric = c.getDeclaredField( "valueNumeric" ); | ||
fieldString = c.getDeclaredField( "valueString" ); | ||
fieldDataType = c.getDeclaredField( "dataType" ); | ||
fieldBoolean.setAccessible( true ); | ||
fieldDate.setAccessible( true ); | ||
fieldNumeric.setAccessible( true ); | ||
fieldString.setAccessible( true ); | ||
fieldDataType.setAccessible( true ); | ||
} | ||
|
||
@Test | ||
public void testGetBooleanValue() throws Exception { | ||
dcv.setBooleanValue( true ); | ||
fieldDate.set( dcv, | ||
now ); | ||
fieldNumeric.set( dcv, | ||
1L ); | ||
fieldString.set( dcv, | ||
"woot" ); | ||
assertEquals( DataType.DataTypes.BOOLEAN, | ||
dcv.getDataType() ); | ||
assertTrue( dcv.getBooleanValue() ); | ||
assertNull( dcv.getDateValue() ); | ||
assertNull( dcv.getNumericValue() ); | ||
assertNull( dcv.getStringValue() ); | ||
} | ||
|
||
@Test | ||
public void testGetDateValue() throws Exception { | ||
fieldBoolean.set( dcv, | ||
true ); | ||
dcv.setDateValue( now ); | ||
fieldNumeric.set( dcv, | ||
1L ); | ||
fieldString.set( dcv, | ||
"woot" ); | ||
assertEquals( DataType.DataTypes.DATE, | ||
dcv.getDataType() ); | ||
assertNull( dcv.getBooleanValue() ); | ||
assertEquals( now, | ||
dcv.getDateValue() ); | ||
assertNull( dcv.getNumericValue() ); | ||
assertNull( dcv.getStringValue() ); | ||
} | ||
|
||
@Test | ||
public void testGetNumericValue() throws Exception { | ||
fieldBoolean.set( dcv, | ||
true ); | ||
fieldDate.set( dcv, | ||
now ); | ||
dcv.setNumericValue( 1L ); | ||
fieldString.set( dcv, | ||
"woot" ); | ||
assertEquals( DataType.DataTypes.NUMERIC_LONG, | ||
dcv.getDataType() ); | ||
assertNull( dcv.getBooleanValue() ); | ||
assertNull( dcv.getDateValue() ); | ||
assertEquals( 1L, | ||
dcv.getNumericValue() ); | ||
assertNull( dcv.getStringValue() ); | ||
} | ||
|
||
@Test | ||
public void testGetStringValue() throws Exception { | ||
fieldBoolean.set( dcv, | ||
true ); | ||
fieldDate.set( dcv, | ||
now ); | ||
fieldNumeric.set( dcv, | ||
1L ); | ||
dcv.setStringValue( "woot" ); | ||
assertEquals( DataType.DataTypes.STRING, | ||
dcv.getDataType() ); | ||
assertNull( dcv.getBooleanValue() ); | ||
assertNull( dcv.getDateValue() ); | ||
assertNull( dcv.getNumericValue() ); | ||
assertEquals( "woot", | ||
dcv.getStringValue() ); | ||
} | ||
|
||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if it matters, but I usually use the multiline comment for javadocs. This way the editor pick it up. You can read the comment when hovering the mouse over the class for example.