Skip to content

Commit

Permalink
Merge pull request #2189 from teleivo/TRUNK-5162
Browse files Browse the repository at this point in the history
TRUNK-5162 Few PropertyEditor getAsText return null if value is null
  • Loading branch information
teleivo committed May 6, 2017
2 parents af1722d + fbdce63 commit 455e452
Show file tree
Hide file tree
Showing 8 changed files with 4 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class ConceptAttributeTypeEditor extends PropertyEditorSupport {
@Override
public String getAsText() {
ConceptAttributeType conceptAttributeType = (ConceptAttributeType) getValue();
return conceptAttributeType == null ? null : conceptAttributeType.getId().toString();
return conceptAttributeType == null ? "" : conceptAttributeType.getId().toString();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class LocationAttributeTypeEditor extends PropertyEditorSupport {
@Override
public String getAsText() {
LocationAttributeType lat = (LocationAttributeType) getValue();
return lat == null ? null : lat.getId().toString();
return lat == null ? "" : lat.getId().toString();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void setAsText(String text) throws IllegalArgumentException {
@Override
public String getAsText() {
Location t = (Location) getValue();
return t == null ? null : t.getLocationId().toString();
return t == null ? "" : t.getLocationId().toString();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void setAsText(String text) throws IllegalArgumentException {
@Override
public String getAsText() {
LocationTag t = (LocationTag) getValue();
return t == null ? null : t.getLocationTagId().toString();
return t == null ? "" : t.getLocationTagId().toString();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,7 @@
*/
package org.openmrs.propertyeditor;

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.junit.Assert.assertThat;

import org.junit.Before;
import org.junit.Test;
import org.openmrs.ConceptAttributeType;
import org.openmrs.api.ConceptService;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -42,11 +37,4 @@ protected ConceptAttributeTypeEditor getNewEditor() {
protected ConceptAttributeType getExistingObject() {
return conceptService.getConceptAttributeType(EXISTING_ID);
}

@Override
@Test
public void shouldReturnEmptyStringIfValueIsNull() {

assertThat(editor.getAsText(), is(nullValue()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,7 @@
*/
package org.openmrs.propertyeditor;

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.junit.Assert.assertThat;

import org.junit.Before;
import org.junit.Test;
import org.openmrs.LocationAttributeType;
import org.openmrs.api.LocationService;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -40,11 +35,4 @@ protected LocationAttributeTypeEditor getNewEditor() {
protected LocationAttributeType getExistingObject() {
return locationService.getLocationAttributeType(EXISTING_ID);
}

@Override
@Test
public void shouldReturnEmptyStringIfValueIsNull() {

assertThat(editor.getAsText(), is(nullValue()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@
*/
package org.openmrs.propertyeditor;

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.junit.Assert.assertThat;

import org.junit.Test;
import org.openmrs.Location;
import org.openmrs.api.LocationService;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -34,11 +29,4 @@ protected LocationEditor getNewEditor() {
protected Location getExistingObject() {
return locationService.getLocation(EXISTING_ID);
}

@Override
@Test
public void shouldReturnEmptyStringIfValueIsNull() {

assertThat(editor.getAsText(), is(nullValue()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,7 @@
*/
package org.openmrs.propertyeditor;

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.junit.Assert.assertThat;

import org.junit.Before;
import org.junit.Test;
import org.openmrs.LocationTag;
import org.openmrs.api.LocationService;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -42,11 +37,4 @@ protected LocationTagEditor getNewEditor() {
protected LocationTag getExistingObject() {
return locationService.getLocationTag(EXISTING_ID);
}

@Override
@Test
public void shouldReturnEmptyStringIfValueIsNull() {

assertThat(editor.getAsText(), is(nullValue()));
}
}

0 comments on commit 455e452

Please sign in to comment.