This is the codeAbility Sharing Platform! Learn more about the codeAbility Sharing Platform.

Skip to content
Snippets Groups Projects
Commit 866c08ff authored by Michael Breu's avatar Michael Breu :speech_balloon:
Browse files

Test Coverage

parent 9d3458b5
Branches
Tags
2 merge requests!55June Release,!52Resolve "Extend Bookmarklists and implement stored searches"
......@@ -206,7 +206,7 @@ public class UserWatchListService {
findByUser(user).stream()
.filter(wl -> wl.getCheckFrequency() != CheckFrequency.NEVER)
.forEach(wl ->
metaDataRepository.getExercisesById(wl.getWatchListEntries().stream().map( (Function<WatchListEntry, String>) WatchListEntry::getExerciseId ) ,
metaDataRepository.getExercisesById(wl.getWatchListEntries().stream().map( WatchListEntry::getExerciseId ) ,
userService.convertToSecurityUser(Optional.of(user)), 0, 100, since).
getSearchResult().forEach(
sr -> {
......
......@@ -4,8 +4,6 @@ import java.util.Optional;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.userdetails.User;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
......@@ -14,7 +12,6 @@ import at.ac.uibk.gitsearch.security.jwt.TokenProvider;
import at.ac.uibk.gitsearch.service.MailService;
import at.ac.uibk.gitsearch.service.UserService;
import at.ac.uibk.gitsearch.service.dto.MessageDTO;
import at.ac.uibk.gitsearch.web.rest.AccountResource.AccountResourceException;
/**
* REST controller for various tests that can be initiated by the user.
......
......@@ -24,6 +24,7 @@ import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMock
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.MediaType;
import org.springframework.security.test.context.support.WithMockUser;
import org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.transaction.annotation.Transactional;
......@@ -528,5 +529,26 @@ public class UserWatchListResourceIT {
List<UserWatchList> userWatchListList = userWatchListRepository.findAll();
assertThat(userWatchListList).hasSize(databaseSizeBeforeDelete - 1);
}
@Test
@Transactional
public void createUserWatchListForCurrentUser() throws Exception {
final UserWatchListDTO userWatchListDTO = userWatchListMapper.toDto(userWatchList);
int databaseSizeBeforeCreate = userWatchListRepository.findAll().size();
// Delete the userWatchList
restUserWatchListMockMvc.perform(post("/api/currentuser-watch-lists", userWatchListDTO)
.with(SecurityMockMvcRequestPostProcessors.user(userWatchList.getUser().getLogin()))
.with(csrf().asHeader())
.accept(MediaType.APPLICATION_JSON)
.contentType(MediaType.APPLICATION_JSON)
.content(TestUtil.convertObjectToJsonBytes(userWatchListDTO)))
.andExpect(status().isCreated());
// Validate the database contains this watchlist
List<UserWatchList> userWatchListList = userWatchListRepository.findAll();
assertThat(userWatchListList).hasSize(databaseSizeBeforeCreate + 1);
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment