Compare commits
11 Commits
master
...
LabWork_02
Author | SHA1 | Date | |
---|---|---|---|
|
402b25c5cc | ||
|
2855793c7b | ||
|
3dee9b728b | ||
|
0b8348bdbc | ||
|
309e915e7b | ||
|
f3f31c1a03 | ||
|
51b4b1b53e | ||
|
04f358067f | ||
|
4fb650e3d1 | ||
|
673233ea88 | ||
|
02eae37b14 |
@ -0,0 +1,13 @@
|
|||||||
|
package ru.ip.labworks.labworks.configuration;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||||
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class WebConfiguration implements WebMvcConfigurer {
|
||||||
|
@Override
|
||||||
|
public void addCorsMappings(CorsRegistry registry) {
|
||||||
|
registry.addMapping("/**").allowedMethods("*");
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
package ru.ip.labworks.labworks.controller;
|
||||||
|
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import ru.ip.labworks.labworks.service.CalculatorService;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
public class UserController {
|
||||||
|
private CalculatorService calculatorService;
|
||||||
|
|
||||||
|
public UserController(CalculatorService calculatorService){
|
||||||
|
this.calculatorService = calculatorService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/+")
|
||||||
|
public String workPlus(@RequestParam String type, @RequestParam Object arg1, @RequestParam Object arg2){
|
||||||
|
return (String) calculatorService.Plus(type, arg1, arg2);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/-")
|
||||||
|
public String workMinus(@RequestParam String type, @RequestParam Object arg1, @RequestParam Object arg2){
|
||||||
|
return (String) calculatorService.Minus(type, arg1, arg2);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/*")
|
||||||
|
public String workMulti(@RequestParam String type, @RequestParam Object arg1, @RequestParam Object arg2){
|
||||||
|
return (String) calculatorService.Multi(type, arg1, arg2);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/:")
|
||||||
|
public String workDiv(@RequestParam String type, @RequestParam Object arg1, @RequestParam Object arg2){
|
||||||
|
return (String) calculatorService.Div(type, arg1, arg2);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,48 @@
|
|||||||
|
package ru.ip.labworks.labworks.domain;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
@Component(value = "array")
|
||||||
|
public class ArrayCalculator implements ITypeCalculator<ArrayList<String>> {
|
||||||
|
@Override
|
||||||
|
public ArrayList<String> Plus(ArrayList<String> arg1, ArrayList<String> arg2) {
|
||||||
|
ArrayList<String> result = new ArrayList<>();
|
||||||
|
for (int i = 0; i < Math.min(arg1.size(), arg2.size()); ++i){
|
||||||
|
result.add(arg1.get(i) + arg2.get(i));
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ArrayList<String> Minus(ArrayList<String> arg1, ArrayList<String> arg2) {
|
||||||
|
ArrayList<String> result = new ArrayList<>();
|
||||||
|
for (int i = 0; i < Math.min(arg1.size(), arg2.size()); ++i){
|
||||||
|
result.add(arg1.get(i).replace(arg2.get(i), ""));
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ArrayList<String> Multi(ArrayList<String> arg1, ArrayList<String> arg2) {
|
||||||
|
ArrayList<String> result = new ArrayList<>();
|
||||||
|
for (int i = 0; i < Math.min(arg1.size(), arg2.size()); ++i){
|
||||||
|
String temp = "";
|
||||||
|
for (int j = 0; j < Integer.parseInt(arg2.get(i)); ++j){
|
||||||
|
temp += arg1.get(i);
|
||||||
|
}
|
||||||
|
result.add(temp);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ArrayList<String> Div(ArrayList<String> arg1, ArrayList<String> arg2) {
|
||||||
|
ArrayList<String> result = new ArrayList<>();
|
||||||
|
for (int i = 0; i < Math.min(arg1.size(), arg2.size()); ++i){
|
||||||
|
result.add(arg1.get(i).substring(0, Integer.parseInt(arg2.get(i))));
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
package ru.ip.labworks.labworks.domain;
|
||||||
|
|
||||||
|
public interface ITypeCalculator<T> {
|
||||||
|
|
||||||
|
T Plus(T arg1, T arg2);
|
||||||
|
T Minus(T arg1, T arg2);
|
||||||
|
T Multi(T arg1, T arg2);
|
||||||
|
T Div(T arg1, T arg2);
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
package ru.ip.labworks.labworks.domain;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component(value = "int")
|
||||||
|
public class IntCalculator implements ITypeCalculator<Integer>{
|
||||||
|
@Override
|
||||||
|
public Integer Plus(Integer arg1, Integer arg2) {
|
||||||
|
return arg1 + arg2;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer Minus(Integer arg1, Integer arg2) {
|
||||||
|
return arg1 - arg2;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer Multi(Integer arg1, Integer arg2) {
|
||||||
|
return arg1 * arg2;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer Div(Integer arg1, Integer arg2) {
|
||||||
|
return arg1 / arg2;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,31 @@
|
|||||||
|
package ru.ip.labworks.labworks.domain;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component(value = "string")
|
||||||
|
public class StringCalculator implements ITypeCalculator<String>{
|
||||||
|
@Override
|
||||||
|
public String Plus(String arg1, String arg2) {
|
||||||
|
return arg1 + arg2;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String Minus(String arg1, String arg2) {
|
||||||
|
return arg1.replaceAll(arg2, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String Multi(String arg1, String arg2) {
|
||||||
|
String result = "";
|
||||||
|
for (int i = 0; i < Integer.parseInt(arg2); ++i){
|
||||||
|
result += arg1;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String Div(String arg1, String arg2) {
|
||||||
|
String result = arg1.substring(0, arg1.length() / Integer.parseInt(arg2));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,66 @@
|
|||||||
|
package ru.ip.labworks.labworks.service;
|
||||||
|
|
||||||
|
import org.springframework.context.ApplicationContext;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import ru.ip.labworks.labworks.domain.ITypeCalculator;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class CalculatorService {
|
||||||
|
private final ApplicationContext applicationContext;
|
||||||
|
private ITypeCalculator typeCalculator;
|
||||||
|
private Object arg1;
|
||||||
|
private Object arg2;
|
||||||
|
|
||||||
|
public CalculatorService(ApplicationContext applicationContext){
|
||||||
|
this.applicationContext = applicationContext;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean ValidateParams(Object value1, Object value2, String type){
|
||||||
|
typeCalculator = (ITypeCalculator)applicationContext.getBean(type);
|
||||||
|
|
||||||
|
try {
|
||||||
|
switch (type) {
|
||||||
|
case "int" -> {
|
||||||
|
arg1 = Integer.valueOf(value1.toString());
|
||||||
|
arg2 = Integer.valueOf(value2.toString());
|
||||||
|
}
|
||||||
|
case "array" -> {
|
||||||
|
arg1 = new ArrayList<>(Arrays.asList(value1.toString().split(",")));
|
||||||
|
arg2 = new ArrayList<>(Arrays.asList(value2.toString().split(",")));
|
||||||
|
}
|
||||||
|
case "string" -> {
|
||||||
|
arg1 = value1.toString();
|
||||||
|
arg2 = value2.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Object Plus(String type, Object arg1, Object arg2){
|
||||||
|
if(!ValidateParams(arg1,arg2,type)) return String.format("Неверные данные");
|
||||||
|
return String.format("%s", typeCalculator.Plus(this.arg1, this.arg2));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object Minus(String type, Object arg1, Object arg2){
|
||||||
|
if(!ValidateParams(arg1,arg2,type)) return String.format("Неверные данные");
|
||||||
|
return String.format("%s", typeCalculator.Minus(this.arg1, this.arg2));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object Multi(String type, Object arg1, Object arg2){
|
||||||
|
if(!ValidateParams(arg1,arg2,type)) return String.format("Неверные данные");
|
||||||
|
return String.format("%s", typeCalculator.Multi(this.arg1, this.arg2));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object Div(String type, Object arg1, Object arg2){
|
||||||
|
if(!ValidateParams(arg1,arg2,type)) return String.format("Неверные данные");
|
||||||
|
return String.format("%s", typeCalculator.Div(this.arg1, this.arg2));
|
||||||
|
}
|
||||||
|
}
|
24
src/main/resources/frontend/spa-vue/.gitignore
vendored
Normal file
24
src/main/resources/frontend/spa-vue/.gitignore
vendored
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
# Logs
|
||||||
|
logs
|
||||||
|
*.log
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
pnpm-debug.log*
|
||||||
|
lerna-debug.log*
|
||||||
|
|
||||||
|
node_modules
|
||||||
|
dist
|
||||||
|
dist-ssr
|
||||||
|
*.local
|
||||||
|
|
||||||
|
# Editor directories and files
|
||||||
|
.vscode/*
|
||||||
|
!.vscode/extensions.json
|
||||||
|
.idea
|
||||||
|
.DS_Store
|
||||||
|
*.suo
|
||||||
|
*.ntvs*
|
||||||
|
*.njsproj
|
||||||
|
*.sln
|
||||||
|
*.sw?
|
7
src/main/resources/frontend/spa-vue/README.md
Normal file
7
src/main/resources/frontend/spa-vue/README.md
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# Vue 3 + Vite
|
||||||
|
|
||||||
|
This template should help get you started developing with Vue 3 in Vite. The template uses Vue 3 `<script setup>` SFCs, check out the [script setup docs](https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup) to learn more.
|
||||||
|
|
||||||
|
## Recommended IDE Setup
|
||||||
|
|
||||||
|
- [VS Code](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur) + [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin).
|
19
src/main/resources/frontend/spa-vue/data.json
Normal file
19
src/main/resources/frontend/spa-vue/data.json
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"posts": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"title": "json-server",
|
||||||
|
"author": "typicode"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"comments": [
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"body": "some comment",
|
||||||
|
"postId": 1
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"profile": {
|
||||||
|
"name": "typicode"
|
||||||
|
}
|
||||||
|
}
|
14
src/main/resources/frontend/spa-vue/index.html
Normal file
14
src/main/resources/frontend/spa-vue/index.html
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
|
||||||
|
<title>Data Type Calculator</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="app"></div>
|
||||||
|
<script type="module" src="/src/main.js"></script>
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js" integrity="sha384-w76AqPfDkMBDXo30jS1Sgez6pr3x5MlQ1ZAGC+nuZB+EYdgRZgiwxhTBTkF7CXvN" crossorigin="anonymous"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
5212
src/main/resources/frontend/spa-vue/package-lock.json
generated
Normal file
5212
src/main/resources/frontend/spa-vue/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
26
src/main/resources/frontend/spa-vue/package.json
Normal file
26
src/main/resources/frontend/spa-vue/package.json
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"name": "spa-vue",
|
||||||
|
"private": true,
|
||||||
|
"version": "1.0.0",
|
||||||
|
"type": "module",
|
||||||
|
"scripts": {
|
||||||
|
"dev": "vite",
|
||||||
|
"fake-server": "json-server --watch data.json -p 8079",
|
||||||
|
"start": "npm-run-all --parallel dev fake-server",
|
||||||
|
"build": "vite build",
|
||||||
|
"preview": "vite preview"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"vue": "^3.2.41",
|
||||||
|
"vue-router": "^4.1.6",
|
||||||
|
"axios": "^1.1.3",
|
||||||
|
"bootstrap": "^5.2.2",
|
||||||
|
"@fortawesome/fontawesome-free": "^6.2.1"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"vite": "^3.2.3",
|
||||||
|
"@vitejs/plugin-vue": "^3.2.0",
|
||||||
|
"npm-run-all": "^4.1.5",
|
||||||
|
"json-server": "^0.17.1"
|
||||||
|
}
|
||||||
|
}
|
9
src/main/resources/frontend/spa-vue/src/App.vue
Normal file
9
src/main/resources/frontend/spa-vue/src/App.vue
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<script setup>
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<router-view>
|
||||||
|
|
||||||
|
</router-view>
|
||||||
|
</template>
|
@ -0,0 +1,17 @@
|
|||||||
|
<template>
|
||||||
|
<footer class="container pt-4 my-md-5 pt-md-5 text-center fixed-bottom border-top">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-12 col-md">
|
||||||
|
<h5 class=""><strong>End</strong></h5>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</footer>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
</style>
|
@ -0,0 +1,11 @@
|
|||||||
|
<template>
|
||||||
|
<header class="fixed-top">
|
||||||
|
<nav class="navbar navbar-expand-lg bg-primary" data-bs-theme="dark">
|
||||||
|
<div class="container">
|
||||||
|
<a class="navbar-brand" href="#">
|
||||||
|
<strong>{ DTC } Data Type Calculator</strong>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
</header>
|
||||||
|
</template>
|
7
src/main/resources/frontend/spa-vue/src/main.js
Normal file
7
src/main/resources/frontend/spa-vue/src/main.js
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
import { createApp } from 'vue'
|
||||||
|
import App from './App.vue'
|
||||||
|
import router from "./router/router.js"
|
||||||
|
|
||||||
|
const app = createApp(App)
|
||||||
|
|
||||||
|
app.use(router).mount("#app");
|
75
src/main/resources/frontend/spa-vue/src/pages/Index.vue
Normal file
75
src/main/resources/frontend/spa-vue/src/pages/Index.vue
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
<script>
|
||||||
|
import Header from '../components/Header.vue'
|
||||||
|
import Footer from '../components/Footer.vue'
|
||||||
|
export default{
|
||||||
|
components:{
|
||||||
|
Header,
|
||||||
|
Footer
|
||||||
|
},
|
||||||
|
data(){
|
||||||
|
return {
|
||||||
|
action: "",
|
||||||
|
type: "",
|
||||||
|
str_1: "",
|
||||||
|
str_2: "",
|
||||||
|
result: ""
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods:{
|
||||||
|
GetRepuest(){
|
||||||
|
if (this.action.length == 0 || this.str_1.length == 0 || this.str_2.length == 0){
|
||||||
|
console.warn("Invalid input to fetch!");
|
||||||
|
}
|
||||||
|
console.log("http://localhost:8080/" + this.action + "?type=" + this.type + "&arg1=" + this.str_1 + "&arg2=" + this.str_2)
|
||||||
|
fetch("http://localhost:8080/" + this.action + "?type=" + this.type + "&arg1=" + this.str_1 + "&arg2=" + this.str_2)
|
||||||
|
.then(res => res.text())
|
||||||
|
.then(res => {
|
||||||
|
this.result = res;
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<Header></Header>
|
||||||
|
<main class="container" style="margin-top: 50pt;">
|
||||||
|
<div class="input-group mb-2 my-5">
|
||||||
|
<span class="input-group-text bg-primary text-white" id="basic-addon1"><strong>Действие:</strong></span>
|
||||||
|
<select class="form-select" aria-label="Default select example" v-model="action">
|
||||||
|
<option value="+">Plus(+)</option>
|
||||||
|
<option value="-">Minus(-)</option>
|
||||||
|
<option value="*">Multi(*)</option>
|
||||||
|
<option value=":">Div(\)</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="input-group mb-2">
|
||||||
|
<span class="input-group-text bg-primary text-white" id="basic-addon1"><strong>Тип данных:</strong></span>
|
||||||
|
<select class="form-select" aria-label="Default select example" v-model="type">
|
||||||
|
<option value="int">Integer{}</option>
|
||||||
|
<option value="string">String"_"</option>
|
||||||
|
<option value="array">Array[]</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="input-group mb-2">
|
||||||
|
<span class="input-group-text bg-primary text-white" id="basic-addon1"><strong>Аргумент№1:</strong></span>
|
||||||
|
<input type="text" class="form-control" placeholder="Введите превую строку" v-model="str_1">
|
||||||
|
</div>
|
||||||
|
<div class="input-group mb-2">
|
||||||
|
<span class="input-group-text bg-primary text-white" id="basic-addon1"><strong>Аргумент№2:</strong></span>
|
||||||
|
<input type="text" class="form-control" placeholder="Введите вторую строку" v-model="str_2">
|
||||||
|
</div>
|
||||||
|
<div class="input-group mb-2">
|
||||||
|
<span class="input-group-text bg-success text-white" id="basic-addon1"><strong>Вывод:</strong></span>
|
||||||
|
<input type="text" class="form-control" placeholder="Выводит рузультат здесь" v-model="result" readonly>
|
||||||
|
</div>
|
||||||
|
<div class="mb-2 d-flex justify-content-center">
|
||||||
|
<button type="submit" class="btn btn-success" @click.prevent="GetRepuest"><strong>GET</strong></button>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
<Footer></Footer>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
|
||||||
|
</style>
|
14
src/main/resources/frontend/spa-vue/src/router/router.js
Normal file
14
src/main/resources/frontend/spa-vue/src/router/router.js
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import {createRouter, createWebHistory} from "vue-router"
|
||||||
|
import Index from '../pages/Index.vue'
|
||||||
|
|
||||||
|
const routes = [
|
||||||
|
{path: '/', component: Index},
|
||||||
|
]
|
||||||
|
|
||||||
|
const router = createRouter({
|
||||||
|
history: createWebHistory(),
|
||||||
|
linkActiveClass: 'active',
|
||||||
|
routes
|
||||||
|
})
|
||||||
|
|
||||||
|
export default router;
|
7
src/main/resources/frontend/spa-vue/vite.config.js
Normal file
7
src/main/resources/frontend/spa-vue/vite.config.js
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
import { defineConfig } from 'vite'
|
||||||
|
import vue from '@vitejs/plugin-vue'
|
||||||
|
|
||||||
|
// https://vitejs.dev/config/
|
||||||
|
export default defineConfig({
|
||||||
|
plugins: [vue()],
|
||||||
|
})
|
@ -1,13 +1,91 @@
|
|||||||
package ru.ip.labworks.labworks;
|
package ru.ip.labworks.labworks;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
import ru.ip.labworks.labworks.service.CalculatorService;
|
||||||
|
|
||||||
@SpringBootTest
|
@SpringBootTest
|
||||||
class LabworksApplicationTests {
|
class LabworksApplicationTests {
|
||||||
|
@Autowired
|
||||||
|
CalculatorService calculatorService;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void contextLoads() {
|
void IntPlus() {
|
||||||
|
final String res = calculatorService.Plus("int", 10, 2).toString();
|
||||||
|
Assertions.assertEquals("12", res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void IntMinus() {
|
||||||
|
final String res = calculatorService.Minus("int", 10, 2).toString();
|
||||||
|
Assertions.assertEquals("8", res);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void IntMulti() {
|
||||||
|
final String res = calculatorService.Multi("int", 10, 2).toString();
|
||||||
|
Assertions.assertEquals("20", res);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void IntDiv() {
|
||||||
|
final String res = calculatorService.Div("int", 10, 2).toString();
|
||||||
|
Assertions.assertEquals("5", res);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void StrPlus() {
|
||||||
|
final String res = calculatorService.Plus("string", "10", "2").toString();
|
||||||
|
Assertions.assertEquals("102", res);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void StrMinus() {
|
||||||
|
final String res = calculatorService.Minus("string", "10", "0").toString();
|
||||||
|
Assertions.assertEquals("1", res);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void StrMulti() {
|
||||||
|
final String res = calculatorService.Multi("string", "10", "2").toString();
|
||||||
|
Assertions.assertEquals("1010", res);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void StrDiv() {
|
||||||
|
final String res = calculatorService.Div("string", "1010", "2").toString();
|
||||||
|
Assertions.assertEquals("10", res);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void ArrayPlus() {
|
||||||
|
final String res = calculatorService.Plus("array", "2,2", "3,3").toString();
|
||||||
|
Assertions.assertEquals("[23, 23]", res);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void ArrayMinus() {
|
||||||
|
final String res = calculatorService.Minus("array", "24,23", "4,3").toString();
|
||||||
|
Assertions.assertEquals("[2, 2]", res);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void ArrayMulti() {
|
||||||
|
final String res = calculatorService.Multi("array", "23,24", "2,2").toString();
|
||||||
|
Assertions.assertEquals("[2323, 2424]", res);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void ArrayDiv() {
|
||||||
|
final String res = calculatorService.Div("array", "23,24", "1,1").toString();
|
||||||
|
Assertions.assertEquals("[2, 2]", res);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testErrorErrorWired() {
|
||||||
|
Assertions.assertThrows(NoSuchBeanDefinitionException.class, () -> calculatorService.Plus("date", 1, 2));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user