Leon 7 yıl önce
ebeveyn
işleme
9f9a4fddc8

+ 0
- 38
src/main/java/com/zipcodewilmington/streams/conversions/ArrayConverter.java Dosyayı Görüntüle

@@ -1,38 +0,0 @@
1
-package com.zipcodewilmington.streams.conversions;
2
-
3
-import com.zipcodewilmington.streams.anthropoid.Person;
4
-import com.zipcodewilmington.streams.anthropoid.PersonFactory;
5
-
6
-import java.util.Arrays;
7
-import java.util.List;
8
-import java.util.stream.Stream;
9
-
10
-/**
11
- * Created by leon on 5/25/17.
12
- */
13
-public final class ArrayConverter extends PersonConversionAgent<Person[]> {
14
-    public ArrayConverter(Person... people) {
15
-        super(people);
16
-    }
17
-
18
-    public ArrayConverter(int collectionSize) {
19
-        this(PersonFactory.createPersonArray(collectionSize));
20
-        /** Implementation of adapter pattern for testing purposes
21
-         *  @param collectionSize  - length of Array to be generated */
22
-    }
23
-
24
-    //TODO
25
-    public List<Person> toList() {
26
-        return null;
27
-    }
28
-
29
-    //TODO
30
-    public Stream<Person> toStream() {
31
-        return null;
32
-    }
33
-
34
-    @Override
35
-    public Person[] toArray() {
36
-        return super.objectSequence;
37
-    }
38
-}

+ 0
- 55
src/main/java/com/zipcodewilmington/streams/conversions/ConversionAgent.java Dosyayı Görüntüle

@@ -1,55 +0,0 @@
1
-package com.zipcodewilmington.streams.conversions;
2
-
3
-import java.util.List;
4
-import java.util.function.Function;
5
-import java.util.function.Predicate;
6
-import java.util.stream.Stream;
7
-
8
-/**
9
- * Created by leon on 5/25/17.
10
- * ConversionAgent is responsible for conversion between different object sequent data types
11
- * Object sequent data types include: collections, arrays, lists, maps, iterators
12
- *
13
- * @param <ObjectSequentDataType> some Object sequent data type
14
- * @param <TypeOfObjectSequence> Type of Object in the object sequence
15
- * @ATTENTION_TO_STUDENTS You are FORBIDDEN from modifying this class
16
- */
17
-
18
-public abstract class ConversionAgent<ObjectSequentDataType, TypeOfObjectSequence> {
19
-    protected ObjectSequentDataType objectSequence;
20
-
21
-    public ConversionAgent(ObjectSequentDataType objectSequence) {
22
-        this.objectSequence = objectSequence;
23
-    }
24
-
25
-    /**
26
-     * @return list representation of this object sequence
27
-     */
28
-    abstract public List<TypeOfObjectSequence> toList();
29
-
30
-    /**
31
-     * @return stream representation of this object sequence
32
-     */
33
-    abstract public Stream<TypeOfObjectSequence> toStream();
34
-
35
-    /**
36
-     * @return array representation of this object sequence
37
-     */
38
-    abstract public TypeOfObjectSequence[] toArray();
39
-
40
-    /**
41
-     * @param predicate Represents a predicate (boolean-valued function) of one argument
42
-     * @return stream representation of respectively filtered
43
-     */
44
-    public Stream<TypeOfObjectSequence> filter(Predicate<? super TypeOfObjectSequence> predicate) {
45
-        return toStream().filter(predicate);
46
-    }
47
-
48
-    /**
49
-     * @param predicate Represents a predicate (boolean-valued function) of one argument
50
-     * @return stream representation of respectively filtered
51
-     */
52
-    public Stream<TypeOfObjectSequence> flatMap(Function<? super TypeOfObjectSequence, ? extends Stream<TypeOfObjectSequence>> predicate) {
53
-        return toStream().flatMap(predicate);
54
-    }
55
-}

+ 0
- 37
src/main/java/com/zipcodewilmington/streams/conversions/ListConverter.java Dosyayı Görüntüle

@@ -1,37 +0,0 @@
1
-package com.zipcodewilmington.streams.conversions;
2
-
3
-import com.zipcodewilmington.streams.anthropoid.Person;
4
-import com.zipcodewilmington.streams.anthropoid.PersonFactory;
5
-
6
-import java.util.List;
7
-import java.util.stream.Stream;
8
-
9
-/**
10
- * Created by leon on 5/25/17.
11
- */
12
-public final class ListConverter extends PersonConversionAgent<List<Person>> {
13
-    public ListConverter(List<Person> people) {
14
-        super(people);
15
-    }
16
-
17
-    public ListConverter(int collectionSize) {
18
-        this(PersonFactory.createPersonList(collectionSize));
19
-        /** Implementation of adapter pattern for testing purposes
20
-         *  @param collectionSize  - size of List to be generated */
21
-    }
22
-
23
-    @Override
24
-    public List<Person> toList() {
25
-        return super.objectSequence;
26
-    }
27
-
28
-    //TODO
29
-    public Stream<Person> toStream() {
30
-        return null;
31
-    }
32
-
33
-    //TODO
34
-    public Person[] toArray() {
35
-        return null;
36
-    }
37
-}

+ 0
- 15
src/main/java/com/zipcodewilmington/streams/conversions/PersonConversionAgent.java Dosyayı Görüntüle

@@ -1,15 +0,0 @@
1
-package com.zipcodewilmington.streams.conversions;
2
-
3
-import com.zipcodewilmington.streams.anthropoid.Person;
4
-
5
-/**
6
- * Created by leon on 5/31/17.
7
- * The purpose of this class is to convert between different types of Person Collections
8
- * @param <ObjectSequentDataType> some sequence of Person objects
9
- * @ATTENTION_TO_STUDENTS You are FORBIDDEN from modifying this class
10
- */
11
-abstract public class PersonConversionAgent<ObjectSequentDataType> extends ConversionAgent<ObjectSequentDataType, Person> {
12
-    public PersonConversionAgent(ObjectSequentDataType personObjectSequence) {
13
-        super(personObjectSequence);
14
-    }
15
-}

+ 0
- 40
src/main/java/com/zipcodewilmington/streams/conversions/StreamConverter.java Dosyayı Görüntüle

@@ -1,40 +0,0 @@
1
-package com.zipcodewilmington.streams.conversions;
2
-
3
-import com.zipcodewilmington.streams.anthropoid.Person;
4
-import com.zipcodewilmington.streams.anthropoid.PersonFactory;
5
-
6
-import java.util.List;
7
-import java.util.stream.Collectors;
8
-import java.util.stream.Stream;
9
-
10
-/**
11
- * Created by leon on 5/25/17.
12
- */
13
-public final class StreamConverter extends PersonConversionAgent<Stream<Person>> {
14
-    private final List<Person> personList;
15
-    public StreamConverter(Stream<Person> people) {
16
-        super(people);
17
-        this.personList = super.objectSequence.collect(Collectors.toList());
18
-    }
19
-
20
-    public StreamConverter(int collectionSize) {
21
-        this(PersonFactory.createPersonStream(collectionSize));
22
-        /** Implementation of adapter pattern for testing purposes
23
-         *  @param collectionSize  - count of Stream to be generated */
24
-    }
25
-
26
-    // TODO
27
-    public List<Person> toList() {
28
-        return null;
29
-    }
30
-
31
-    // TODO
32
-    public Stream<Person> toStream() {
33
-        return null;
34
-    }
35
-
36
-    // TODO
37
-    public Person[] toArray() {
38
-        return null;
39
-    }
40
-}

+ 0
- 2
src/test/java/com/zipcodewilmington/streams/TestSuiteFullRegression.java Dosyayı Görüntüle

@@ -2,7 +2,6 @@ package com.zipcodewilmington.streams;
2 2
 
3 3
 import com.zipcodewilmington.streams.anthropoid.TestPersonFactory;
4 4
 import com.zipcodewilmington.streams.anthropoid.TestSuiteAnthropoidRegression;
5
-import com.zipcodewilmington.streams.conversions.TestSuiteConversionRegression;
6 5
 import org.junit.runner.RunWith;
7 6
 import org.junit.runners.Suite;
8 7
 
@@ -11,7 +10,6 @@ import org.junit.runners.Suite;
11 10
 @Suite.SuiteClasses({
12 11
         TestStreamFilter.class,
13 12
         TestSuiteAnthropoidRegression.class,
14
-        TestSuiteConversionRegression.class
15 13
 })
16 14
 
17 15
 /**

+ 0
- 76
src/test/java/com/zipcodewilmington/streams/conversions/TestConversionAgent.java Dosyayı Görüntüle

@@ -1,76 +0,0 @@
1
-package com.zipcodewilmington.streams.conversions;
2
-
3
-import com.zipcodewilmington.streams.anthropoid.Person;
4
-import org.junit.Assert;
5
-import org.junit.Before;
6
-import org.junit.Test;
7
-
8
-import java.util.List;
9
-import java.util.stream.Collectors;
10
-import java.util.stream.Stream;
11
-
12
-/**
13
- * Created by leon on 5/25/17.
14
- * @ATTENTION_TO_STUDENTS You are FORBIDDEN from modifying this class
15
- */
16
-public class TestConversionAgent<T extends PersonConversionAgent<Person>> {
17
-    private final T conversionAgent;
18
-
19
-    private List<Person> personList;
20
-    private Person[] personArray;
21
-    private Stream<Person> personStream;
22
-
23
-    public TestConversionAgent(T conversionAgent) {
24
-        this.conversionAgent = conversionAgent;
25
-    }
26
-
27
-    @Before
28
-    public void setup() {
29
-        this.personStream = conversionAgent.toStream();
30
-        this.personList = conversionAgent.toList();
31
-        this.personArray = conversionAgent.toArray();
32
-    }
33
-
34
-    @Test
35
-    public void testCount() {
36
-        int listSize = personList.size();
37
-        int arrayLength = personArray.length;
38
-        int streamCount = (int) personStream.count();
39
-
40
-        Assert.assertEquals(listSize, arrayLength);
41
-        Assert.assertEquals(listSize, streamCount);
42
-    }
43
-
44
-    @Test
45
-    public void testToList() {
46
-        for (int i = 0; i < personList.size(); i++) {
47
-            long listId = personList.get(i).getPersonalId();
48
-            long arrayId = personArray[i].getPersonalId();
49
-
50
-            Assert.assertEquals(listId, arrayId);
51
-        }
52
-    }
53
-
54
-
55
-    @Test
56
-    public void testToStream() {
57
-        List<Person> people = personStream.collect(Collectors.toList());
58
-
59
-        for (int i = 0; i < people.size(); i++) {
60
-            long arrayId = personArray[i].getPersonalId();
61
-            long streamId = people.get(i).getPersonalId();
62
-
63
-            Assert.assertEquals(streamId, arrayId);
64
-        }
65
-    }
66
-
67
-    @Test
68
-    public void testToArray() {
69
-        for (int i = 0; i < personArray.length; i++) {
70
-            long arrayId = personArray[i].getPersonalId();
71
-            long listId = personList.get(i).getPersonalId();
72
-
73
-            Assert.assertEquals(listId, arrayId);
74
-        }
75
-    }
76
-}

+ 0
- 13
src/test/java/com/zipcodewilmington/streams/conversions/TestConverterArray.java Dosyayı Görüntüle

@@ -1,13 +0,0 @@
1
-package com.zipcodewilmington.streams.conversions;
2
-
3
-import com.zipcodewilmington.streams.TestConstants;
4
-
5
-/**
6
- * Created by leon on 5/25/17.
7
- * @ATTENTION_TO_STUDENTS You are FORBIDDEN from modifying this class
8
- */
9
-public class TestConverterArray extends TestConversionAgent implements TestConstants {
10
-    public TestConverterArray() {
11
-        super(new ArrayConverter(collectionSize));
12
-    }
13
-}

+ 0
- 13
src/test/java/com/zipcodewilmington/streams/conversions/TestConverterList.java Dosyayı Görüntüle

@@ -1,13 +0,0 @@
1
-package com.zipcodewilmington.streams.conversions;
2
-
3
-import com.zipcodewilmington.streams.TestConstants;
4
-
5
-/**
6
- * Created by leon on 5/25/17.
7
- * @ATTENTION_TO_STUDENTS You are FORBIDDEN from modifying this class
8
- */
9
-public class TestConverterList extends TestConversionAgent implements TestConstants {
10
-    public TestConverterList() {
11
-        super(new ListConverter(collectionSize));
12
-    }
13
-}

+ 0
- 13
src/test/java/com/zipcodewilmington/streams/conversions/TestConverterStream.java Dosyayı Görüntüle

@@ -1,13 +0,0 @@
1
-package com.zipcodewilmington.streams.conversions;
2
-
3
-import com.zipcodewilmington.streams.TestConstants;
4
-
5
-/**
6
- * Created by leon on 5/25/17.
7
- * @ATTENTION_TO_STUDENTS You are FORBIDDEN from modifying this class
8
- */
9
-public class TestConverterStream extends TestConversionAgent implements TestConstants {
10
-    public TestConverterStream() {
11
-        super(new StreamConverter(collectionSize));
12
-    }
13
-}

+ 0
- 18
src/test/java/com/zipcodewilmington/streams/conversions/TestSuiteConversionRegression.java Dosyayı Görüntüle

@@ -1,18 +0,0 @@
1
-package com.zipcodewilmington.streams.conversions;
2
-
3
-import org.junit.runner.RunWith;
4
-import org.junit.runners.Suite;
5
-
6
-@RunWith(Suite.class)
7
-
8
-@Suite.SuiteClasses({
9
-        TestConverterList.class,
10
-        TestConverterArray.class,
11
-        TestConverterStream.class
12
-})
13
-
14
-/**
15
- * @ATTENTION_TO_STUDENTS You are FORBIDDEN from modifying this class
16
- */
17
-public class TestSuiteConversionRegression {
18
-}