#11 - Fixed broken equals(…) in SimplePluginMetadata.

This commit is contained in:
Oliver Gierke
2015-03-05 11:01:20 +01:00
parent 83cf68afb7
commit def9d6cfe2
2 changed files with 53 additions and 2 deletions

View File

@@ -23,7 +23,7 @@ import org.springframework.util.Assert;
/**
* Value object style implementation of {@code PluginMetadata}.
*
* @author Oliver Gierke - gierke@synyx.de
* @author Oliver Gierke
*/
public class SimplePluginMetadata implements PluginMetadata {
@@ -88,7 +88,7 @@ public class SimplePluginMetadata implements PluginMetadata {
PluginMetadata that = (PluginMetadata) obj;
boolean sameName = nullSafeEquals(this.getName(), that.getName());
boolean sameVersion = nullSafeEquals(this.getName(), that.getName());
boolean sameVersion = nullSafeEquals(this.getVersion(), that.getVersion());
return sameName && sameVersion;
}

View File

@@ -0,0 +1,51 @@
/*
* Copyright 2015 the original author or authors.
*
* 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.springframework.plugin.metadata;
import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*;
import org.junit.Test;
/**
* Unit tests for {@link SimplePluginMetadata}.
*
* @author Oliver Gierke
*/
public class SimplePluginMetadataUnitTest {
/**
* @see #11
*/
@Test
public void equalsIsWorkingCorrectly() {
SimplePluginMetadata nameOneOh = new SimplePluginMetadata("Name", "1.0");
SimplePluginMetadata sameNameOneOh = new SimplePluginMetadata("Name", "1.0");
SimplePluginMetadata nameTwoOh = new SimplePluginMetadata("Name", "2.0");
SimplePluginMetadata anotherNameOneOh = new SimplePluginMetadata("AnotherName", "1.0");
assertThat(nameOneOh, is(nameOneOh));
assertThat(nameOneOh, is(sameNameOneOh));
assertThat(sameNameOneOh, is(nameOneOh));
assertThat(nameOneOh, is(not(nameTwoOh)));
assertThat(nameTwoOh, is(not(nameOneOh)));
assertThat(nameOneOh, is(not(anotherNameOneOh)));
assertThat(anotherNameOneOh, is(not(nameOneOh)));
}
}