-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
84a2179
commit da64a43
Showing
6 changed files
with
106 additions
and
15 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
...lan-nbi/src/main/java/global/packet/magellan/controller/ApplicationServiceController.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package global.packet.magellan.controller; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import global.packet.magellan.service.ApplicationService; | ||
|
||
//import com.wordnik.swagger.annotations.ApiOperation; | ||
//import com.wordnik.swagger.annotations.ApiResponse; | ||
//import com.wordnik.swagger.annotations.ApiResponses; | ||
|
||
@RestController | ||
@RequestMapping("/app") | ||
public class ApplicationServiceController { | ||
|
||
@Autowired | ||
ApplicationService applicationService; | ||
|
||
//@GET | ||
//@Path("/health") | ||
//@Produces(MediaType.TEXT_HTML) | ||
//@RequestMapping("/test") | ||
/*@ApiOperation(value="health check", notes="health check for auto scaling") | ||
@ApiResponses (value= { | ||
@ApiResponse(code=200, message="OK - success"), | ||
@ApiResponse(code=400, message="Bad Request"), | ||
@ApiResponse(code=401, message="Unauthorized"), | ||
@ApiResponse(code=403, message="Forbidden"), | ||
@ApiResponse(code=404, message="NotFound"), | ||
@ApiResponse(code=409, message="Conflict"), | ||
@ApiResponse(code=500, message="Internal Server Error") | ||
})*/ | ||
@GetMapping("/health") | ||
public String getHealth() { | ||
return applicationService.health().toString(); | ||
} | ||
|
||
} |
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
6 changes: 6 additions & 0 deletions
6
magellan-nbi/src/main/java/global/packet/magellan/service/ForwardingService.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package global.packet.magellan.service; | ||
|
||
public interface ForwardingService { | ||
|
||
String forward(); | ||
} |
14 changes: 14 additions & 0 deletions
14
magellan-nbi/src/main/java/global/packet/magellan/service/ForwardingServiceImpl.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package global.packet.magellan.service; | ||
|
||
import org.springframework.stereotype.Component; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
public class ForwardingServiceImpl implements ForwardingService { | ||
|
||
@Override | ||
public String forward() { | ||
return "OK"; | ||
} | ||
|
||
} |
39 changes: 39 additions & 0 deletions
39
magellan-nbi/src/test/java/global/packet/magellan/ApplicationServiceControllerTest.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package global.packet.magellan; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.mockito.InjectMocks; | ||
import org.mockito.Mockito; | ||
import org.mockito.MockitoAnnotations; | ||
|
||
import global.packet.magellan.controller.ApplicationServiceController; | ||
|
||
public class ApplicationServiceControllerTest { | ||
// controller is unmocked, but service bean inside is mocked | ||
private @InjectMocks ApplicationServiceController controller | ||
= Mockito.mock(ApplicationServiceController.class); | ||
// if controller is InjectMocked then Mock service bean will be injected | ||
//@Mock ForwardingController controller; | ||
|
||
@Before | ||
public void setup() { | ||
MockitoAnnotations.initMocks(this); | ||
} | ||
|
||
@Test | ||
public void testForwardRequest() { | ||
String expected = "ok"; | ||
Mockito.when(controller.getHealth()) | ||
.thenReturn(expected); | ||
String response = controller.getHealth(); | ||
Assertions.assertNotNull(response); | ||
Assert.assertEquals(expected, response); | ||
} | ||
|
||
|
||
} | ||
|
||
|
||
|
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