Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Q
qk_backend
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
quanku
qk_backend
Commits
a4dcfadd
Commit
a4dcfadd
authored
Sep 07, 2023
by
shiyu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
测试类
parent
250d7146
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
132 additions
and
0 deletions
+132
-0
ch-admin-api/src/test/java/com/wwdz/ch/admin/impl/CategoryServiceImplTest.java
.../java/com/wwdz/ch/admin/impl/CategoryServiceImplTest.java
+23
-0
ch-admin-api/src/test/java/com/wwdz/ch/admin/impl/ItemServiceImplTest.java
...test/java/com/wwdz/ch/admin/impl/ItemServiceImplTest.java
+109
-0
No files found.
ch-admin-api/src/test/java/com/wwdz/ch/admin/impl/CategoryServiceImplTest.java
0 → 100644
View file @
a4dcfadd
package
com.wwdz.ch.admin.impl
;
import
com.wwdz.ch.admin.service.CategoryService
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
static
org
.
junit
.
Assert
.*;
@SpringBootTest
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
public
class
CategoryServiceImplTest
{
@Autowired
CategoryService
categoryService
;
@Test
public
void
getSubCategory
()
{
categoryService
.
getSubCategory
(
1001025
);
}
}
\ No newline at end of file
ch-admin-api/src/test/java/com/wwdz/ch/admin/impl/ItemServiceImplTest.java
0 → 100644
View file @
a4dcfadd
package
com.wwdz.ch.admin.impl
;
import
com.wwdz.ch.admin.job.SynCoinJob
;
import
com.wwdz.ch.admin.service.AdminGoodsService
;
import
com.wwdz.ch.admin.service.ItemService
;
import
com.wwdz.ch.core.consts.CommConsts
;
import
com.wwdz.ch.core.consts.MediaTypeEnum
;
import
com.wwdz.ch.core.storage.QiniuStorage
;
import
com.wwdz.ch.core.util.UUID
;
import
com.wwdz.ch.db.dao.ItemDao
;
import
com.wwdz.ch.db.dto.request.CoinRequestDto
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
javax.imageio.ImageIO
;
import
java.awt.image.BufferedImage
;
import
java.io.*
;
import
java.net.URL
;
import
java.util.Arrays
;
import
java.util.Base64
;
@SpringBootTest
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
public
class
ItemServiceImplTest
{
@Autowired
ItemService
itemService
;
@Autowired
QiniuStorage
qiniuStorage
;
@Autowired
SynCoinJob
synCoinJob
;
@Autowired
ItemDao
itemDao
;
@Autowired
AdminGoodsService
adminGoodsService
;
@Test
public
void
list
()
{
adminGoodsService
.
list
(
null
,
null
,
1
,
10
,
"create_time"
,
"desc"
);
}
@Test
public
void
upload
()
throws
Exception
{
String
imgBaseStr
=
""
;
/* byte[] bytes = new BASE64Decoder().decodeBuffer(imgBaseStr.trim());
String file64 = Base64.encodeToString(bytes, 0);
ByteArrayInputStream inputStream = new ByteArrayInputStream(bytes);
*/
String
keyName
=
CommConsts
.
UPLOAD_PRE_DIRECTORY
+
System
.
currentTimeMillis
();
qiniuStorage
.
storeBase64Str
(
imgBaseStr
,
keyName
);
//
/* File file = new File("/Users/xxdxxs/Downloads/tt.jpg");
InputStream inputStream1 = new FileInputStream(file);
String keyName = "test002" + System.currentTimeMillis() + ".jpg";
System.out.println("keyName = " + keyName);
qiniuStorage.store(inputStream1, file.length(), "image/jpg", keyName);*/
// String url = qiniuStorage.generateUrl(keyName);
// System.out.println("url = " + url);
}
@Test
public
void
uploadOfSize
()
throws
Exception
{
String
imageUrl
=
"https://cdn.wanwudezhi.com/quanku/YjFzNEgwMWxMTG9mTUlxQ2hVWTZKUzE2ODUwMDQ0NDg=.jpg"
;
URL
url
=
new
URL
(
imageUrl
);
InputStream
inputStream
=
url
.
openStream
();
String
keyName
=
UUID
.
fastUUID
().
toString
();
BufferedImage
bufferedImage
=
ImageIO
.
read
(
inputStream
);
keyName
=
keyName
+
"_"
+
bufferedImage
.
getWidth
()
+
"x"
+
bufferedImage
.
getHeight
()+
".jpg"
;
InputStream
fileStream
=
bufferedImageToInputStream
(
bufferedImage
,
MediaTypeEnum
.
IMAGE_JPG
.
getExt
());
qiniuStorage
.
store
(
fileStream
,
1
,
"image/jpeg"
,
keyName
);
String
imageUrlofSize
=
qiniuStorage
.
generateUrl
(
keyName
);
System
.
out
.
println
(
"imageUrlofSize = "
+
imageUrlofSize
);
}
private
static
InputStream
bufferedImageToInputStream
(
BufferedImage
image
,
String
type
)
{
try
(
ByteArrayOutputStream
os
=
new
ByteArrayOutputStream
())
{
ImageIO
.
write
(
image
,
type
,
os
);
return
new
ByteArrayInputStream
(
os
.
toByteArray
());
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
return
null
;
}
@Test
public
void
deleteUserItems
(){
CoinRequestDto
coinRequestDto
=
new
CoinRequestDto
();
coinRequestDto
.
setIds
(
Arrays
.
asList
(
767377L
,
767378L
,
767379L
));
itemDao
.
deleteUserItems
(
coinRequestDto
);
}
@Test
public
void
setCoin
()
{
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment