Skip to content

Commit

Permalink
Auto-save-commit-2/22/2024--4:31:46-PM
Browse files Browse the repository at this point in the history
  • Loading branch information
neojarvis committed Feb 22, 2024
1 parent 98399cb commit ef59eab
Show file tree
Hide file tree
Showing 3 changed files with 139 additions and 0 deletions.
35 changes: 35 additions & 0 deletions backup.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
-- MariaDB dump 10.19 Distrib 10.5.21-MariaDB, for debian-linux-gnu (x86_64)
--
-- Host: localhost Database: appdb
-- ------------------------------------------------------
-- Server version 5.6.51

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

--
-- Current Database: `appdb`
--

CREATE DATABASE /*!32312 IF NOT EXISTS*/ `appdb` /*!40100 DEFAULT CHARACTER SET latin1 */;

USE `appdb`;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

-- Dump completed on 2024-02-22 11:01:48
1 change: 1 addition & 0 deletions hlo.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hello all new!
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
package com.examly.springapp;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Order;
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 static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;

import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
import org.springframework.web.util.NestedServletException;

import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
import java.io.File;
import java.util.NoSuchElementException;

@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
@SpringBootTest(classes = SpringappApplication.class)
@AutoConfigureMockMvc
class SpringappApplicationTests {

@Autowired
private MockMvc mockMvc;

@Test
@Order(1)
void testaddShirt() throws Exception {
String st = "{\"shirtId\": 123, \"shirtSize\": 457, \"shirtColor\": \"browndemo\"}";
mockMvc.perform(MockMvcRequestBuilders.post("/")
.contentType(MediaType.APPLICATION_JSON)
.content(st)
.accept(MediaType.APPLICATION_JSON))
.andExpect(MockMvcResultMatchers.status().isOk())
.andExpect(jsonPath("$.shirtSize").value("457"))
.andReturn();
}

@Test
@Order(2)
void testgetAll() throws Exception {
mockMvc.perform(get("/")
.accept(MediaType.APPLICATION_JSON))
.andDo(print())
.andExpect(status().isOk())
.andExpect(jsonPath("$[?(@.shirtColor == 'browndemo')]").exists())
.andReturn();
}

@Test
@Order(3)
void testgetByID() throws Exception {
mockMvc.perform(get("/123")
.accept(MediaType.APPLICATION_JSON))
.andDo(print())
.andExpect(jsonPath("$[?(@.shirtColor == 'browndemo')]").exists())
.andReturn();
}

@Test
@Order(4)
void testupdateDetails() throws Exception {
String st = "{\"shirtId\": 123, \"shirtSize\": 345,\"shirtColor\": \"black\"}";
mockMvc.perform(MockMvcRequestBuilders.put("/123")
.contentType(MediaType.APPLICATION_JSON)
.content(st)
.accept(MediaType.APPLICATION_JSON))
.andExpect(MockMvcResultMatchers.status().isOk())
.andExpect(jsonPath("$.shirtSize").value(345))
.andReturn();
}

@Test
@Order(5)
void testdeleteById() throws Exception {
mockMvc.perform(MockMvcRequestBuilders.delete("/123")
.accept(MediaType.APPLICATION_JSON))
.andDo(print())
.andExpect(status().isOk())
.andExpect(jsonPath("$").value(true))
.andReturn();

try {
mockMvc.perform(MockMvcRequestBuilders.get("/123")
.accept(MediaType.APPLICATION_JSON))
.andExpect(status().isNotFound());
} catch (NestedServletException e) {
if (e.getCause() instanceof NoSuchElementException) {
} else {
throw e;
}
}

}

}

0 comments on commit ef59eab

Please sign in to comment.