Skip to content

Commit

Permalink
Merge pull request #519 from commercetools/add_toString_to_LocalizedS…
Browse files Browse the repository at this point in the history
…tring

Override toString method.
  • Loading branch information
salander85 authored Nov 13, 2023
2 parents edffa6f + 3f1808b commit 614389d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

/**
* LocalizedString implementation
Expand Down Expand Up @@ -57,4 +59,9 @@ public int hashCode() {
return new HashCodeBuilder(17, 37).append(values).toHashCode();
}

@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).append("values", values).build();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import com.commercetools.api.models.common.LocalizedString;
import com.commercetools.api.models.common.LocalizedStringEntry;

import io.vrap.rmf.base.client.ModelBase;
import io.vrap.rmf.base.client.utils.json.JsonUtils;

import org.apache.commons.lang3.StringUtils;
Expand Down Expand Up @@ -186,7 +185,7 @@ public void returnPresentLocales() throws Exception {

@Test
public void implementToString() throws Exception {
assertThat(((ModelBase) LOCALIZED_STRING).reflectionString())
assertThat(LOCALIZED_STRING.toString())
.isEqualTo(format("LocalizedStringImpl[values={de=%s, en=%s}]", DEFAULT_STRING_1, DEFAULT_STRING_2));
}

Expand Down

0 comments on commit 614389d

Please sign in to comment.