This repository has been archived by the owner on Nov 9, 2017. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rhbz1139950 - apply file mapping rule to xliff pull strategy
- Loading branch information
Patrick Huang
committed
Sep 25, 2014
1 parent
b119d69
commit 8c7ba2e
Showing
2 changed files
with
80 additions
and
4 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
75 changes: 75 additions & 0 deletions
75
...-client-commands/src/test/java/org/zanata/client/commands/pull/XliffStrategyPullTest.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,75 @@ | ||
package org.zanata.client.commands.pull; | ||
|
||
import com.google.common.base.Optional; | ||
import com.google.common.collect.Lists; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.zanata.client.config.FileMappingRule; | ||
import org.zanata.client.config.LocaleList; | ||
import org.zanata.client.config.LocaleMapping; | ||
|
||
import java.io.File; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.Matchers.equalTo; | ||
import static org.zanata.client.TestUtils.createAndAddLocaleMapping; | ||
|
||
public class XliffStrategyPullTest { | ||
private XliffStrategy strategy; | ||
private PullOptionsImpl opts; | ||
|
||
@Before | ||
public void setUp() { | ||
opts = new PullOptionsImpl(); | ||
opts.setLocaleMapList(new LocaleList()); | ||
opts.setProjectType("xliff"); | ||
strategy = new XliffStrategy(opts); | ||
} | ||
|
||
@Test | ||
public void canGetTransFileWithoutMappingRule() { | ||
LocaleMapping deMapping = createAndAddLocaleMapping("de", | ||
Optional.<String>absent(), opts); | ||
LocaleMapping zhMapping = | ||
createAndAddLocaleMapping("zh-CN", | ||
Optional.of("zh-Hans"), | ||
opts); | ||
|
||
File deTransFile = | ||
strategy.getTransFileToWrite("foo/message", deMapping); | ||
|
||
assertThat(deTransFile, | ||
equalTo(new File(opts.getTransDir(), "foo/message_de.xml"))); | ||
|
||
File zhTransFile = | ||
strategy.getTransFileToWrite("foo/message", zhMapping); | ||
assertThat(zhTransFile, equalTo( | ||
new File(opts.getTransDir(), "foo/message_zh_Hans.xml"))); | ||
|
||
} | ||
|
||
@Test | ||
public void canGetTransFileWithMappingRule() { | ||
LocaleMapping deMapping = createAndAddLocaleMapping("de", | ||
Optional.<String>absent(), opts); | ||
LocaleMapping zhMapping = | ||
createAndAddLocaleMapping("zh-CN", | ||
Optional.of("zh-Hans"), | ||
opts); | ||
opts.setFileMappingRules(Lists.newArrayList( | ||
new FileMappingRule("{path}/{filename}_{locale_with_underscore}.{extension}"))); | ||
|
||
File deTransFile = | ||
strategy.getTransFileToWrite("foo/message", deMapping); | ||
|
||
assertThat(deTransFile, | ||
equalTo(new File(opts.getTransDir(), "foo/message_de.xml"))); | ||
|
||
File zhTransFile = | ||
strategy.getTransFileToWrite("foo/message", zhMapping); | ||
assertThat(zhTransFile, equalTo( | ||
new File(opts.getTransDir(), "foo/message_zh_Hans.xml"))); | ||
|
||
} | ||
|
||
} |