Skip to content
Snippets Groups Projects
Commit a31033da authored by zabiulla.ahmadi's avatar zabiulla.ahmadi
Browse files

test search implement

parent 1cae5bbf
No related branches found
No related tags found
No related merge requests found
...@@ -79,6 +79,7 @@ public class Family extends Contacts { ...@@ -79,6 +79,7 @@ public class Family extends Contacts {
return this; return this;
} }
public void updateContact() { public void updateContact() {
clearConsoleScreen(); clearConsoleScreen();
PrintInColor(" ==================================================================================\n", GREEN); PrintInColor(" ==================================================================================\n", GREEN);
...@@ -133,7 +134,6 @@ public class Family extends Contacts { ...@@ -133,7 +134,6 @@ public class Family extends Contacts {
} }
} }
@Override @Override
public void showContact() { public void showContact() {
...@@ -187,4 +187,9 @@ public class Family extends Contacts { ...@@ -187,4 +187,9 @@ public class Family extends Contacts {
} }
@Override
public String toString() {
return this.getName();
}
} }
...@@ -189,4 +189,9 @@ public class Friends extends Contacts { ...@@ -189,4 +189,9 @@ public class Friends extends Contacts {
"----------------------------------------------------------------------------------\n"); "----------------------------------------------------------------------------------\n");
} }
@Override
public String toString() {
return this.getName();
}
} }
...@@ -188,4 +188,9 @@ public class Professional extends Contacts { ...@@ -188,4 +188,9 @@ public class Professional extends Contacts {
"----------------------------------------------------------------------------------\n"); "----------------------------------------------------------------------------------\n");
} }
@Override
public String toString() {
return this.getName();
}
} }
package ContactException;
public class ContactException {
}
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import java.util.List; import java.util.List;
import org.junit.Test; import org.junit.Test;
...@@ -11,17 +10,21 @@ import Friends.Friends; ...@@ -11,17 +10,21 @@ import Friends.Friends;
public class MainTest { public class MainTest {
Application app;
public MainTest() {
app = new Application();
}
@Test @Test
public void insertContactTest() { public void insertContactTest() {
Application app = new Application(); String name = "alex";
List<String> lastName = List.of("kurteshi", "browman");
String name = "agnon";
List<String> lastName = List.of("kurteshi", "burteshi");
String address = "rue du rhone 4, 1203 Genève"; String address = "rue du rhone 4, 1203 Genève";
List<String> telephoneNumber = List.of("+41 77 444 33 22"); List<String> telephoneNumber = List.of("+41 77 444 33 22");
List<String> email = List.of("agnon@gmail.com"); List<String> email = List.of("alex@gmail.com");
List<String> socialAcount = List.of("https://hello.com/?name=agnon"); List<String> socialAcount = List.of("https://hello.com/?name=alex");
String profession = "student"; String profession = "student";
String friendSince = "2022/02/02"; String friendSince = "2022/02/02";
...@@ -33,21 +36,17 @@ public class MainTest { ...@@ -33,21 +36,17 @@ public class MainTest {
assertEquals(app.getContactList().size(), 1); assertEquals(app.getContactList().size(), 1);
assertEquals(app.getContactList().get(0).getName(), name); assertEquals(app.getContactList().get(0).getName(), name);
assertEquals(app.getContactList().get(0).getType(), contact.getType()); assertEquals(app.getContactList().get(0).getType(), contact.getType());
System.out.println("INSERTION TEST PASSED");
} }
@Test @Test
public void DeleteContactTest() { public void DeleteContactTest() {
Application app = new Application(); String name = "alex";
List<String> lastName = List.of("kurteshi", "browman");
String name = "agnon";
List<String> lastName = List.of("kurteshi", "burteshi");
String address = "rue du rhone 4, 1203 Genève"; String address = "rue du rhone 4, 1203 Genève";
List<String> telephoneNumber = List.of("+41 77 444 33 22"); List<String> telephoneNumber = List.of("+41 77 444 33 22");
List<String> email = List.of("agnon@gmail.com"); List<String> email = List.of("alex@gmail.com");
List<String> socialAcount = List.of("https://hello.com/?name=agnon"); List<String> socialAcount = List.of("https://hello.com/?name=alex");
String profession = "student"; String profession = "student";
String friendSince = "2022/02/02"; String friendSince = "2022/02/02";
...@@ -60,22 +59,17 @@ public class MainTest { ...@@ -60,22 +59,17 @@ public class MainTest {
// after delete size should be 0 // after delete size should be 0
assertEquals(app.getContactList().size(), 0); assertEquals(app.getContactList().size(), 0);
System.out.println("DELETION TEST PASSED");
} }
@Test @Test
public void sort() { public void sort() {
Application app = new Application(); String name = "alex";
List<String> lastName = List.of("kurteshi", "browman");
String name = "agnon";
List<String> lastName = List.of("kurteshi", "burteshi");
String address = "rue du rhone 4, 1203 Genève"; String address = "rue du rhone 4, 1203 Genève";
List<String> telephoneNumber = List.of("+41 77 444 33 22"); List<String> telephoneNumber = List.of("+41 77 444 33 22");
List<String> email = List.of("agnon@gmail.com"); List<String> email = List.of("alex@gmail.com");
List<String> socialAcount = List.of("https://hello.com/?name=agnon"); List<String> socialAcount = List.of("https://hello.com/?name=alex");
String profession = "student"; String profession = "student";
String friendSince = "2022/02/02"; String friendSince = "2022/02/02";
...@@ -93,7 +87,31 @@ public class MainTest { ...@@ -93,7 +87,31 @@ public class MainTest {
// if sort is correct then "AAAAAA" should be at index 0 // if sort is correct then "AAAAAA" should be at index 0
assertEquals(app.getContactList().get(0).getName(), name2); assertEquals(app.getContactList().get(0).getName(), name2);
System.out.println("SORT TEST PASSED");
}
@Test
public void search() {
String name = "nonexisting";
List<String> lastName = List.of("kurteshi", "browman");
String address = "rue du rhone 4, 1203 Genève";
List<String> telephoneNumber = List.of("+41 77 444 33 22");
List<String> email = List.of("alex@gmail.com");
List<String> socialAcount = List.of("https://hello.com/?name=alex");
String profession = "student";
String friendSince = "2022/02/02";
Contacts contact = new Friends(name, lastName, address, email, telephoneNumber, socialAcount, profession,
friendSince);
boolean findAlex = app.getContactList().stream().anyMatch(e -> e.getName().equals(name));
app.addToContactList(contact);
boolean findagian = app.getContactList().stream().anyMatch(e -> e.getName().equals(name));
assertEquals(!findAlex, findagian);
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment