This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class JsonArgumentsProvider implements ArgumentsProvider, AnnotationConsumer { | |
private String[] values; | |
private Class<?> type; | |
@Override | |
public void accept(final JsonSource annotation) { | |
values = annotation.value(); | |
type = annotation.type(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ParameterizedTest | |
@JsonSource(value = "{firstname:'Jane', lastname: 'Doe'}", type = Person.class) | |
void jsonSourceTest(Person param) { | |
System.out.println(param); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Entity | |
@Table(name="city") | |
internal data class CityEntity( | |
@Id val id: Long? = null, | |
val name: String, | |
val description: String? = null) { | |
fun toDto(): CityDto = CityDto( | |
id = this.id!!, | |
name = this.name, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Transactional(Transactional.TxType.MANDATORY) | |
internal interface CityRepository : JpaRepository<CityEntity, Long> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface CityService { | |
fun retrieveCity(cityId: Long): CityDto? | |
fun retrieveCities(): List<CityDto> | |
fun addCity(city: CreateCityDto): CityDto | |
fun updateCity(id: Long, city: UpdateCityDto): CityDto | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Service | |
@Transactional | |
internal class JpaCityService(val cityRepo: CityRepository) : CityService { | |
override fun retrieveCity(cityId: Long) : CityDto? { | |
return cityRepo.findOne(cityId)?.toDto() | |
} | |
override fun retrieveCities() : List<CityDto> { | |
return cityRepo.findAll().map { it.toDto() } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RunWith(SpringRunner::class) | |
@ContextConfiguration(classes = arrayOf(CityConfig::class)) | |
@DataJpaTest | |
internal class JpaCityServiceTest { | |
@Autowired | |
lateinit var service: CityService | |
@Autowired | |
lateinit var repository: CityRepository |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=Additional drive | |
[Mount] | |
What=/dev/disk/by-uuid/6080-1BC0 | |
Where=/media/backup | |
Type=exfat | |
Options=defaults | |
[Install] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=Automount USB Backup | |
[Automount] | |
Where=/media/backup | |
[Install] | |
WantedBy=multi-user.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=backup the vaultwarden sqlite database and attachments | |
[Service] | |
Type=oneshot | |
WorkingDirectory=/media/backup | |
ExecStart=/usr/bin/env sh -c 'sqlite3 /home/pi/bw-data//db.sqlite3 ".backup backup-$(date -Is | tr : _).sq3"' | |
ExecStart=/usr/bin/env sh -c 'tar cvfz bw-attachments-$(date -Is | tr : _).tar.gz /home/pi/bw-data/attachments/' | |
ExecStart=/usr/bin/find . -type f -mtime +30 -name 'backup*' -delete | |
ExecStart=/usr/bin/find . -type f -mtime +30 -name 'bw-attachments*' -delete |