Skip to content

Commit

Permalink
Unit tests cleanup #79
Browse files Browse the repository at this point in the history
  • Loading branch information
tillias committed Nov 2, 2020
1 parent 3adf1ea commit 714e4df
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
18 changes: 18 additions & 0 deletions src/test/java/com/github/microcatalog/MockMvcWithUser.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.github.microcatalog;

import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureWebMvc;
import org.springframework.security.test.context.support.WithMockUser;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@AutoConfigureWebMvc
@AutoConfigureMockMvc
@WithMockUser
public @interface MockMvcWithUser {
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package com.github.microcatalog.web.rest.custom;

import com.github.microcatalog.MockMvcWithUser;
import com.github.microcatalog.domain.custom.impact.analysis.Result;
import com.github.microcatalog.service.custom.ImpactAnalysisService;
import com.github.microcatalog.utils.MicroserviceBuilder;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureWebMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.http.MediaType;
Expand All @@ -18,9 +20,8 @@
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;

@SpringBootTest
@AutoConfigureMockMvc
@WithMockUser
@SpringBootTest(classes = ImpactAnalysisCustomResource.class)
@MockMvcWithUser
class ImpactAnalysisCustomResourceTest {

@Autowired
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
package com.github.microcatalog.web.rest.custom;

import com.github.microcatalog.MockMvcWithUser;
import com.github.microcatalog.domain.custom.ReleasePath;
import com.github.microcatalog.service.custom.ReleasePathCustomService;
import com.github.microcatalog.utils.MicroserviceBuilder;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.http.MediaType;
import org.springframework.security.test.context.support.WithMockUser;
import org.springframework.test.web.servlet.MockMvc;

import java.util.Optional;

import static org.mockito.BDDMockito.given;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;

@SpringBootTest
@AutoConfigureMockMvc
@WithMockUser
@SpringBootTest(classes = ReleasePathCustomResource.class)
@MockMvcWithUser
class ReleasePathCustomResourceTest {

@Autowired
Expand Down

0 comments on commit 714e4df

Please sign in to comment.