Skip to content

Commit

Permalink
feat: increase coverage and revision
Browse files Browse the repository at this point in the history
  • Loading branch information
gb-cic committed Dec 21, 2023
1 parent 37f4164 commit 33fe15d
Show file tree
Hide file tree
Showing 9 changed files with 128 additions and 113 deletions.
6 changes: 0 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,6 @@
<scope>test</scope>
</dependency>

<!-- GSON -->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-sleuth</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,24 @@
*/
package it.finanze.sanita.fse2.ms.gtw.statusmanager.controller;

import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import it.finanze.sanita.fse2.ms.gtw.statusmanager.dto.SchedulerResDTO;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;


public interface ISchedulerActionCTL {


@PostMapping("/v1/runStatusScheduler")
@Operation(summary = "Run status scheduler", description = "Run scheduler.")
@ApiResponse(content = @Content(mediaType = MediaType.APPLICATION_PROBLEM_JSON_VALUE, schema = @Schema(implementation = SchedulerResDTO.class)))
@ApiResponse(content = @Content(mediaType = MediaType.APPLICATION_PROBLEM_JSON_VALUE))
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Scheduler startato", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = void.class))),
@ApiResponse(responseCode = "500", description = "Internal Server Error", content = @Content(mediaType = MediaType.APPLICATION_PROBLEM_JSON_VALUE)) })
@ApiResponse(responseCode = "200", description = "Scheduler started"),
@ApiResponse(responseCode = "500", description = "Internal Server Error", content = @Content(mediaType = MediaType.APPLICATION_PROBLEM_JSON_VALUE))
})
void runSchedulerAction();

}
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
*/
package it.finanze.sanita.fse2.ms.gtw.statusmanager.utility;

import com.google.gson.Gson;

public final class StringUtility {

/**
Expand All @@ -21,16 +19,6 @@ public final class StringUtility {
private StringUtility() {
// Constructor intentionally empty.
}

/**
* Transformation from Object to Json.
*
* @param obj object to transform
* @return json
*/
public static String toJSON(final Object obj) {
return new Gson().toJson(obj);
}

/**
* Returns {@code true} if the String passed as parameter is null or empty.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package it.finanze.sanita.fse2.ms.gtw.statusmanager;

import it.finanze.sanita.fse2.ms.gtw.statusmanager.config.Constants;
import it.finanze.sanita.fse2.ms.gtw.statusmanager.enums.ConfigItemTypeEnum;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;

import java.util.List;

import static org.junit.jupiter.api.Assertions.assertEquals;

@SpringBootTest
@ActiveProfiles(Constants.Profile.TEST)

@Slf4j
public class ConfigItemTypeEnumTest {

@Test
public void testPriority() {
// Call the priority method
List<ConfigItemTypeEnum> items = ConfigItemTypeEnum.priority();

// Assert that the first item is GENERIC
assertEquals(ConfigItemTypeEnum.GENERIC, items.get(0));

// Assert that the last item is GARBAGE
assertEquals(ConfigItemTypeEnum.STATUS_MANAGER, items.get(items.size() - 1));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package it.finanze.sanita.fse2.ms.gtw.statusmanager;

import it.finanze.sanita.fse2.ms.gtw.statusmanager.config.Constants;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
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.http.MediaType;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.web.servlet.MockMvc;

import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
@ActiveProfiles(Constants.Profile.TEST)
@AutoConfigureMockMvc
public class LivenessCheckCTLTest {

@Autowired
MockMvc mockMvc;

@Test
public void testHealthCheck() throws Exception {
mockMvc.perform(
get("/status")
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk()
);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package it.finanze.sanita.fse2.ms.gtw.statusmanager;

import it.finanze.sanita.fse2.ms.gtw.statusmanager.config.Constants;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInstance;
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.http.MediaType;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.web.servlet.MockMvc;

import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;

@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
@ActiveProfiles(Constants.Profile.TEST)
@AutoConfigureMockMvc
public class SchedulerActionCTLTest {

@Autowired
MockMvc mockMvc;

@Test
public void testRunSchedulerAction404() throws Exception {
mockMvc.perform(post("/v1/runStatusScheduler")
.contentType(MediaType.APPLICATION_JSON)
.accept(MediaType.APPLICATION_JSON));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package it.finanze.sanita.fse2.ms.gtw.statusmanager;

import it.finanze.sanita.fse2.ms.gtw.statusmanager.config.Constants;
import it.finanze.sanita.fse2.ms.gtw.statusmanager.utility.StringUtility;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit.jupiter.SpringExtension;

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

@SpringBootTest
@ActiveProfiles(Constants.Profile.TEST)
@Slf4j
@ExtendWith(SpringExtension.class)
public class StringUtilityTest {
@Test
void testIsNullOrEmpty(){
assertTrue(StringUtility.isNullOrEmpty(null));
assertTrue(StringUtility.isNullOrEmpty(""));
assertFalse(StringUtility.isNullOrEmpty("Test"));
}
}

0 comments on commit 33fe15d

Please sign in to comment.