Skip to content

Commit

Permalink
Merge branch 'master' into asciidoc
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Eng committed Feb 8, 2018
2 parents 3282d13 + 5c51443 commit 84f8d43
Show file tree
Hide file tree
Showing 737 changed files with 23,960 additions and 12,334 deletions.
2 changes: 1 addition & 1 deletion api/pom.xml
Expand Up @@ -8,7 +8,7 @@
<parent>
<groupId>org.zanata</groupId>
<artifactId>parent</artifactId>
<version>4.4.0-SNAPSHOT</version>
<version>4.5.0-SNAPSHOT</version>
<relativePath>../parent</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion api/zanata-common-api/pom.xml
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.zanata</groupId>
<artifactId>api</artifactId>
<version>4.4.0-SNAPSHOT</version>
<version>4.5.0-SNAPSHOT</version>
</parent>
<packaging>jar</packaging>

Expand Down
2 changes: 1 addition & 1 deletion build-tools/pom.xml
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.zanata</groupId>
<artifactId>build-tools</artifactId>
<version>4.4.0-SNAPSHOT</version>
<version>4.5.0-SNAPSHOT</version>
<name>Build Tools</name>
<description>Build tools for Zanata modules</description>
<url>http://zanata.org/</url>
Expand Down
2 changes: 1 addition & 1 deletion client/pom.xml
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.zanata</groupId>
<artifactId>parent</artifactId>
<version>4.4.0-SNAPSHOT</version>
<version>4.5.0-SNAPSHOT</version>
<relativePath>../parent</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion client/stub-server/pom.xml
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.zanata</groupId>
<artifactId>client</artifactId>
<version>4.4.0-SNAPSHOT</version>
<version>4.5.0-SNAPSHOT</version>
</parent>
<artifactId>stub-server</artifactId>
<name>stub-server</name>
Expand Down
2 changes: 1 addition & 1 deletion client/zanata-cli/pom.xml
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.zanata</groupId>
<artifactId>client</artifactId>
<version>4.4.0-SNAPSHOT</version>
<version>4.5.0-SNAPSHOT</version>
</parent>
<artifactId>zanata-cli</artifactId>
<name>Zanata command-line client</name>
Expand Down
Expand Up @@ -202,11 +202,19 @@ protected void processArgs(String... args) {
* @param options
*/
private void copyGlobalOptionsTo(BasicOptions options) {
options.setDebug(getDebug());
options.setErrors(getErrors());
if (!options.isDebugSet()) {
options.setDebug(getDebug());
}
if (!options.isErrorsSet()) {
options.setErrors(getErrors());
}
options.setHelp(getHelp());
options.setInteractiveMode(isInteractiveMode());
options.setQuiet(getQuiet());
if (!options.isInteractiveModeSet()) {
options.setInteractiveMode(isInteractiveMode());
}
if (!options.isQuietSet()) {
options.setQuiet(getQuiet());
}
}

private void printHelp(PrintWriter out) {
Expand Down
2 changes: 1 addition & 1 deletion client/zanata-client-commands/pom.xml
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.zanata</groupId>
<artifactId>client</artifactId>
<version>4.4.0-SNAPSHOT</version>
<version>4.5.0-SNAPSHOT</version>
</parent>
<artifactId>zanata-client-commands</artifactId>
<name>Zanata client commands</name>
Expand Down
Expand Up @@ -53,6 +53,8 @@ public interface BasicOptions {

void setInteractiveMode(boolean interactiveMode);

boolean isInteractiveModeSet();

/**
* Used to generate the command line interface and its usage help. This name
* should match the Maven Mojo's 'goal' annotation and must match the @SubCommand
Expand Down
Expand Up @@ -42,6 +42,7 @@ public abstract class BasicOptionsImpl implements BasicOptions {
private boolean quiet = false;
private boolean quietSet;
private boolean interactiveMode = true;
private boolean interactiveModeSet;
private List<CommandHook> commandHooks = new ArrayList<CommandHook>();

public BasicOptionsImpl() {
Expand Down Expand Up @@ -109,6 +110,7 @@ public boolean isInteractiveMode() {

@Override
public void setInteractiveMode(boolean interactiveMode) {
interactiveModeSet = true;
this.interactiveMode = interactiveMode;
}

Expand All @@ -133,6 +135,11 @@ public boolean isQuietSet() {
return quietSet;
}

@Override
public boolean isInteractiveModeSet() {
return interactiveModeSet;
}

@Override
public void setCommandHooks(List<CommandHook> commandHooks) {
this.commandHooks = commandHooks;
Expand Down
Expand Up @@ -362,17 +362,25 @@ public static void applyUserConfig(ConfigurableOptions opts,
if (quiet != null)
opts.setQuiet(quiet);
}

if (!opts.isInteractiveModeSet()) {
Boolean batchMode = config.getBoolean("defaults.batchMode", null);
if (batchMode != null)
opts.setInteractiveMode(!batchMode);
}
if ((opts.getUsername() == null || opts.getKey() == null)
&& opts.getUrl() != null) {
SubnodeConfiguration servers = config.getSection("servers");
String prefix = ConfigUtil.findPrefix(servers, opts.getUrl());
if (prefix != null) {
if (opts.getUsername() == null) {
opts.setUsername(servers.getString(prefix + ".username",
null));
}
if (opts.getKey() == null) {
opts.setKey(servers.getString(prefix + ".key", null));
if (servers != null) {
String prefix = ConfigUtil.findPrefix(servers, opts.getUrl());
if (prefix != null) {
if (opts.getUsername() == null) {
opts.setUsername(servers.getString(prefix + ".username",
null));
}
if (opts.getKey() == null) {
opts.setKey(servers.getString(prefix + ".key", null));
}
}
}
}
Expand Down
Expand Up @@ -61,6 +61,11 @@ public String[] getSrcFiles(File srcDir, ImmutableList<String> includes,
includes = builder.build();
}

ImmutableList.Builder<String> emptyFileExcludesBuilder = ImmutableList.builder();
for (String fileExtension : fileExtensions) {
emptyFileExcludesBuilder.add("**/" + fileExtension);
}

DirectoryScanner dirScanner = new DirectoryScanner();

if (useDefaultExcludes) {
Expand All @@ -71,7 +76,11 @@ public String[] getSrcFiles(File srcDir, ImmutableList<String> includes,

dirScanner.setCaseSensitive(isCaseSensitive);

dirScanner.setExcludes(excludes.toArray(new String[excludes.size()]));
emptyFileExcludesBuilder.addAll(excludes);
ImmutableList<String> allExcludes = emptyFileExcludesBuilder.build();


dirScanner.setExcludes(allExcludes.toArray(new String[allExcludes.size()]));
dirScanner.setIncludes(includes.toArray(new String[includes.size()]));
dirScanner.scan();
String[] includedFiles = dirScanner.getIncludedFiles();
Expand Down
Expand Up @@ -2,24 +2,29 @@

import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.zanata.client.commands.ConsoleInteractor.DisplayMode.Question;
import static org.zanata.client.commands.ConsoleInteractor.DisplayMode.Warning;
import static org.zanata.client.commands.FileMappingRuleHandler.Placeholders.allHolders;
import static org.zanata.client.commands.Messages.get;

import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.file.Files;
import java.util.List;
import java.util.Optional;

import javax.xml.bind.JAXBException;

import org.apache.commons.configuration.HierarchicalINIConfiguration;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.rules.TemporaryFolder;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.zanata.client.config.FileMappingRule;
import org.zanata.client.config.LocaleList;
Expand Down Expand Up @@ -110,6 +115,36 @@ public void optionTakesPrecedenceOverConfig() {
assertThat(opts.getExcludes()).contains("a.properties", "b.properties");
}

@Test
public void applyUserConfigTestDefault() throws MalformedURLException {
opts.setUsername("username");
opts.setUrl(new URL("http://localhost"));

HierarchicalINIConfiguration config =
Mockito.mock(HierarchicalINIConfiguration.class);
OptionsUtil.applyUserConfig(opts, config);

verify(config).getSection("servers");
verify(config).getBoolean("defaults.debug", null);
verify(config).getBoolean("defaults.errors", null);
verify(config).getBoolean("defaults.quiet", null);
verify(config).getBoolean("defaults.batchMode", null);
}

@Test
public void applyUserConfigTest() {
opts.setDebug(false);
opts.setErrors(false);
opts.setQuiet(false);
opts.setInteractiveMode(false);

HierarchicalINIConfiguration config =
Mockito.mock(HierarchicalINIConfiguration.class);
OptionsUtil.applyUserConfig(opts, config);

verifyZeroInteractions(config);
}

@Test
public void willWarnUserIfRuleSeemsWrong() {
opts.setInteractiveMode(false);
Expand Down
Expand Up @@ -23,17 +23,22 @@

import java.io.File;
import java.io.IOException;
import java.util.Set;

import javax.xml.bind.Unmarshaller;

import com.google.common.collect.ImmutableList;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import org.zanata.client.TempTransFileRule;
import org.zanata.client.TestUtils;
import org.zanata.client.config.FileMappingRule;
import org.zanata.client.config.LocaleList;
import org.zanata.client.config.LocaleMapping;
Expand All @@ -47,6 +52,7 @@
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;
import static org.zanata.client.TestUtils.createAndAddLocaleMapping;

public class XmlStrategyTest {
Expand Down Expand Up @@ -77,6 +83,33 @@ public void setUp() throws IOException {
sourceResource = new Resource("test");
}

@Test
public void findDocNamesTest() throws IOException {
PushOptions mockPushOption = Mockito.mock(PushOptions.class);
File sourceDir = TestUtils.fileFromClasspath("xliffDir");
LocaleList locales = new LocaleList();
String sourceLocale = "en-US";

ImmutableList<String> include = ImmutableList.of();
ImmutableList<String> exclude = ImmutableList.of();

when(mockPushOption.getLocaleMapList()).thenReturn(locales);
when(mockPushOption.getSourceLang()).thenReturn(sourceLocale);
when(mockPushOption.getDefaultExcludes()).thenReturn(true);
when(mockPushOption.getCaseSensitive()).thenReturn(true);
when(mockPushOption.getExcludeLocaleFilenames()).thenReturn(true);
when(mockPushOption.getValidate()).thenReturn("xsd");

strategy.setPushOptions(mockPushOption);

Set<String> localDocNames =
strategy.findDocNames(sourceDir, include, exclude,
mockPushOption.getDefaultExcludes(),
mockPushOption.getCaseSensitive(),
mockPushOption.getExcludeLocaleFilenames());
Assert.assertEquals(7, localDocNames.size());
}

@Test
public void canVisitTranslationFileWithoutFileMapping() throws Exception {
// with translation
Expand Down
Empty file.
2 changes: 1 addition & 1 deletion client/zanata-maven-plugin/pom.xml
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.zanata</groupId>
<artifactId>client</artifactId>
<version>4.4.0-SNAPSHOT</version>
<version>4.5.0-SNAPSHOT</version>
</parent>
<artifactId>zanata-maven-plugin</artifactId>

Expand Down
Expand Up @@ -60,6 +60,8 @@ public abstract class ConfigurableMojo<O extends ConfigurableOptions> extends
@Parameter(defaultValue = "${settings.interactiveMode}")
private boolean interactiveMode = true;

private boolean interactiveModeSet;

/**
* Enable HTTP message logging.
*/
Expand Down Expand Up @@ -197,13 +199,19 @@ public boolean isQuietSet() {
return !getLog().isInfoEnabled();
}

@Override
public boolean isInteractiveModeSet() {
return interactiveModeSet;
}

@Override
public boolean isInteractiveMode() {
return interactiveMode;
}

@Override
public void setInteractiveMode(boolean interactiveMode) {
interactiveModeSet = true;
this.interactiveMode = interactiveMode;
}

Expand Down
2 changes: 1 addition & 1 deletion client/zanata-rest-client/pom.xml
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.zanata</groupId>
<artifactId>client</artifactId>
<version>4.4.0-SNAPSHOT</version>
<version>4.5.0-SNAPSHOT</version>
</parent>
<packaging>jar</packaging>

Expand Down
2 changes: 1 addition & 1 deletion common/pom.xml
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.zanata</groupId>
<artifactId>parent</artifactId>
<version>4.4.0-SNAPSHOT</version>
<version>4.5.0-SNAPSHOT</version>
<relativePath>../parent</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion common/zanata-adapter-glossary/pom.xml
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.zanata</groupId>
<artifactId>common</artifactId>
<version>4.4.0-SNAPSHOT</version>
<version>4.5.0-SNAPSHOT</version>
</parent>
<packaging>jar</packaging>

Expand Down

0 comments on commit 84f8d43

Please sign in to comment.