Fixes
This commit is contained in:
parent
710c7666dd
commit
00f2442397
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