Skip to content

Instantly share code, notes, and snippets.

View larsgroeber's full-sized avatar

Lars Gröber larsgroeber

View GitHub Profile
@MockBean
private lateinit var mailSenderProxy: MailSenderProxyService;
@Test
@WithMockUser(authorities = ["SEND_MAIL"])
@Throws(Exception::class)
fun shouldSendMail() {
val mockMessage = mock(MimeMessage::class.java)
Mockito.`when`(mailSenderProxy.createMimeMessage()).thenReturn(mockMessage)
val builder = MockMvcRequestBuilders.multipart("/email/sendMail")
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@AutoConfigureMockMvc
@TestPropertySource(locations = ["classpath:application-integration-tests.properties"])
class EmailApiIntegrationTests : IntegrationTestBase() {
...
}
@PreAuthorize("@authorizationService.hasPermission('SEND_MAIL', authentication)")
@Override
public void sendMail(SendMailRequest request) {
MimeMessage message = makeMessage(request);
addEmailLog(request);
sendMessage(message);
}
@RestController
@RequestMapping("/email")
public class EmailApiController {
private final EmailService emailService;
public EmailApiController(EmailService emailService) {
this.emailService = emailService;
}
...
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.1.0</version>
@larsgroeber
larsgroeber / anagram_finder.cpp
Created October 6, 2017 14:20
Small anagram finder in c++. Generates a hash table from a dictionary file of words.
/**
* \author Lars Gröber
*/
#include <iostream>
#include <fstream>
#include <vector>
#include <unordered_map>
#include <thread>
#include <map>
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Folder Include="wwwroot\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.3" />
#!/bin/bash
#
# This script watches the local folder for files with the ending in 'file_endings'
# and uploads them to a server specified in 'server'.
#
server_name="" # include login name if necessary
target_directory=""
@larsgroeber
larsgroeber / spamMail.sh
Last active January 28, 2021 20:14
Small bash script for sending spam mails using mutt
#! /usr/bin/env bash
#
# small script to send spam mails using mutt (excercise project for a course)
# @author: Lars Groeber
#
# Usage:
# SCRIPTNAME [-T %Y%m%d%H%M] [-t timeInterval-in-min] [-m maxMails]
# (-s subject,email,body) | (-f subject,file-with-emails,body)
#
#! /bin/gnuplot
set terminal wxt size 350,262 enhanced font 'Verdana,10' persist
# set terminal dumb
file="`echo $plot_file`" # make sure to set the $plot_file environment variable first
f(x) = a*x+b
a = 1
b = 1
fit f(x) file via a,b