Skip to content

Commit 9d88872

Browse files
committed
code coverage increased.
1 parent c650ece commit 9d88872

File tree

14 files changed

+35
-63
lines changed

14 files changed

+35
-63
lines changed

Vishal Mawani/Sprint 1/HealthCareSystem/src/main/java/com/capgemini/healthcaresystem/dao/TestDao.java

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33

44

55
import com.capgemini.healthcaresystem.dto.DiagnosticTest;
6+
import com.capgemini.healthcaresystem.exception.NullCenterId;
67
import com.capgemini.healthcaresystem.util.TestRepository;
78

8-
import java.util.ArrayList;
99
import java.util.List;
10-
import java.util.Map;
1110
import java.util.Map.Entry;
1211

1312
public class TestDao {
@@ -16,6 +15,7 @@ public class TestDao {
1615

1716
public String addTestDao(String cId,DiagnosticTest diagnosticTest){
1817

18+
1919
for (Entry<String, List<DiagnosticTest>> entry : TestRepository.getCenterIdTestListMap().entrySet()) {
2020
String key = entry.getKey();
2121

@@ -26,8 +26,9 @@ public String addTestDao(String cId,DiagnosticTest diagnosticTest){
2626

2727
}
2828

29+
2930
}
30-
System.out.println(TestRepository.getCenterIdTestListMap());
31+
3132

3233
return "added successfully";
3334
}
@@ -41,29 +42,13 @@ public String removeTestDao(String cid,DiagnosticTest diagnosticTest) {
4142
List<DiagnosticTest> values = entry.getValue();
4243
values.remove(diagnosticTest);
4344
TestRepository.getCenterIdTestListMap().put(key, values);
45+
4446
}
4547
}
4648
return "removed successfully";
4749
}
4850

49-
// public List<String> getCenterIdTestListDao(String cid){
50-
// List<String> tempDao = new ArrayList<String>();
51-
// for (Entry<String, List<DiagnosticTest>> entry : TestRepository.getCenterIdTestListMap().entrySet()) {
52-
// String key = entry.getKey();
53-
// if(key.equals(cid)) {
54-
// List<DiagnosticTest> values = entry.getValue();
55-
// for(int i=0;i<values.size();i++) {
56-
// tempDao.add(values.get(i).getTestName());
57-
// }
58-
// }
59-
// }
60-
// return tempDao;
61-
// }
62-
63-
// public Map<String,String> getCenterIdCenterNameMapDao() {
64-
// return TestRepository.getCenterIdCenterNameMap();
65-
// }
66-
51+
6752

6853
public String getTestIdDao() {
6954
return TestRepository.getTestId();

Vishal Mawani/Sprint 1/HealthCareSystem/src/main/java/com/capgemini/healthcaresystem/dto/DiagnosticCenter.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package com.capgemini.healthcaresystem.dto;
22

33
import java.util.List;
4-
5-
import com.capgemini.healthcaresystem.util.TestRepository;
64
public class DiagnosticCenter {
75

86
private String centerName;
@@ -44,13 +42,13 @@ public List<DiagnosticTest> getListOfTests() {
4442
return listOfTests;
4543
}
4644
public void setListOfTests(List<DiagnosticTest> listOfTests) {
47-
this.listOfTests = listOfTests;
45+
DiagnosticCenter.listOfTests = listOfTests;
4846
}
4947
public List<Appointment> getAppointmentList() {
5048
return appointmentList;
5149
}
5250
public void setAppointmentList(List<Appointment> appointmentList) {
53-
this.appointmentList = appointmentList;
51+
DiagnosticCenter.appointmentList = appointmentList;
5452
}
5553

5654

Vishal Mawani/Sprint 1/HealthCareSystem/src/main/java/com/capgemini/healthcaresystem/service/TestService.java

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
package com.capgemini.healthcaresystem.service;
22

3-
import java.util.List;
4-
5-
import java.util.Map;
6-
73
import com.capgemini.healthcaresystem.dao.TestDao;
84
import com.capgemini.healthcaresystem.dto.DiagnosticTest;
95
import com.capgemini.healthcaresystem.exception.NullCenterId;
@@ -25,7 +21,7 @@ public String addTestService(String cId,DiagnosticTest diagnosticTest) throws Nu
2521
throw new NullTestValue("Test object passed is null");
2622
}
2723
testDaoObject.addTestDao(cId,diagnosticTest);
28-
return "abc";
24+
return "added successfully";
2925
}
3026

3127

@@ -44,21 +40,6 @@ public String removeTestService(String cid,DiagnosticTest diagnosticTest) throws
4440
return "called testDao remove";
4541
}
4642

47-
48-
49-
50-
// public List<String> getCenterIdTestListService(String cid) throws NullCenterId{
51-
// if(cid.isEmpty()) {
52-
// throw new NullCenterId("Center Id is passed null");
53-
// }
54-
//
55-
// return testDaoObject.getCenterIdTestListDao(cid);
56-
//
57-
// }
58-
59-
// public Map<String,String> getCenterIdCenterNameMapService() {
60-
// return testDaoObject.getCenterIdCenterNameMapDao();
61-
// }
6243

6344

6445
public String getTestIdService() {

Vishal Mawani/Sprint 1/HealthCareSystem/src/main/java/com/capgemini/healthcaresystem/ui/Ui.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public void execute(){
3838
DiagnosticTest temp = new DiagnosticTest(null,getTestName());
3939

4040
String cid = getCenterId();
41-
testServiceObject.addTestService(cid,temp);
41+
System.out.println(testServiceObject.addTestService(cid,temp));
4242
break;
4343

4444
case 2:
@@ -49,7 +49,7 @@ public void execute(){
4949
String tid = getTestIdUser();
5050
String tname = getTestName();
5151
DiagnosticTest temp1 = new DiagnosticTest(tid,tname);
52-
testServiceObject.removeTestService(cid1,temp1);
52+
System.out.println(testServiceObject.removeTestService(cid1,temp1));
5353
break;
5454

5555
default:

Vishal Mawani/Sprint 1/HealthCareSystem/src/main/java/com/capgemini/healthcaresystem/util/TestRepository.java

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,24 @@
88

99
public class TestRepository {
1010

11-
private static Map<String,String> centerIdCenterNameMap = new TreeMap<String,String>();
11+
private static Map<String,String> centerIdCenterNameMap = new TreeMap<>();
1212

13-
private static Map<String,List<DiagnosticTest>> centerIdTestListMap = new TreeMap<String,List<DiagnosticTest>>();
13+
private static Map<String,List<DiagnosticTest>> centerIdTestListMap = new TreeMap<>();
1414
static int randomTestId=100;
1515

1616

1717

1818
public TestRepository() {
1919

20-
makeCenterIdCenterNameMap();
20+
makeCenterIdCenterNameMap(); //Constructor calling functions to populate the repository...
2121
makeCenterIdTestListMap();
2222

2323
}
2424

2525
public void makeCenterIdCenterNameMap() {
2626
centerIdCenterNameMap.put("1001","AIMS");
2727
centerIdCenterNameMap.put("1002","MAX");
28-
centerIdCenterNameMap.put("1003","APOLO");
28+
centerIdCenterNameMap.put("1003","APOLO");// Center name and center id...
2929
centerIdCenterNameMap.put("1004","FORTIS");
3030
centerIdCenterNameMap.put("1005","TRAUMA CENTER");
3131

@@ -41,7 +41,7 @@ public void makeCenterIdTestListMap() {
4141
populateListOfTests(listOfTests2);
4242
centerIdTestListMap.put("1002",listOfTests2);
4343

44-
List<DiagnosticTest> listOfTests3 = new ArrayList<>();
44+
List<DiagnosticTest> listOfTests3 = new ArrayList<>();// Center name and corresponding list of tests...
4545
populateListOfTests(listOfTests3);
4646
centerIdTestListMap.put("1003",listOfTests3);
4747

@@ -60,7 +60,7 @@ public List<DiagnosticTest> populateListOfTests(List<DiagnosticTest> temp){
6060
DiagnosticTest t1 = new DiagnosticTest(getTestId(),"blood group");
6161
DiagnosticTest t2 = new DiagnosticTest(getTestId(),"blood sugar");
6262
DiagnosticTest t3 = new DiagnosticTest(getTestId(),"blood pressure");
63-
temp.add(t1);
63+
temp.add(t1);// Generating list of test for every center...
6464
temp.add(t2);
6565
temp.add(t3);
6666
return temp;
@@ -69,15 +69,11 @@ public List<DiagnosticTest> populateListOfTests(List<DiagnosticTest> temp){
6969
}
7070

7171

72-
73-
// public static Map<String, String> getCenterIdCenterNameMap() {
74-
// return centerIdCenterNameMap;
75-
// }
7672

7773

7874

7975
public static Map<String, List<DiagnosticTest>> getCenterIdTestListMap() {
80-
return centerIdTestListMap;
76+
return centerIdTestListMap;
8177
}
8278

8379

Vishal Mawani/Sprint 1/HealthCareSystem/src/test/java/com/capgemini/healthcaresystem/daotest/TestDaoTest.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,32 @@
33

44

55
import static org.junit.jupiter.api.Assertions.assertEquals;
6-
76
import org.junit.jupiter.api.Test;
87

98
import com.capgemini.healthcaresystem.dao.TestDao;
109
import com.capgemini.healthcaresystem.dto.DiagnosticTest;
11-
import com.capgemini.healthcaresystem.service.TestService;
10+
import com.capgemini.healthcaresystem.exception.NullCenterId;
11+
import com.capgemini.healthcaresystem.util.TestRepository;
1212

1313
public class TestDaoTest {
1414

1515
@Test
16-
public void checkAddTestDao(){
16+
public void checkAddTestDao() throws NullCenterId{
17+
TestRepository repoObject = new TestRepository();
1718
DiagnosticTest obj = new DiagnosticTest("112","cancer");
1819
TestDao daoObject = new TestDao();
1920
assertEquals("added successfully" ,daoObject.addTestDao("1001", obj));
2021

2122
}
22-
23+
2324
@Test
2425
public void checkRemoveTestDao() {
26+
TestRepository repoObject = new TestRepository();
2527
DiagnosticTest obj = new DiagnosticTest("102","blood sugar");
2628
TestDao daoObject = new TestDao();
2729
assertEquals("removed successfully" ,daoObject.removeTestDao("1002",obj));
2830
}
2931

32+
33+
3034
}

Vishal Mawani/Sprint 1/HealthCareSystem/src/test/java/com/capgemini/healthcaresystem/servicetest/TestServiceTest.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import com.capgemini.healthcaresystem.exception.NullCenterId;
55
import com.capgemini.healthcaresystem.exception.NullTestValue;
66
import com.capgemini.healthcaresystem.service.TestService;
7+
import com.capgemini.healthcaresystem.util.TestRepository;
78

89
import static org.junit.jupiter.api.Assertions.assertEquals;
910
import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -14,6 +15,7 @@ public class TestServiceTest {
1415

1516
@Test
1617
void checkAddTestService() throws NullCenterId, NullTestValue {
18+
TestRepository repoObject = new TestRepository();
1719
DiagnosticTest obj = new DiagnosticTest("110","malaria");
1820
TestService serviceObject = new TestService();
1921
Throwable exception = assertThrows(Exception.class, ()->{serviceObject.addTestService("",obj);});
@@ -22,6 +24,7 @@ void checkAddTestService() throws NullCenterId, NullTestValue {
2224

2325
@Test
2426
void checkAddTestService1() throws NullTestValue, NullCenterId{
27+
TestRepository repoObject = new TestRepository();
2528
DiagnosticTest obj = null;
2629
TestService serviceObject = new TestService();
2730
Throwable exception = assertThrows(Exception.class, ()->{serviceObject.addTestService("1001",obj);});
@@ -30,14 +33,16 @@ void checkAddTestService1() throws NullTestValue, NullCenterId{
3033

3134
@Test
3235
void checkAddTestService2() throws NullTestValue, NullCenterId{
36+
TestRepository repoObject = new TestRepository();
3337
DiagnosticTest obj = new DiagnosticTest("110","malaria");
3438
TestService serviceObject = new TestService();
35-
assertEquals("abc", serviceObject.addTestService("1001",obj));
39+
assertEquals("added successfully", serviceObject.addTestService("1001",obj));
3640
}
3741

3842

3943
@Test
4044
public void checkRemoveTestService() throws NullTestValue, NullCenterId {
45+
TestRepository repoObject = new TestRepository();
4146
DiagnosticTest obj = new DiagnosticTest("102","blood sugar");
4247
TestService serviceObject = new TestService();
4348
Throwable exception = assertThrows(Exception.class, ()->{serviceObject.removeTestService("",obj);});
@@ -47,6 +52,7 @@ public void checkRemoveTestService() throws NullTestValue, NullCenterId {
4752
@Test
4853

4954
public void checkRemoveTestService1() throws NullTestValue, NullCenterId {
55+
TestRepository repoObject = new TestRepository();
5056
DiagnosticTest obj = null;
5157
TestService serviceObject = new TestService();
5258
Throwable exception = assertThrows(Exception.class, ()->{serviceObject.removeTestService("1001",obj);});
@@ -56,6 +62,7 @@ public void checkRemoveTestService1() throws NullTestValue, NullCenterId {
5662

5763
@Test
5864
public void checkRemoveTestService2() throws NullTestValue, NullCenterId {
65+
TestRepository repoObject = new TestRepository();
5966
DiagnosticTest obj = new DiagnosticTest("102","blood sugar");
6067
TestService serviceObject = new TestService();
6168
assertEquals("called testDao remove",serviceObject.removeTestService("1001", obj));
@@ -64,6 +71,7 @@ public void checkRemoveTestService2() throws NullTestValue, NullCenterId {
6471

6572
@Test
6673
public void checkGetTestIdService() {
74+
TestRepository repoObject = new TestRepository();
6775
TestService serviceObject = new TestService();
6876
String str = serviceObject.getTestIdService();
6977
assertEquals(Integer.toString((Integer.parseInt(str)+1)),serviceObject.getTestIdService());
-144 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
15 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)