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.
rhbz1110627,rhbz1038852 - add src dir and trans dir to zanata config
- Loading branch information
Patrick Huang
committed
Jun 30, 2014
1 parent
3c0bba5
commit dda35c9
Showing
9 changed files
with
217 additions
and
60 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
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
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
68 changes: 68 additions & 0 deletions
68
zanata-client-commands/src/test/java/org/zanata/client/commands/OptionsUtilTest.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,68 @@ | ||
package org.zanata.client.commands; | ||
|
||
import java.io.File; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.mockito.Mock; | ||
import org.mockito.MockitoAnnotations; | ||
import org.zanata.client.config.ZanataConfig; | ||
|
||
import static org.mockito.Matchers.any; | ||
import static org.mockito.Mockito.never; | ||
import static org.mockito.Mockito.verify; | ||
import static org.mockito.Mockito.when; | ||
|
||
public class OptionsUtilTest { | ||
|
||
@Mock | ||
private ConfigurableProjectOptions opts; | ||
private ZanataConfig config; | ||
|
||
@Before | ||
public void setUp() { | ||
MockitoAnnotations.initMocks(this); | ||
config = new ZanataConfig(); | ||
} | ||
|
||
@Test | ||
public void willApplyConfigFromFileIfNotSetInOptions() throws Exception { | ||
// Given: options are not set and exists in zanata config | ||
when(opts.getSrcDir()).thenReturn(null); | ||
when(opts.getTransDir()).thenReturn(null); | ||
config.setSrcDir("a"); | ||
config.setTransDir("b"); | ||
|
||
// When: | ||
OptionsUtil.applySrcDirAndTransDirFromProjectConfig(opts, config); | ||
|
||
// Then: | ||
verify(opts).setSrcDir(new File("a")); | ||
verify(opts).setTransDir(new File("b")); | ||
} | ||
@Test | ||
public void willSetToDefaultValueIfNeitherHasValue() { | ||
when(opts.getSrcDir()).thenReturn(null); | ||
when(opts.getTransDir()).thenReturn(null); | ||
|
||
OptionsUtil.applySrcDirAndTransDirFromProjectConfig(opts, config); | ||
|
||
verify(opts).setSrcDir(new File(".")); | ||
verify(opts).setTransDir(new File(".")); | ||
} | ||
@Test | ||
public void optionTakesPrecedenceOverConfig() { | ||
// Given: options are set and exists in zanata config | ||
when(opts.getSrcDir()).thenReturn(new File("pot")); | ||
when(opts.getTransDir()).thenReturn(new File(".")); | ||
config.setSrcDir("a"); | ||
config.setTransDir("b"); | ||
|
||
// When: | ||
OptionsUtil.applySrcDirAndTransDirFromProjectConfig(opts, config); | ||
|
||
// Then: | ||
verify(opts, never()).setSrcDir(any(File.class)); | ||
verify(opts, never()).setTransDir(any(File.class)); | ||
} | ||
} |
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