Merge branch 'tests' into 'dev'
Fixes See merge request sa4-2020/the-sanmarinoes/backend!181
This commit is contained in:
commit
fa7fe5e8be
3 changed files with 63 additions and 0 deletions
|
@ -0,0 +1,15 @@
|
|||
package ch.usi.inf.sa4.sanmarinoes.smarthut.config;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class CameraConfigurationServiceTests {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
final CameraConfigurationService c = new CameraConfigurationService();
|
||||
c.setVideoUrl("cose");
|
||||
assertThat(c.getVideoUrl()).isEqualTo("cose");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package ch.usi.inf.sa4.sanmarinoes.smarthut.models;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
public class InputDeviceTests {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
final InputDevice motionSensor = new MotionSensor();
|
||||
assertThat(motionSensor.getOutputs()).isEmpty();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package ch.usi.inf.sa4.sanmarinoes.smarthut.service;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import ch.usi.inf.sa4.sanmarinoes.smarthut.models.User;
|
||||
import ch.usi.inf.sa4.sanmarinoes.smarthut.models.UserRepository;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
||||
|
||||
@ExtendWith({MockitoExtension.class})
|
||||
public class JWTUserDetailsServiceTests {
|
||||
|
||||
@InjectMocks private JWTUserDetailsService jwtUserDetailsService;
|
||||
|
||||
@Mock private UserRepository userRepository;
|
||||
|
||||
@Test
|
||||
public void testLoadByUsername() {
|
||||
final User u = new User();
|
||||
u.setUsername("username");
|
||||
u.setPassword("password");
|
||||
when(userRepository.findByUsername("username")).thenReturn(u);
|
||||
assertThatThrownBy(() -> jwtUserDetailsService.loadUserByUsername("username"))
|
||||
.isInstanceOf(UsernameNotFoundException.class);
|
||||
u.setEnabled(true);
|
||||
assertThat(jwtUserDetailsService.loadUserByUsername("username")).isNotNull();
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue