Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,3 @@ workbench.xmi
*.swp
.settings
.checkstyle
twitter4j.properties
7 changes: 0 additions & 7 deletions akormushin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,6 @@
<artifactId>jcommander</artifactId>
<version>1.48</version>
</dependency>

<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
<scope>test</scope>
</dependency>
</dependencies>

<developers>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,14 @@
import java.util.Arrays;
import java.util.List;

import static java.util.stream.Collectors.toCollection;

/**
* Created by kormushin on 22.09.15.
*/
@XmlRootElement
@XmlType
@XmlAccessorType(XmlAccessType.FIELD)
@DatabaseTable
public class Group implements Cloneable {
public class Group {

@PrimaryKey
@XmlAttribute
Expand Down Expand Up @@ -55,16 +53,4 @@ public String toString() {
+ '}';
}

@Override
public Group clone() {
try {
Group clone = (Group) super.clone();
clone.setStudents(students.stream()
.map(Student::clone)
.collect(toCollection(ArrayList::new)));
return clone;
} catch (CloneNotSupportedException e) {
throw new IllegalStateException(e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
@XmlRootElement
@XmlType
@XmlAccessorType(XmlAccessType.FIELD)
public class Student implements Cloneable {
public class Student {

@XmlAttribute
private String firstName;
Expand Down Expand Up @@ -47,13 +47,4 @@ public String toString() {
+ ", secondName='" + getSecondName() + '\''
+ '}';
}

@Override
public Student clone() {
try {
return (Student) super.clone();
} catch (CloneNotSupportedException e) {
throw new IllegalStateException(e);
}
}
}

This file was deleted.

This file was deleted.

This file was deleted.

3 changes: 0 additions & 3 deletions akormushin/src/main/resources/log4j.properties

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,71 +1,34 @@
package ru.fizteh.fivt.students.akormushin.annotations.junit;

import org.junit.After;
import junit.framework.TestCase;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import ru.fizteh.fivt.students.akormushin.annotations.xml.Group;
import ru.fizteh.fivt.students.akormushin.annotations.xml.Student;

import java.util.ArrayList;
import java.util.Arrays;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyObject;
import static org.mockito.Mockito.when;
import java.security.acl.Group;

/**
* Created by kormushin on 22.09.15.
*/
@RunWith(MockitoJUnitRunner.class)
public class GroupStatisticsTest {
public class GroupStatisticsTest extends TestCase {

@InjectMocks
private GroupStatistics groupStatistics;

@Mock
private Database<String, Group> database;// = mock(Database.class);

@BeforeClass
public static void beforeAll() {
System.out.println("before all");
}
private Database<String, Group> database;

@Before
public void setUp1() throws IllegalAccessException {
Student student1 = new Student("Ivan", "Ivanov");
Student student2 = new Student("Petr", "Petrov");
public void setUp(){

Group group1 = new Group("494", student1, student2);
Group group2 = new Group("495", student1, student2);

when(database.select()).thenReturn(Arrays.asList(group1, group2));
when(database.select(anyObject())).thenReturn(group1);
when(database.select(any())).thenAnswer(i -> {
if (i.getArguments()[0].equals("494")) {
return group1;
}
return null;
});
}

@After
public void afterTest() {
System.out.println("after test");
}


@Test
public void testGetStudentsByGroup() throws Exception {
assertThat(groupStatistics.getStudentsByGroup().get("494"), is(2));

assertThat(groupStatistics.getStudentsByGroup().get("495"), is(2));
System.out.println(groupStatistics.getStudentsByGroup());
}

}
Loading