-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Alex Eng
committed
Apr 24, 2017
1 parent
b13f498
commit fe63594
Showing
20 changed files
with
370 additions
and
51 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
93 changes: 93 additions & 0 deletions
93
api/zanata-common-api/src/main/java/org/zanata/rest/dto/LocaleMember.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,93 @@ | ||
/* | ||
* Copyright 2014, Red Hat, Inc. and individual contributors | ||
* as indicated by the @author tags. See the copyright.txt file in the | ||
* distribution for a full listing of individual contributors. | ||
* | ||
* This is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU Lesser General Public License as | ||
* published by the Free Software Foundation; either version 2.1 of | ||
* the License, or (at your option) any later version. | ||
* | ||
* This software is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this software; if not, write to the Free | ||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. | ||
*/ | ||
|
||
package org.zanata.rest.dto; | ||
|
||
import org.codehaus.jackson.annotate.JsonProperty; | ||
import org.codehaus.jackson.map.annotate.JsonSerialize; | ||
import java.io.Serializable; | ||
|
||
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL) | ||
public class LocaleMember implements Serializable { | ||
|
||
private final String username; | ||
private final Boolean isCoordinator; | ||
private final Boolean isReviewer; | ||
private final Boolean isTranslator; | ||
|
||
|
||
public LocaleMember(String username, Boolean isCoordinator, | ||
Boolean isReviewer, Boolean isTranslator) { | ||
this.username = username; | ||
this.isCoordinator = isCoordinator; | ||
this.isReviewer = isReviewer; | ||
this.isTranslator = isTranslator; | ||
} | ||
|
||
@JsonProperty("username") | ||
public String getUsername() { | ||
return username; | ||
} | ||
|
||
@JsonProperty("isCoordinator") | ||
public Boolean getCoordinator() { | ||
return isCoordinator; | ||
} | ||
|
||
@JsonProperty("isReviewer") | ||
public Boolean getReviewer() { | ||
return isReviewer; | ||
} | ||
|
||
@JsonProperty("isTranslator") | ||
public Boolean getTranslator() { | ||
return isTranslator; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
|
||
LocaleMember that = (LocaleMember) o; | ||
|
||
if (username != null ? !username.equals(that.username) : | ||
that.username != null) return false; | ||
if (isCoordinator != null ? !isCoordinator.equals(that.isCoordinator) : | ||
that.isCoordinator != null) return false; | ||
if (isReviewer != null ? !isReviewer.equals(that.isReviewer) : | ||
that.isReviewer != null) return false; | ||
return isTranslator != null ? isTranslator.equals(that.isTranslator) : | ||
that.isTranslator == null; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
int result = username != null ? username.hashCode() : 0; | ||
result = | ||
31 * result + | ||
(isCoordinator != null ? isCoordinator.hashCode() : 0); | ||
result = 31 * result + (isReviewer != null ? isReviewer.hashCode() : 0); | ||
result = 31 * result + | ||
(isTranslator != null ? isTranslator.hashCode() : 0); | ||
return result; | ||
} | ||
} |
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
37 changes: 37 additions & 0 deletions
37
api/zanata-common-api/src/test/java/org/zanata/rest/dto/LanguageTeamSearchResultTest.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,37 @@ | ||
package org.zanata.rest.dto; | ||
|
||
import org.junit.Test; | ||
import org.zanata.common.LocaleId; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.Matchers.equalTo; | ||
|
||
/** | ||
* @author Alex Eng<a href="mailto:aeng@redhat.com">aeng@redhat.com</a> | ||
*/ | ||
public class LanguageTeamSearchResultTest { | ||
@Test | ||
public void testConstructor() { | ||
LanguageTeamSearchResult searchResults = new LanguageTeamSearchResult(); | ||
assertThat(searchResults.getType(), equalTo( | ||
SearchResult.SearchResultType.LanguageTeam)); | ||
} | ||
|
||
@Test | ||
public void testLocaleDetails() { | ||
LocaleDetails localeDetails = | ||
new LocaleDetails(LocaleId.DE, "German", null, null, true, true, | ||
null); | ||
LanguageTeamSearchResult searchResults = new LanguageTeamSearchResult(); | ||
searchResults.setLocaleDetails(localeDetails); | ||
assertThat(searchResults.getLocaleDetails(), equalTo(localeDetails)); | ||
} | ||
|
||
@Test | ||
public void testMemberCount() { | ||
long count = 100L; | ||
LanguageTeamSearchResult searchResults = new LanguageTeamSearchResult(); | ||
searchResults.setMemberCount(count); | ||
assertThat(searchResults.getMemberCount(), equalTo(count)); | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
api/zanata-common-api/src/test/java/org/zanata/rest/dto/LocaleMemberTest.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 @@ | ||
package org.zanata.rest.dto; | ||
|
||
import org.junit.Test; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.Matchers.equalTo; | ||
import static org.hamcrest.Matchers.not; | ||
|
||
/** | ||
* @author Alex Eng<a href="mailto:aeng@redhat.com">aeng@redhat.com</a> | ||
*/ | ||
public class LocaleMemberTest { | ||
|
||
@Test | ||
public void testConstructor() { | ||
String username = "user1"; | ||
LocaleMember member = new LocaleMember(username, true, true, true); | ||
assertThat(member.getUsername(), equalTo(username)); | ||
assertThat(member.getCoordinator(), equalTo(true)); | ||
assertThat(member.getReviewer(), equalTo(true)); | ||
assertThat(member.getTranslator(), equalTo(true)); | ||
} | ||
|
||
@Test | ||
public void testEqualsAndHashCode() { | ||
LocaleMember member = new LocaleMember("user1", true, true, true); | ||
LocaleMember member2 = new LocaleMember("user1", true, true, true); | ||
assertThat(member.hashCode(), equalTo(member2.hashCode())); | ||
assertThat(member.equals(member2), equalTo(true)); | ||
|
||
// different username | ||
member2 = new LocaleMember("user2", true, true, true); | ||
assertThat(member.hashCode(), not(equalTo(member2.hashCode()))); | ||
assertThat(member.equals(member2), equalTo(false)); | ||
|
||
// different coordinator | ||
member2 = new LocaleMember("user1", false, true, true); | ||
assertThat(member.hashCode(), not(equalTo(member2.hashCode()))); | ||
assertThat(member.equals(member2), equalTo(false)); | ||
|
||
// different reviewer | ||
member2 = new LocaleMember("user1", true, false, true); | ||
assertThat(member.hashCode(), not(equalTo(member2.hashCode()))); | ||
assertThat(member.equals(member2), equalTo(false)); | ||
|
||
// different translator | ||
member2 = new LocaleMember("user1", true, true, false); | ||
assertThat(member.hashCode(), not(equalTo(member2.hashCode()))); | ||
assertThat(member.equals(member2), equalTo(false)); | ||
} | ||
} |
Oops, something went wrong.