Skip to content

Commit

Permalink
making more tests for better coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrej Čalfa committed Nov 23, 2022
1 parent d2b66b3 commit dd4811b
Showing 1 changed file with 92 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -181,4 +181,96 @@ 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
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");
}
}

0 comments on commit dd4811b

Please sign in to comment.