Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #288 from zanata/ZNTA-1915-language-users
Znta 1915 language users
- Loading branch information
Showing
26 changed files
with
706 additions
and
388 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; | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
api/zanata-common-api/src/main/java/org/zanata/rest/dto/LocalesResults.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,54 @@ | ||
package org.zanata.rest.dto; | ||
|
||
import java.io.Serializable; | ||
import java.util.List; | ||
import org.codehaus.jackson.annotate.JsonIgnoreProperties; | ||
import org.codehaus.jackson.annotate.JsonProperty; | ||
import org.codehaus.jackson.map.annotate.JsonSerialize; | ||
|
||
/** | ||
* @author Alex Eng <a href="mailto:aeng@redhat.com">aeng@redhat.com</a> | ||
*/ | ||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL) | ||
public class LocalesResults implements Serializable { | ||
public Integer totalCount; | ||
public List<LanguageTeamSearchResult> results; | ||
|
||
@java.beans.ConstructorProperties({ "totalCount", "results" }) | ||
public LocalesResults(final int totalCount, | ||
final List<LanguageTeamSearchResult> results) { | ||
this.totalCount = totalCount; | ||
this.results = results; | ||
} | ||
|
||
@JsonProperty("totalCount") | ||
public Integer getTotalCount() { | ||
return this.totalCount; | ||
} | ||
|
||
@JsonProperty("results") | ||
public List<LanguageTeamSearchResult> getResults() { | ||
return this.results; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
|
||
LocalesResults that = (LocalesResults) o; | ||
|
||
if (totalCount != null ? !totalCount.equals(that.totalCount) : | ||
that.totalCount != null) return false; | ||
return results != null ? results.equals(that.results) : | ||
that.results == null; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
int result = totalCount != null ? totalCount.hashCode() : 0; | ||
result = 31 * result + (results != null ? results.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
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)); | ||
} | ||
} |
Oops, something went wrong.