Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tests for ability to ignore null values
- Loading branch information
spgingras
committed
Jan 30, 2015
1 parent
7db7120
commit 0f22efb
Showing
9 changed files
with
330 additions
and
52 deletions.
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
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
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
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
51 changes: 51 additions & 0 deletions
51
...gration-test/src/main/java/com/arcbees/chosen/integrationtest/client/domain/CarBrand.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,51 @@ | ||
/** | ||
* Copyright 2014 ArcBees Inc. | ||
* | ||
* 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 com.arcbees.chosen.integrationtest.client.domain; | ||
|
||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
import com.google.gwt.text.shared.Renderer; | ||
|
||
public enum CarBrand { | ||
TOYOTA, | ||
HONDA, | ||
MERCEDES, | ||
FORD, | ||
HYUNDAI, | ||
FERRARI, | ||
BMW, | ||
TESLA, | ||
AUDI, | ||
BENTLEY, | ||
CADILLAC, | ||
CHEVROLET, | ||
CHRYSLER, | ||
DODGE, | ||
MITSUBISHI, | ||
JAGUAR, | ||
JEEP; | ||
|
||
public static Set<String> getAllNames(Renderer<CarBrand> renderer) { | ||
Set<String> brandNames = new HashSet<String>(); | ||
for (CarBrand carBrand : CarBrand.values()) { | ||
brandNames.add(renderer.render(carBrand)); | ||
} | ||
|
||
return brandNames; | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
...-test/src/main/java/com/arcbees/chosen/integrationtest/client/testcases/ChooseOption.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,49 @@ | ||
/** | ||
* Copyright 2014 ArcBees Inc. | ||
* | ||
* 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 com.arcbees.chosen.integrationtest.client.testcases; | ||
|
||
import java.util.EnumSet; | ||
|
||
import com.arcbees.chosen.client.gwt.ChosenValueListBox; | ||
import com.arcbees.chosen.integrationtest.client.TestCase; | ||
import com.arcbees.chosen.integrationtest.client.domain.CarBrand; | ||
import com.google.gwt.text.shared.AbstractRenderer; | ||
import com.google.gwt.user.client.ui.RootPanel; | ||
|
||
public class ChooseOption extends TestCase { | ||
public static final AbstractRenderer<CarBrand> RENDERER = new AbstractRenderer<CarBrand>() { | ||
@Override | ||
public String render(CarBrand object) { | ||
if (object == null) { | ||
return ""; | ||
} | ||
return object.name(); | ||
} | ||
}; | ||
|
||
@Override | ||
public void run() { | ||
RootPanel rootPanel = RootPanel.get(); | ||
|
||
ChosenValueListBox<CarBrand> listBox = new ChosenValueListBox<CarBrand>(RENDERER); | ||
|
||
listBox.setAcceptableValues(EnumSet.allOf(CarBrand.class)); | ||
listBox.setValue(CarBrand.AUDI); | ||
|
||
rootPanel.add(listBox); | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
...st/src/main/java/com/arcbees/chosen/integrationtest/client/testcases/HideEmptyValues.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,57 @@ | ||
/** | ||
* Copyright 2014 ArcBees Inc. | ||
* | ||
* 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 com.arcbees.chosen.integrationtest.client.testcases; | ||
|
||
import java.util.List; | ||
|
||
import com.arcbees.chosen.client.gwt.ChosenValueListBox; | ||
import com.arcbees.chosen.integrationtest.client.TestCase; | ||
import com.arcbees.chosen.integrationtest.client.domain.CarBrand; | ||
import com.google.common.collect.Lists; | ||
import com.google.gwt.text.shared.AbstractRenderer; | ||
import com.google.gwt.text.shared.Renderer; | ||
import com.google.gwt.user.client.ui.RootPanel; | ||
|
||
/** | ||
* This test makes sure that when null values are rendered as empty string (""), | ||
* then the empty string will not be displayed in the dropdown options. | ||
*/ | ||
|
||
public class HideEmptyValues extends TestCase { | ||
public static final Renderer<CarBrand> RENDERER = new AbstractRenderer<CarBrand>() { | ||
@Override | ||
public String render(CarBrand object) { | ||
if (object == null) { | ||
return ""; | ||
} | ||
return object.name(); | ||
} | ||
}; | ||
|
||
@Override | ||
public void run() { | ||
ChosenValueListBox<CarBrand> listBox = new ChosenValueListBox<CarBrand>(RENDERER); | ||
|
||
List<CarBrand> carBrands = Lists.newArrayList(CarBrand.values()); | ||
carBrands.add(0, null); | ||
listBox.setAcceptableValues(carBrands); | ||
|
||
listBox.setValue(null); | ||
|
||
RootPanel.get().add(listBox); | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
...src/main/java/com/arcbees/chosen/integrationtest/client/testcases/ShowNonEmptyValues.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,57 @@ | ||
/** | ||
* Copyright 2014 ArcBees Inc. | ||
* | ||
* 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 com.arcbees.chosen.integrationtest.client.testcases; | ||
|
||
import java.util.List; | ||
|
||
import com.arcbees.chosen.client.gwt.ChosenValueListBox; | ||
import com.arcbees.chosen.integrationtest.client.TestCase; | ||
import com.arcbees.chosen.integrationtest.client.domain.CarBrand; | ||
import com.google.common.collect.Lists; | ||
import com.google.gwt.text.shared.AbstractRenderer; | ||
import com.google.gwt.text.shared.Renderer; | ||
import com.google.gwt.user.client.ui.RootPanel; | ||
|
||
/** | ||
* This test makes sure that when null values are rendered as a non-empty string, | ||
* then that exact non-empty string will be displayed in the dropdown options. | ||
*/ | ||
|
||
public class ShowNonEmptyValues extends TestCase { | ||
public static final Renderer<CarBrand> RENDERER = new AbstractRenderer<CarBrand>() { | ||
@Override | ||
public String render(CarBrand object) { | ||
if (object == null) { | ||
return "Placeholder for null"; | ||
} | ||
return object.name(); | ||
} | ||
}; | ||
|
||
@Override | ||
public void run() { | ||
ChosenValueListBox<CarBrand> listBox = new ChosenValueListBox<CarBrand>(RENDERER); | ||
|
||
List<CarBrand> carBrands = Lists.newArrayList(CarBrand.values()); | ||
carBrands.add(0, null); | ||
listBox.setAcceptableValues(carBrands); | ||
|
||
listBox.setValue(null); | ||
|
||
RootPanel.get().add(listBox); | ||
} | ||
} |
Oops, something went wrong.