Skip to content

Commit c1d6ad4

Browse files
ddamkeddamke
authored andcommitted
updated dependency and deleted deprecated test imports
1 parent 2852622 commit c1d6ad4

File tree

5 files changed

+66
-68
lines changed

5 files changed

+66
-68
lines changed

pom.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
<dependency>
5252
<groupId>org.springframework.boot</groupId>
5353
<artifactId>spring-boot-starter-data-jpa</artifactId>
54+
<version>2.7.4</version>
5455
</dependency>
5556

5657
<dependency>
@@ -61,6 +62,7 @@
6162
<dependency>
6263
<groupId>org.springframework.boot</groupId>
6364
<artifactId>spring-boot-starter-test</artifactId>
65+
<version>2.7.4</version>
6466
<scope>test</scope>
6567
</dependency>
6668

src/test/java/de/doubleslash/keeptime/common/DateFormatterTest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@
1616

1717
package de.doubleslash.keeptime.common;
1818

19-
import static org.junit.Assert.assertThat;
20-
2119
import java.time.LocalDateTime;
2220

2321
import org.hamcrest.Matchers;
24-
import org.junit.Ignore;
25-
import org.junit.Test;
22+
import org.junit.jupiter.api.Disabled;
23+
import org.junit.jupiter.api.Test;
24+
25+
import static org.junit.jupiter.api.Assertions.assertEquals;
2626

27-
@Ignore
27+
@Disabled
2828
public class DateFormatterTest {
2929

3030
@Test
@@ -33,9 +33,9 @@ public void zeroSecondsBetweenTest() {
3333
final LocalDateTime endDate = startDate.plusNanos(10000);
3434

3535
final long secondsBewtween = DateFormatter.getSecondsBewtween(startDate, endDate);
36-
assertThat(secondsBewtween, Matchers.is(0l));
36+
assertEquals(secondsBewtween, Matchers.is(0l));
3737

3838
final long secondsBewtweenSwitched = DateFormatter.getSecondsBewtween(endDate, startDate);
39-
assertThat(secondsBewtweenSwitched, Matchers.is(0l)); // why??
39+
assertEquals(secondsBewtweenSwitched, Matchers.is(0l)); // why??
4040
}
4141
}

src/test/java/de/doubleslash/keeptime/controller/ControllerTest.java

Lines changed: 47 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,20 @@
1717
package de.doubleslash.keeptime.controller;
1818

1919
import static org.hamcrest.Matchers.contains;
20-
import static org.hamcrest.Matchers.equalTo;
21-
import static org.hamcrest.Matchers.is;
22-
import static org.hamcrest.Matchers.not;
23-
import static org.junit.Assert.assertEquals;
24-
import static org.junit.Assert.assertThat;
25-
import static org.junit.Assert.assertTrue;
20+
import static org.junit.jupiter.api.Assertions.assertEquals;
21+
import static org.junit.jupiter.api.Assertions.assertNotEquals;
22+
2623

2724
import java.time.LocalDateTime;
2825
import java.util.ArrayList;
2926
import java.util.Arrays;
3027
import java.util.List;
3128
import java.util.concurrent.TimeUnit;
3229

33-
import org.hamcrest.Matchers;
34-
import org.junit.Before;
35-
import org.junit.Test;
30+
31+
import org.junit.jupiter.api.Assertions;
32+
import org.junit.jupiter.api.BeforeEach;
33+
import org.junit.jupiter.api.Test;
3634
import org.mockito.ArgumentCaptor;
3735
import org.mockito.Mockito;
3836
import org.springframework.test.util.ReflectionTestUtils;
@@ -55,8 +53,8 @@ public class ControllerTest {
5553

5654
private WorkRepository mockedWorkRepository;
5755

58-
@Before
59-
public void beforeTest() {
56+
@BeforeEach
57+
void beforeTest() {
6058
mockedWorkRepository = Mockito.mock(WorkRepository.class);
6159
model = new Model(Mockito.mock(ProjectRepository.class), mockedWorkRepository,
6260
Mockito.mock(SettingsRepository.class));
@@ -87,7 +85,7 @@ public void moveProjectFromEndToStart() {
8785
testee.resortProjectIndexes(projectList, project3, oldIndex, newIndex);
8886

8987
for (int i = 0; i < projectList.size(); i++) {
90-
assertThat(projectList.get(i).getIndex(), Matchers.is(expectedOrderAfter.get(i)));
88+
assertEquals(projectList.get(i).getIndex(), expectedOrderAfter.get(i));
9189
}
9290

9391
}
@@ -114,7 +112,7 @@ public void moveProjectFromStartToEnd() {
114112
testee.resortProjectIndexes(projectList, project0, oldIndex, newIndex);
115113

116114
for (int i = 0; i < projectList.size(); i++) {
117-
assertThat(projectList.get(i).getIndex(), Matchers.is(expectedOrderAfter.get(i)));
115+
assertEquals(projectList.get(i).getIndex(), expectedOrderAfter.get(i));
118116
}
119117

120118
}
@@ -141,7 +139,7 @@ public void moveProjectForward() {
141139
testee.resortProjectIndexes(projectList, project1, oldIndex, newIndex);
142140

143141
for (int i = 0; i < projectList.size(); i++) {
144-
assertThat(projectList.get(i).getIndex(), Matchers.is(expectedOrderAfter.get(i)));
142+
assertEquals(projectList.get(i).getIndex(), expectedOrderAfter.get(i));
145143
}
146144

147145
}
@@ -168,7 +166,7 @@ public void moveProjectBackward() {
168166
testee.resortProjectIndexes(projectList, project2, oldIndex, newIndex);
169167

170168
for (int i = 0; i < projectList.size(); i++) {
171-
assertThat(projectList.get(i).getIndex(), is(expectedOrderAfter.get(i)));
169+
assertEquals(projectList.get(i).getIndex(), expectedOrderAfter.get(i));
172170
}
173171
}
174172

@@ -193,7 +191,7 @@ public void dontMoveProjectTest() {
193191
}
194192

195193
for (int i = 0; i < projectList.size(); i++) {
196-
assertThat(projectList.get(i).getIndex(), is(expectedOrderAfter.get(i)));
194+
assertEquals(projectList.get(i).getIndex(), expectedOrderAfter.get(i));
197195
}
198196
}
199197

@@ -221,11 +219,11 @@ public void changeProjectSameDayTest() {
221219
}
222220
return true;
223221
}));
224-
assertThat("Two project should be in the past work items", model.getPastWorkItems().size(), is(2));
225-
assertThat("The first project should be the past work project", model.getPastWorkItems().get(0).getProject(),
226-
is(firstProject));
227-
assertThat("The second project should be the active work project", model.activeWorkItem.get().getProject(),
228-
is(secondProject));
222+
assertEquals(model.getPastWorkItems().size(), 2, "Two project should be in the past work items");
223+
assertEquals( model.getPastWorkItems().get(0).getProject(),
224+
firstProject, "The first project should be the past work project");
225+
assertEquals(model.activeWorkItem.get().getProject(),
226+
secondProject, "The second project should be the active work project");
229227
}
230228

231229
@Test
@@ -253,11 +251,11 @@ public void changeProjectOtherDayTest() {
253251
}
254252
return true;
255253
}));
256-
assertThat("'2nd project' should be in the past work items", model.getPastWorkItems().size(), is(1));
257-
assertThat("The project should be '2ndProject'", model.getPastWorkItems().get(0).getProject(),
258-
is(secondProject));
259-
assertThat("'2ndProject' should be the active work project", model.activeWorkItem.get().getProject(),
260-
is(secondProject));
254+
assertEquals( model.getPastWorkItems().size(), 1 , "'2nd project' should be in the past work items");
255+
assertEquals(model.getPastWorkItems().get(0).getProject(),
256+
secondProject, "The project should be '2ndProject'");
257+
assertEquals(model.activeWorkItem.get().getProject(),
258+
secondProject, "'2ndProject' should be the active work project");
261259
}
262260

263261
@Test
@@ -286,15 +284,15 @@ public void changeProjectOtherDayWithTimeTest() {
286284
return true;
287285
}));
288286

289-
assertThat("Two projects should be in the past work items", model.getPastWorkItems().size(), is(2));
290-
assertThat("The first project should be '1st Project'", model.getPastWorkItems().get(0).getProject(),
291-
is(firstProject));
292-
assertThat("The second project should be '2ndProject'", model.getPastWorkItems().get(1).getProject(),
293-
is(secondProject));
287+
assertEquals( model.getPastWorkItems().size(), 2, "Two projects should be in the past work items");
288+
assertEquals( model.getPastWorkItems().get(0).getProject(),
289+
firstProject, "The first project should be '1st Project'");
290+
assertEquals( model.getPastWorkItems().get(1).getProject(),
291+
secondProject , "The second project should be '2ndProject'");
294292
final Work work = model.activeWorkItem.get();
295-
assertThat("'2ndProject' should be the active work project", work.getProject(), is(secondProject));
296-
assertThat(work.getStartTime().toLocalDate(), is(firstProjectDateTime.toLocalDate()));
297-
assertThat(work.getStartTime(), is(firstProjectPlusOneHour));
293+
assertEquals(work.getProject(), secondProject , "'2ndProject' should be the active work project");
294+
assertEquals(work.getStartTime().toLocalDate(), firstProjectDateTime.toLocalDate());
295+
assertEquals(work.getStartTime(), firstProjectPlusOneHour);
298296
}
299297

300298
@Test
@@ -318,10 +316,10 @@ public void shouldCalculateSecondsCorrectlyWhenWorkItemsAreGiven() {
318316
model.getPastWorkItems().addAll(workItems);
319317

320318
final long totalSeconds = testee.calcSeconds(workItems);
321-
assertEquals("Seconds were not calculated correctly.", TimeUnit.HOURS.toSeconds(4), totalSeconds);
319+
assertEquals(TimeUnit.HOURS.toSeconds(4), totalSeconds , "Seconds were not calculated correctly.");
322320

323321
final long todaysSeconds = testee.calcTodaysSeconds();
324-
assertEquals("Todays seconds were not calulated correctly.", TimeUnit.HOURS.toSeconds(4), todaysSeconds);
322+
assertEquals(TimeUnit.HOURS.toSeconds(4), todaysSeconds,"Todays seconds were not calulated correctly.");
325323

326324
// final long todaysWorkSeconds = testee.calcTodaysWorkSeconds();
327325
// assertEquals("Todays work seconds were not calculated correctly.",TimeUnit.HOURS.toSeconds(2),
@@ -351,14 +349,15 @@ public void shouldUpdateWorkItemPersistentlyWhenWorkItemIsEdited() {
351349
testee.editWork(originalWork, newWork);
352350

353351
final Work testWork = model.getPastWorkItems().get(0);
354-
assertThat("Start time was not updated", testWork.getStartTime(), equalTo(newWork.getStartTime()));
355-
assertThat("End timewas not updated", testWork.getEndTime(), equalTo(newWork.getEndTime()));
356-
assertThat("Notes were not updated", testWork.getNotes(), equalTo(newWork.getNotes()));
357-
assertThat("Project was not updated", testWork.getProject(), equalTo(newWork.getProject()));
352+
353+
assertEquals(testWork.getStartTime(), newWork.getStartTime(),"Start time was not updated");
354+
assertEquals(testWork.getEndTime(), newWork.getEndTime(), "End timewas not updated");
355+
assertEquals(testWork.getNotes(), newWork.getNotes(),"Notes were not updated");
356+
assertEquals(testWork.getProject(), newWork.getProject(),"Project was not updated");
358357

359358
final ArgumentCaptor<Work> argument = ArgumentCaptor.forClass(Work.class);
360359
Mockito.verify(mockedWorkRepository, Mockito.times(1)).save(argument.capture());
361-
assertThat("Edited work was not saved persistently", argument.getValue(), is(originalWork));
360+
assertEquals(argument.getValue(), originalWork,"Edited work was not saved persistently");
362361

363362
}
364363

@@ -389,14 +388,14 @@ public void shouldNotUpdateOthersWhenWorkItemIsEdited() {
389388

390389
testee.editWork(originalWork, newWork);
391390

392-
assertThat("Too many or too less work items in past work items", model.getPastWorkItems().size(), equalTo(2));
393-
assertThat("Work with new values in past work items instead of updatd work", model.getPastWorkItems(),
394-
not(contains(newWork)));
391+
assertEquals( 2, model.getPastWorkItems().size(),"Too many or too less work items in past work items");
392+
assertNotEquals(model.getPastWorkItems(),
393+
contains(newWork),"Work with new values in past work items instead of updatd work");
395394

396395
final ArgumentCaptor<Work> argument = ArgumentCaptor.forClass(Work.class);
397396
Mockito.verify(mockedWorkRepository, Mockito.times(1)).save(argument.capture());
398-
assertThat("Saved other Work persistently than what should be edited", argument.getValue(),
399-
not(is(notToBeUpdatedWork)));
397+
assertNotEquals(argument.getValue(),
398+
notToBeUpdatedWork, "Saved other Work persistently than what should be edited");
400399

401400
}
402401

@@ -416,7 +415,7 @@ public void shouldDeleteWorkPersistentlyWhenWorkIsDeleted() {
416415

417416
final ArgumentCaptor<Work> argument = ArgumentCaptor.forClass(Work.class);
418417
Mockito.verify(mockedWorkRepository, Mockito.times(1)).delete(argument.capture());
419-
assertThat("Edited work was not deleted persistently", argument.getValue(), is(work));
418+
assertEquals(argument.getValue(), work,"Edited work was not deleted persistently");
420419

421420
}
422421

@@ -433,8 +432,7 @@ public void shouldRemoveWorkFromPastWorkItemsWhenWorkIsDeleted() {
433432
model.getPastWorkItems().add(work);
434433

435434
testee.deleteWork(work);
436-
437-
assertTrue("work Items contain work when it should have been deleted", model.getPastWorkItems().isEmpty());
435+
Assertions.assertTrue(model.getPastWorkItems().isEmpty(),"work Items contain work when it should have been deleted");
438436

439437
}
440438

src/test/java/de/doubleslash/keeptime/view/ProjectReportTest.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,15 @@
1515
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1616

1717
package de.doubleslash.keeptime.view;
18-
19-
import static org.junit.Assert.assertEquals;
20-
2118
import java.lang.invoke.MethodHandles;
2219

23-
import org.junit.Before;
24-
import org.junit.Test;
20+
import org.junit.jupiter.api.BeforeEach;
21+
import org.junit.jupiter.api.Test;
2522
import org.slf4j.Logger;
2623
import org.slf4j.LoggerFactory;
2724

25+
import static org.junit.jupiter.api.Assertions.assertEquals;
26+
2827
public class ProjectReportTest {
2928

3029
/** The slf4j-logger for this class. */
@@ -34,8 +33,8 @@ public class ProjectReportTest {
3433

3534
private ProjectReport uut;
3635

37-
@Before
38-
public void setUp() throws Exception {
36+
@BeforeEach
37+
void setUp(){
3938
this.uut = new ProjectReport(3);
4039
}
4140

src/test/java/de/doubleslash/keeptime/view/ProjectsListViewControllerTest.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616

1717
package de.doubleslash.keeptime.view;
1818

19-
import static org.junit.Assert.assertFalse;
20-
import static org.junit.Assert.assertTrue;
21-
22-
import org.junit.Test;
2319

2420
import de.doubleslash.keeptime.model.Project;
21+
import org.junit.jupiter.api.Test;
22+
23+
import static org.junit.jupiter.api.Assertions.assertFalse;
24+
import static org.junit.jupiter.api.Assertions.assertTrue;
2525

2626
public class ProjectsListViewControllerTest {
2727

@@ -81,7 +81,6 @@ public void shouldNotMatchWhenDescriptionAndNameAreNotMatching() {
8181

8282
project.setName("MyNameIsJohn");
8383
project.setDescription("I am a project.");
84-
8584
assertFalse(ProjectsListViewController.doesProjectMatchSearchFilter("Hellow world", project));
8685
}
8786

0 commit comments

Comments
 (0)