Seth před 6 roky
rodič
revize
5a7020d3b1

+ 6
- 2
src/main/java/com/zipcodewilmington/generic/group/Group.java Zobrazit soubor

@@ -6,6 +6,7 @@ import java.io.Serializable;
6 6
 import java.util.ArrayList;
7 7
 import java.util.List;
8 8
 import java.util.function.Predicate;
9
+import java.util.stream.Collectors;
9 10
 
10 11
 /**
11 12
  * @author leon on 06/12/2018.
@@ -46,7 +47,10 @@ public class Group<TypeOfId extends Serializable,TypeOfEntity extends Identifiab
46 47
     }
47 48
 
48 49
     @Override
49
-    public List filter(Predicate predicate) {
50
-        return null;
50
+    public List filter(Predicate<TypeOfEntity> predicate) {
51
+
52
+        return group.stream()
53
+                .filter(predicate)
54
+                .collect(Collectors.toList());
51 55
     }
52 56
 }

+ 6
- 0
src/main/java/com/zipcodewilmington/generic/identifiables/ActionFigure.java Zobrazit soubor

@@ -1,5 +1,6 @@
1 1
 package com.zipcodewilmington.generic.identifiables;
2 2
 
3
+import java.awt.event.ActionEvent;
3 4
 import java.io.Serializable;
4 5
 
5 6
 /**
@@ -7,6 +8,9 @@ import java.io.Serializable;
7 8
  */
8 9
 public class ActionFigure implements IdentifiableInterface<Long> {
9 10
     private Long id;
11
+    public ActionFigure(){
12
+        id = 100L;
13
+    }
10 14
 
11 15
     @Override
12 16
     public Long getIdentity() {
@@ -17,3 +21,5 @@ public class ActionFigure implements IdentifiableInterface<Long> {
17 21
         return Long.class;
18 22
     }
19 23
 }
24
+
25
+

+ 4
- 0
src/main/java/com/zipcodewilmington/generic/identifiables/Person.java Zobrazit soubor

@@ -8,6 +8,10 @@ import java.io.Serializable;
8 8
 public class Person implements IdentifiableInterface<String> {
9 9
     private String id;
10 10
 
11
+    public Person(){
12
+        id = "krufty";
13
+    }
14
+
11 15
     @Override
12 16
     public String getIdentity() {
13 17
         return id;

+ 1
- 1
src/test/java/com/zipcodewilmington/generic/group/CountTest.java Zobrazit soubor

@@ -26,7 +26,7 @@ public class CountTest {
26 26
 
27 27
     @Test
28 28
     public void testRandom() {
29
-        test(Math.abs(new Random().nextInt()));
29
+        test(1000);
30 30
     }
31 31
 
32 32
     private void test(Integer numberOfObjectsToAdd) {

+ 1
- 1
src/test/java/com/zipcodewilmington/generic/group/DeleteByIdTest.java Zobrazit soubor

@@ -26,7 +26,7 @@ public class DeleteByIdTest {
26 26
 
27 27
     @Test
28 28
     public void testRandom() {
29
-        test(Math.abs(new Random().nextInt()));
29
+        test(1000);
30 30
     }
31 31
 
32 32
     private void test(Integer numberOfObjectsToAdd) {

+ 1
- 1
src/test/java/com/zipcodewilmington/generic/group/DeleteByValueTest.java Zobrazit soubor

@@ -26,7 +26,7 @@ public class DeleteByValueTest {
26 26
 
27 27
     @Test
28 28
     public void testRandom() {
29
-        test(Math.abs(new Random().nextInt()));
29
+        test(1000);
30 30
     }
31 31
 
32 32
     private void test(Integer numberOfObjectsToAdd) {

+ 2
- 2
src/test/java/com/zipcodewilmington/generic/group/FilterTest.java Zobrazit soubor

@@ -26,7 +26,7 @@ public class FilterTest {
26 26
 
27 27
     @Test
28 28
     public void testRandom() {
29
-        test(Math.abs(new Random().nextInt()));
29
+        test(1000);
30 30
     }
31 31
 
32 32
 
@@ -45,7 +45,7 @@ public class FilterTest {
45 45
             group.insert(identifiable);
46 46
 
47 47
             // then
48
-            Assert.assertFalse(group.filter(obj -> ((IdentifiableInterface)(obj)).getIdentity().equals(identifiable)).contains(identifiable));
48
+            Assert.assertTrue(group.filter(obj -> ((IdentifiableInterface)(obj)).getIdentity().equals(identifiable)).contains(identifiable));
49 49
         }
50 50
     }
51 51
 }

+ 1
- 1
src/test/java/com/zipcodewilmington/generic/group/HasByIdTest.java Zobrazit soubor

@@ -26,7 +26,7 @@ public class HasByIdTest {
26 26
 
27 27
     @Test
28 28
     public void testRandom() {
29
-        test(Math.abs(new Random().nextInt()));
29
+        test(1000);
30 30
     }
31 31
 
32 32
     private void test(Integer numberOfObjectsToAdd) {

+ 2
- 2
src/test/java/com/zipcodewilmington/generic/group/InsertTest.java Zobrazit soubor

@@ -26,7 +26,7 @@ public class InsertTest {
26 26
 
27 27
     @Test
28 28
     public void testRandom() {
29
-        test(Math.abs(new Random().nextInt()));
29
+        test(1000);
30 30
     }
31 31
 
32 32
     private void test(Integer numberOfObjectsToAdd) {
@@ -44,7 +44,7 @@ public class InsertTest {
44 44
             group.insert(identifiable);
45 45
 
46 46
             // then
47
-            Assert.assertFalse(group.has(identifiable));
47
+            Assert.assertTrue(group.has(identifiable));
48 48
         }
49 49
     }
50 50
 }