Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

more tests for better coverage #509

Merged
merged 9 commits into from
Nov 25, 2022
Original file line number Diff line number Diff line change
Expand Up @@ -181,4 +181,97 @@ public void testPropertiesWithTarget() {
assertEquals(pb.getTargets().get(0).getName(), "android");
assertEquals(pb.getProjectId(), "666");
}

@Test
public void testMockPropBuildersWithTargets() {
PropertiesBuilders pb = mock(PropertiesBuilders.class);
when(pb.buildPropertiesWithTargets(null,null,null,null)).thenThrow(NullPointerException.class);
}
@Test
public void testMockPropWithTargets() {
PropertiesWithTargets pt = mock(PropertiesWithTargets.class);
when(pt.getTargets().isEmpty()).thenThrow(NullPointerException.class);
}

@Test
public void testMockBasePropUrl() {
BaseProperties bp = mock(BaseProperties.class);
bp.setBaseUrl("https://crowdin.com");
String url = "https://crowdin.com";
when(bp.getBaseUrl()).thenReturn(url);
}

@Test
public void testMockBasePropPath() {
BaseProperties bp = mock(BaseProperties.class);
bp.setBasePath("./path");
String path = "./path";
when(bp.getBasePath()).thenReturn(path);
}

@Test
public void testMockBasePropApiToken() {
BaseProperties bp = mock(BaseProperties.class);
bp.setApiToken("123Token");
String token = "123Token";
when(bp.getApiToken()).thenReturn(token);
}

@Test
public void testMockProjectPropToken() {
ProjectProperties pp = mock(ProjectProperties.class);
pp.setApiToken("123Token");
String token = "123Token";
when(pp.getApiToken()).thenReturn(token);
}

@Test
public void testMockProjectPropPath() {
ProjectProperties pp = mock(ProjectProperties.class);
pp.setBasePath("./path");
String path = "./path";
when(pp.getBasePath()).thenReturn(path);
}

@Test
public void testMockProjectPropUrl() {
ProjectProperties pp = mock(ProjectProperties.class);
pp.setBaseUrl("https://crowdin.com");
String url = "https://crowdin.com";
when(pp.getBaseUrl()).thenReturn(url);
}

@Test
public void testMockPropBuilderBasePropUrl() {
PropertiesBuilders pb = mock(PropertiesBuilders.class);
File configFile = new File("folder/crowdinTest.yml");
String minimalConfigFileText = NewPropertiesWithTargetsUtilBuilder
.minimalBuilt().buildToString();
configFile = tempProject.addFile(configFile.getPath(), minimalConfigFileText);

ParamsWithTargets okParams = new ParamsWithTargets();
okParams.setBaseUrlParam("https://crowdin.com");

BaseProperties bp = mock(BaseProperties.class);
pb.buildBaseProperties(out, configFile,null, okParams);

when(bp.getBaseUrl()).thenReturn( "https://crowdin.com");
}

@Test
andrii-bodnar marked this conversation as resolved.
Show resolved Hide resolved
public void testMockPropBuilderBasePropIdParam() {
PropertiesBuilders pb = mock(PropertiesBuilders.class);
File configFile = new File("folder/crowdinTest.yml");
String minimalConfigFileText = NewPropertiesWithTargetsUtilBuilder
.minimalBuilt().buildToString();
configFile = tempProject.addFile(configFile.getPath(), minimalConfigFileText);

ParamsWithTargets okParams = new ParamsWithTargets();
okParams.setIdParam("123");

BaseProperties bp = mock(BaseProperties.class);
pb.buildBaseProperties(out, configFile,null, okParams);

when(bp.getApiToken()).thenReturn( "123");
}
}