This repository has been archived by the owner on Nov 9, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
/
RawPushCommandTest.java
96 lines (81 loc) · 3.07 KB
/
RawPushCommandTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
package org.zanata.client.commands.push;
import java.util.List;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.zanata.client.commands.ConsoleInteractor;
import org.zanata.rest.client.RestClientFactory;
import static org.hamcrest.Matchers.contains;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.when;
/**
* @author Alex Eng <a href="mailto:aeng@redhat.com">aeng@redhat.com</a>
*/
public class RawPushCommandTest {
@Mock
private PushOptions opts;
@Mock
private RestClientFactory clientFactory;
@Mock
private ConsoleInteractor console;
private RawPushCommand command;
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
when(opts.getProj()).thenReturn("project");
when(opts.getProjectVersion()).thenReturn("version");
when(opts.getProjectType()).thenReturn("File");
command = new RawPushCommand(opts, clientFactory, console);
}
@Test
public void extractFileTypeWithExtensionTest() {
String fileNameAndExtension = "properties[xml]";
String type = command.extractType(fileNameAndExtension);
assertThat(type, equalTo("properties"));
}
@Test
public void extractFileTypeWithoutExtensionTest() {
String fileNameAndExtension = "properties";
String type = command.extractType(fileNameAndExtension);
assertThat(type, equalTo("properties"));
}
@Test
public void extractFileTypeOnlyExtensionTest() {
String fileNameAndExtension = "[xml]";
String type = command.extractType(fileNameAndExtension);
assertThat(type, equalTo(""));
}
@Test
public void extractExtensionWithTypeTest() {
String fileNameAndExtension = "properties[xml]";
List<String> extensions = command.extractExtensions(fileNameAndExtension);
assertThat(extensions, contains("xml"));
}
@Test
public void extractExtensionWithTypeTest2() {
String fileNameAndExtension = "properties[xml;html]";
List<String> extensions = command.extractExtensions(fileNameAndExtension);
assertThat(extensions, containsInAnyOrder("xml", "html"));
}
@Test
public void extractExtensionWithoutTypeTest() {
String fileNameAndExtension = "[xml]";
List<String> extensions = command.extractExtensions(fileNameAndExtension);
assertThat(extensions, contains("xml"));
}
@Test
public void extractExtensionWithoutTypeTest2() {
String fileNameAndExtension = "[xml;html]";
List<String> extensions = command.extractExtensions(fileNameAndExtension);
assertThat(extensions, containsInAnyOrder("xml", "html"));
}
@Test
public void extractExtensionOnlyTypeTest() {
String fileNameAndExtension = "properties";
List<String> extensions = command.extractExtensions(fileNameAndExtension);
assertThat(extensions.size(), equalTo(0));
}
}