Search in sources :

Example 11 with SubjectEntity

use of easytests.core.entities.SubjectEntity in project easy-tests by malinink.

the class SubjectsMapperTest method testUpdate.

@Test
public void testUpdate() throws Exception {
    final Integer id = 2;
    final String name = "updated";
    final String description = "updated description";
    SubjectEntity subject = this.subjectsMapper.find(id);
    Assert.assertNotEquals(name, subject.getName());
    Assert.assertNotEquals(description, subject.getDescription());
    subject = Mockito.mock(SubjectEntity.class);
    Mockito.when(subject.getId()).thenReturn(id);
    Mockito.when(subject.getName()).thenReturn(name);
    Mockito.when(subject.getDescription()).thenReturn(description);
    this.subjectsMapper.update(subject);
    final SubjectEntity readSubject = subjectsMapper.find(id);
    Assert.assertEquals(name, readSubject.getName());
    Assert.assertEquals(description, readSubject.getDescription());
}
Also used : SubjectEntity(easytests.core.entities.SubjectEntity) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 12 with SubjectEntity

use of easytests.core.entities.SubjectEntity in project easy-tests by malinink.

the class SubjectsMapperTest method testInsert.

@Test
public void testInsert() throws Exception {
    final Integer id = this.subjectsMapper.findAll().size() + 1;
    final Integer testUserId = 1;
    final String testName = "test";
    final String testDescription = "testSubject.description";
    final SubjectEntity testSubject = Mockito.mock(SubjectEntity.class);
    Mockito.when(testSubject.getId()).thenReturn(id);
    Mockito.when(testSubject.getName()).thenReturn(testName);
    Mockito.when(testSubject.getDescription()).thenReturn(testDescription);
    Mockito.when(testSubject.getUserId()).thenReturn(testUserId);
    subjectsMapper.insert(testSubject);
    verify(testSubject, times(1)).setId(id);
    final SubjectEntity readSubject = subjectsMapper.find(testSubject.getId());
    Assert.assertNotNull(readSubject);
    Assert.assertEquals(testUserId, readSubject.getUserId());
    Assert.assertEquals(testName, readSubject.getName());
    Assert.assertEquals(testDescription, readSubject.getDescription());
}
Also used : SubjectEntity(easytests.core.entities.SubjectEntity) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 13 with SubjectEntity

use of easytests.core.entities.SubjectEntity in project easy-tests by malinink.

the class SubjectsMapperTest method testDelete.

@Test
public void testDelete() throws Exception {
    SubjectEntity subject = this.subjectsMapper.find(1);
    Assert.assertNotNull(subject);
    this.subjectsMapper.delete(subject);
    subject = this.subjectsMapper.find(1);
    Assert.assertNull(subject);
}
Also used : SubjectEntity(easytests.core.entities.SubjectEntity) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 14 with SubjectEntity

use of easytests.core.entities.SubjectEntity in project easy-tests by malinink.

the class SubjectsServiceTest method testSaveUpdateEntityIdOnCreation.

@Test
public void testSaveUpdateEntityIdOnCreation() throws Exception {
    final Integer id = 5;
    final SubjectModelInterface subjectModel = this.subjectsSupport.getModelAdditionalMock(0);
    doAnswer(invocation -> {
        final SubjectEntity subjectEntity = (SubjectEntity) invocation.getArguments()[0];
        subjectEntity.setId(id);
        return null;
    }).when(this.subjectsMapper).insert(any());
    this.subjectsService.save(subjectModel);
    verify(subjectModel, times(1)).setId(id);
}
Also used : SubjectEntity(easytests.core.entities.SubjectEntity) SubjectModelInterface(easytests.core.models.SubjectModelInterface)

Example 15 with SubjectEntity

use of easytests.core.entities.SubjectEntity in project easy-tests by malinink.

the class SubjectsSupport method assertEntitiesListEquals.

public void assertEntitiesListEquals(List<SubjectEntity> expected, List<SubjectEntity> actual) {
    Assert.assertEquals(expected.size(), actual.size());
    Integer i = 0;
    for (SubjectEntity subjectEntity : expected) {
        this.assertEquals(subjectEntity, actual.get(i));
        i++;
    }
}
Also used : SubjectEntity(easytests.core.entities.SubjectEntity)

Aggregations

SubjectEntity (easytests.core.entities.SubjectEntity)19 SubjectModelInterface (easytests.core.models.SubjectModelInterface)7 Test (org.junit.Test)7 ArrayList (java.util.ArrayList)4 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)4 UserModelInterface (easytests.core.models.UserModelInterface)3 SubjectsOptionsInterface (easytests.core.options.SubjectsOptionsInterface)3 IssueStandardModelEmpty (easytests.core.models.empty.IssueStandardModelEmpty)1 ModelsListEmpty (easytests.core.models.empty.ModelsListEmpty)1 UserModelEmpty (easytests.core.models.empty.UserModelEmpty)1