How to get Bash version number in Mac OS
Following command can be used to know the bash version in Mac OS.
package com.bootng.display;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
public class DisplayCustomNameTest {
@Test
public void test_if_it_will_rain() {
}
@Test
public void test_if_it_will_be_cloudy() {
}
@Test
public void test_if_it_will_be_sunny() {
}
}
package com.bootng.display;
@DisplayName("Vacation Weather Test")
public class DisplayCustNameTest {
@DisplayName("🌧")
@Test
public void test_if_it_will_rain() {
}
@DisplayName("🌨")
@Test
public void test_if_it_will_be_cloudy() {
}
@DisplayName("🌞")
@Test
public void test_if_it_will_be_sunny() {
}
}
package com.bootng.display;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
@DisplayName("Weather Test DisplayExample ")
@DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class)
public class DisplayGeneratorExampleTest {
@Test
public void test_if_it_will_rain() {
}
@Test
public void test_if_it_will_be_cloudy() {
}
@Test
public void test_if_it_will_be_sunny() {
}
}
[^\x00-\x7F]
public int fib(int n) {
if (n == 0)
return 0;
else if (n == 1)
return 1;
else
return fib(n - 1) + fib(n - 2);
}
public static int fib_topdown(int n, int td[]) {
if (td[n] != 0 && n != 0)
return td[n];
else if (n == 0)
td[n] = 0;
else if (n == 1)
td[n] = 1;
else
td[n] = fib_topdown(n - 1, td) + fib_topdown(n - 2, td);
return td[n];
}
public static int fib_bottomup(int n) {
if (n < 2)
return n;
int f0 = 0;
int f1 = 1;
int f2 = 0;
for (int i = 2; i <= n; i++) {
f2 = f0 + f1;
f0 = f1;
f1 = f2;
}
return f2;
}
mvn install -DskipTests
Following article is a very good one explaining the Gaussian Mixture model along with python code.
https://towardsdatascience.com/gaussian-mixture-models-explained-6986aaf5a95
<!-- swagger ui -->
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>1.5.10</version>
</dependency>
http://localhost:8080/swagger-ui/index.html
{
"openapi":"3.0.1",
"info":{
"title":"OpenAPI definition",
"version":"v0"
},
"servers":[
{
"url":"http://localhost:8080",
"description":"Generated server url"
}
],
"paths":{
"/blogapi/v2/blogs":{
"get":{
"tags":[
"blog-controller-v-2"
],
"operationId":"getBlogStories",
"responses":{
"200":{
"description":"OK",
"content":{
"application/json":{
"schema":{
"type":"array",
"items":{
"$ref":"#/components/schemas/BlogStory"
}
}
}
}
}
}
},
"post":{
"tags":[
"blog-controller-v-2"
],
"operationId":"addBlogStory",
"requestBody":{
"content":{
"application/json":{
"schema":{
"$ref":"#/components/schemas/BlogStory"
}
}
},
"required":true
},
"responses":{
"200":{
"description":"OK",
"content":{
"application/json":{
"schema":{
"$ref":"#/components/schemas/BlogStory"
}
}
}
}
}
}
},
"/blogapi/v1/categories":{
"get":{
"tags":[
"category-controller"
],
"operationId":"getBlogCats",
"responses":{
"200":{
"description":"OK",
"content":{
"application/json":{
"schema":{
"type":"array",
"items":{
"$ref":"#/components/schemas/BlogCategory"
}
}
}
}
}
}
},
"post":{
"tags":[
"category-controller"
],
"operationId":"addCats",
"requestBody":{
"content":{
"application/json":{
"schema":{
"$ref":"#/components/schemas/BlogCategory"
}
}
},
"required":true
},
"responses":{
"200":{
"description":"OK",
"content":{
"application/json":{
"schema":{
"$ref":"#/components/schemas/BlogCategory"
}
}
}
}
}
}
},
"/blogapi/v2/blogs/{id}":{
"get":{
"tags":[
"blog-controller-v-2"
],
"operationId":"getBlogStory",
"parameters":[
{
"name":"id",
"in":"path",
"required":true,
"schema":{
"type":"string"
}
}
],
"responses":{
"200":{
"description":"OK",
"content":{
"application/json":{
"schema":{
"$ref":"#/components/schemas/BlogStory"
}
}
}
}
}
}
}
},
"components":{
"schemas":{
"BlogStory":{
"type":"object",
"properties":{
"id":{
"type":"string"
},
"name":{
"type":"string"
},
"summary":{
"type":"string"
},
"description":{
"type":"string"
},
"category":{
"type":"string"
}
}
},
"BlogCategory":{
"type":"object",
"properties":{
"id":{
"type":"string"
},
"name":{
"type":"string"
}
}
}
}
}
}
@Entity
@Table (name = "dish_table")
public class Dish {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
@Column(name = "id")
private Long id;
@NotNull
@Size(min=2, message="Name should have atleast 5 characters")
@Column(name = "name")
private String name;
@Column(name = "description")
private String description;
@Column(name = "lowprice")
private Double lowPrice;
@Column(name = "highprice")
private Double highPrice;
public Dish () {}
//Getter and Setters
}
@Repository
public interface DishRepository extends JpaRepository {
public Page findByName(String name, Pageable pageable);
}
@RestController
@RequestMapping("api/v2")
public class DishControllerPaginatedV2 {
private static final int pageSize = 2;
@Autowired
DishRepository repo;
@GetMapping(value="/dishes",produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity> getDish3(@RequestParam (defaultValue = "0") int pageNo) throws Exception {
Sort sort = Sort.by("name");
Pageable pageReq = PageRequest.of(pageNo, pageSize, sort);
Page result = repo.findAll(pageReq);
return ResponseEntity.ok(result);
}
}
curl --request GET \
--url 'http://localhost:8080/api/v1/dishes3?pageNo=0' \
--header 'cache-control: no-cache'
{
"content": [
{
"id": 12,
"name": "Anchovies",
"description": "Anchovies",
"lowPrice": 1987,
"highPrice": 0
},
{
"id": 14,
"name": "Celery",
"description": "Celery",
"lowPrice": 2928,
"highPrice": 0
}
],
"pageable": {
"sort": {
"sorted": true,
"unsorted": false,
"empty": false
},
"offset": 0,
"pageNumber": 0,
"pageSize": 2,
"paged": true,
"unpaged": false
},
"last": false,
"totalPages": 7,
"totalElements": 14,
"size": 2,
"number": 0,
"sort": {
"sorted": true,
"unsorted": false,
"empty": false
},
"numberOfElements": 2,
"first": true,
"empty": false
}
public class JakartaRestfulApp extends Application {
private final Set> classes;
public JakartaRestfulApp() {
HashSet> c = new HashSet>();
c.add(MenuResource.class);
classes = Collections.unmodifiableSet(c);
}
@Override
public Set> getClasses() {
return classes;
}
}
@Path("/rest")
public class MenuResource {
MenuService service = MenuService.getInstance();
@GET
@Path("/menus")
@Produces("application/json")
public List
public class MenuService {
private static MenuService instance = new MenuService();
private static HashSet
public class Menu {
private Long id;
private String name;
public Menu() {
}
public Menu(Long id, String name) {
this.id = id;
this.name = name;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
public class JDKSEServer {
private static final Logger LOGGER = Logger.getLogger(JDKSEServer.class.getName());
/**
* Starts the JDK HTTP server serving the JAX-RS application.
*/
static HttpServer startServer() throws IOException {
ResourceConfig config = new ResourceConfig(MenuResource.class);
HttpServer server = JdkHttpServerFactory.createHttpServer(getBaseURI(), config);
return server;
}
public static void main(String[] args) {
try {
final HttpServer httpServer = startServer();
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
try {
LOGGER.info("Shutting down the application...");
httpServer.stop(0);
} catch (Exception e) {
LOGGER.log(Level.SEVERE, null, e);
}
}));
LOGGER.info("Application started.%nStop the application using CTRL+C");
Thread.currentThread().join();
} catch (Exception ex) {
LOGGER.log(Level.SEVERE, null, ex);
}
}
/**
* Gets base {@link URI}.
*/
public static URI getBaseURI() {
return UriBuilder.fromUri("http://localhost/").port(8080).build();
}
}
public class TestMenuResource extends JerseyTest {
@BeforeEach
void init() throws Exception {
super.setUp();
}
@Override
protected Application configure() {
//to start a new container in s different port
forceSet(TestProperties.CONTAINER_PORT, "0");
return new ResourceConfig(MenuResource.class);
}
@Test
public void get_one() throws Exception {
Response response = target("/rest/menus/1").request().get();
System.out.println("sd " + response.getStatus());
assertEquals(response.getStatus(), 200);
assertEquals(response.readEntity(Menu.class).getName(), "Menu One");
}
protected TestContainerFactory getTestContainerFactory() {
return new JdkHttpServerTestContainerFactory();
}
}