Merge pull request #8 from getrebuild/makeup-testcases

Makeup testcases
This commit is contained in:
RB 2019-03-09 16:27:01 +08:00 committed by GitHub
commit 2794a05054
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
30 changed files with 942 additions and 123 deletions

53
pom.xml
View file

@ -2,7 +2,7 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.rebuild</groupId>
<artifactId>rebuild</artifactId>
<packaging>war</packaging>
@ -14,7 +14,7 @@
<licenses>
<license>
<name>GPL-3.0</name>
<url>https://www.gnu.org/licenses/</url>
<url>https://www.gnu.org/licenses/gpl-3.0.html</url>
</license>
</licenses>
@ -42,12 +42,17 @@
<target>1.8</target>
</configuration>
</plugin>
<!-- run `mvn cobertura:cobertura` & `bash <(curl -s https://codecov.io/bash) -t TOKEN` -->
<!-- Manual run `mvn cobertura:cobertura -DskipTests=false -Drbpass=PASSKEY` & `bash <(curl -s https://codecov.io/bash) -t TOKEN` -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.7</version>
<configuration>
<instrumentation>
<excludes>
<exclude>com/rebuild/**/*Test.class</exclude>
</excludes>
</instrumentation>
<formats>
<format>html</format>
<format>xml</format>
@ -107,14 +112,14 @@
<scope>provided</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.25</version>
<groupId>taglibs</groupId>
<artifactId>standard</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
@ -165,16 +170,34 @@
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
<version>2.3.0</version>
<exclusions>
<exclusion>
<artifactId>slf4j-api</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache</artifactId>
<version>2.10.6</version>
<exclusions>
<exclusion>
<artifactId>slf4j-api</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>2.10.1</version>
<exclusions>
<exclusion>
<artifactId>slf4j-api</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
@ -184,17 +207,7 @@
<dependency>
<groupId>com.qiniu</groupId>
<artifactId>qiniu-java-sdk</artifactId>
<version>7.2.18</version>
</dependency>
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>taglibs</groupId>
<artifactId>standard</artifactId>
<version>1.1.2</version>
<version>[7.2.18, 7.2.99]</version>
</dependency>
<dependency>
<groupId>com.github.whvcse</groupId>

View file

@ -29,7 +29,8 @@ import com.rebuild.server.Application;
import com.rebuild.utils.JSONUtils;
/**
* 黑名单
* 黑名单 src/main/resources/blacklist.json
* More details https://github.com/fighting41love/funNLP
*
* @author devezhao
* @since 01/31/2019
@ -60,7 +61,7 @@ public class BlackList {
String s = IOUtils.toString(url, "UTF-8");
BLACKLIST = JSON.parseArray(s);
} catch (IOException e) {
Application.LOG.error("Cloud't load blacklist! The feature is missed : " + e);
Application.LOG.error("Cloud't load [blacklist.json] file! This feature is missed : " + e);
BLACKLIST = JSONUtils.EMPTY_ARRAY;
}
}

View file

@ -19,7 +19,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
package com.rebuild.server.helper;
/**
* 预置系统配置项
* 预置系统配置项所有配置应在此处声明
*
* @author devezhao
* @since 12/25/2018

View file

@ -26,8 +26,10 @@ import org.apache.commons.io.FileUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.qiniu.common.QiniuException;
import com.qiniu.common.Zone;
import com.qiniu.http.Response;
import com.qiniu.storage.BucketManager;
import com.qiniu.storage.Configuration;
import com.qiniu.storage.UploadManager;
import com.qiniu.util.Auth;
@ -46,7 +48,9 @@ public class QiniuCloud {
private static final Log LOG = LogFactory.getLog(QiniuCloud.class);
private final UploadManager UPLOAD_MANAGER = new UploadManager(new Configuration(Zone.autoZone()));
private final Configuration CONFIGURATION = new Configuration(Zone.autoZone());
private final UploadManager UPLOAD_MANAGER = new UploadManager(CONFIGURATION);
private Auth auth;
private String bucketName;
@ -156,6 +160,27 @@ public class QiniuCloud {
return true;
}
/**
* 删除文件
*
* @param key
* @return
*/
protected boolean delete(String key) {
BucketManager bucketManager = new BucketManager(auth, CONFIGURATION);
Response resp = null;
try {
resp = bucketManager.delete(this.bucketName, key);
if (resp.isOK()) {
return true;
} else {
throw new RebuildException("删除文件失败 : " + this.bucketName + " < " + key + " : " + resp.bodyString());
}
} catch (QiniuException e) {
throw new RebuildException("删除文件失败 : " + this.bucketName + " < " + key, e);
}
}
// --
private static final QiniuCloud INSTANCE = new QiniuCloud();

View file

@ -126,9 +126,9 @@ public class SMSender {
params.put("appid", account[0]);
params.put("signature", account[1]);
params.put("to", to);
// Auto append sign
if (!content.endsWith("]")) {
content += "[" + account[2] + "";
// Auto appended the SMS-Sign (China only?)
if (!content.startsWith("")) {
content = "" + account[2] + "" + content;
}
params.put("content", content);

View file

@ -41,6 +41,7 @@ import cn.devezhao.persist4j.engine.ID;
*
* @author devezhao
* @since 10/14/2018
* @see ConfigItem
*/
public class SystemConfig {

View file

@ -387,8 +387,8 @@ public class SecurityManager {
Object[] rights = Application.createQueryNoFilter(
"select rights from ShareAccess where belongEntity = ? and recordId = ? and shareTo = ?")
.setParameter(1, entity.getName())
.setParameter(2, target.toLiteral())
.setParameter(3, user.toLiteral())
.setParameter(2, target)
.setParameter(3, user)
.unique();
int rightsVal = rights == null ? 0 : (int) rights[0];
if ((rightsVal & BizzPermission.READ.getMask()) != 0) {

View file

@ -33,8 +33,6 @@ import com.rebuild.web.BaseEntityControll;
import cn.devezhao.persist4j.engine.ID;
/**
* TODO
*
* @author devezhao-mac zhaofang123@gmail.com
* @since 2019/02/16
*/

View file

@ -100,7 +100,7 @@ public class MetaFieldControll extends BasePageControll {
}
@RequestMapping("{entity}/field/{field}")
public ModelAndView pageEntityFields(@PathVariable String entity, @PathVariable String field, HttpServletRequest request) throws IOException {
public ModelAndView pageEntityField(@PathVariable String entity, @PathVariable String field, HttpServletRequest request) throws IOException {
ModelAndView mv = createModelAndView("/admin/entity/field-edit.jsp");
EasyMeta easyMeta = MetaEntityControll.setEntityBase(mv, entity);

View file

@ -200,8 +200,8 @@ public class GeneralRecordOperatorControll extends BaseControll {
@RequestMapping("record-unshare")
public void unshare(HttpServletRequest request, HttpServletResponse response) throws IOException {
final ID user = getRequestUser(request);
final ID record = getIdParameterNotNull(request, "record");
final ID[] ids = parseIdList(request);
final ID record = getIdParameterNotNull(request, "record"); // Record ID
final ID[] ids = parseIdList(request); // ShareAccess IDs
if (ids.length == 0) {
writeFailure(response, "没有要取消共享的记录");
return;

View file

@ -1,131 +1,163 @@
html, body {
overflow: auto;
height: 100%;
html,
body {
overflow: auto;
height: 100%;
}
.main-content {
margin-top: 60px;
margin-top: 60px;
}
.tab-container {
margin-top: -8px
margin-top: -8px
}
.tab-content {
padding: 0;
margin: 0;
padding-top: 13px
padding: 0;
margin: 0;
padding-top: 13px
}
.view-header {
padding: 15px 20px;
height: 60px;
border-bottom: 1px solid #e3e3e3;
position: absolute;
top: 0;
left: 0;
width: 100%;
z-index: 1001;
background-color: rgba(255, 255, 255, .8);
background-color: #fff;
padding: 15px 20px;
height: 60px;
border-bottom: 1px solid #e3e3e3;
position: absolute;
top: 0;
left: 0;
width: 100%;
z-index: 1001;
background-color: rgba(255, 255, 255, .8);
background-color: #fff;
}
.view-header .header-icon {
float: left;
float: left;
}
.view-header .title {
line-height: 1.428571;
display: inline-block;
margin: 0;
font-weight: 300;
font-size: 1.538rem
line-height: 1.428571;
display: inline-block;
margin: 0;
font-weight: 300;
font-size: 1.538rem
}
.view-header>span>.close {
font-size: 1.638rem;
opacity: .6;
padding: 1rem;
margin: -1rem -1rem -1rem auto;
height: 40px;
margin-top: -10px;
font-size: 1.638rem;
opacity: .6;
padding: 1rem;
margin: -1rem -1rem -1rem auto;
height: 40px;
margin-top: -10px;
}
.view-header>span>.close.sm {
font-size: 1.45rem;
margin-right: -7px;
font-size: 1.45rem;
margin-right: -7px;
}
.view-header>span>.close:hover {
opacity: .8;
opacity: .8;
}
.nav-tabs>li.nav-item a.nav-link {
padding: 11px 15px;
max-width: 120px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
padding: 11px 15px;
max-width: 120px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.nav-tabs, .nav-tabs>li.nav-item {
position: relative;
.nav-tabs,
.nav-tabs>li.nav-item {
position: relative;
}
.nav-tabs .vtab-settings {
position: absolute;
right: 0;
top: 4px;
display: inline-block;
padding: 9px 8px;
font-size: 15px;
opacity: 0.6;
display: none;
position: absolute;
right: 0;
top: 4px;
display: inline-block;
padding: 9px 8px;
font-size: 15px;
opacity: 0.6;
display: none;
}
.nav-tabs .vtab-settings:hover {
opacity: 0.8
opacity: 0.8
}
.nav-tabs:hover .vtab-settings {
display: inline-block;
display: inline-block;
}
.nav-tabs .badge {
position: absolute;
top: -1px;
right: -4px;
font-size: .8462rem;
font-weight: normal;
position: absolute;
top: -1px;
right: -4px;
font-size: .8462rem;
font-weight: normal;
}
.related-list {
min-height: 200px
min-height: 200px
}
.related-list .card {
border: 1px solid #ebebeb;
box-shadow: 0 0 4px 0 rgba(0, 0, 0, .04);
padding: 10px 15px;
margin-bottom: 9px;
border: 1px solid #ebebeb;
box-shadow: 0 0 4px 0 rgba(0, 0, 0, .04);
padding: 10px 15px;
margin-bottom: 9px;
}
.related-list .card .float-right {
color: #aaa;
cursor: help;
color: #aaa;
cursor: help;
}
.view-operating {
padding-left: 30px;
padding-left: 30px;
}
.view-operating>div {
margin-bottom: 15px !important;
margin-bottom: 15px !important;
}
.view-operating .row, .view-operating .form-line {
margin-bottom: 10px;
.view-operating .row,
.view-operating .form-line {
margin-bottom: 10px;
}
.view-operating dt {
font-weight: normal;
font-weight: normal;
}
.view-action {
margin-top: 33px;
margin-top: 33px;
}
.view-action .col-6 {
margin-bottom: .769231rem;
}
.view-action .col-6:nth-child(odd) {
padding-right: 0.384615rem;
}
.view-action .col-6:nth-child(even) {
padding-left: 0.384615rem;
}
.view-action .col-6 .btn {
width: 100%
width: 100%
}
.view-action.empty {
margin-top: 4px;
}
.btn.load-mores {
display: inline-block;
min-width: 200px;
@ -138,12 +170,15 @@ html, body {
margin: 0;
padding: 0;
}
.user-show:hover{
.user-show:hover {
opacity: 0.8;
}
.user-show>div{
.user-show>div {
display: inline-block;
}
.user-show .avatar {
overflow: hidden;
font-size: 0;
@ -154,16 +189,19 @@ html, body {
text-align: center;
vertical-align: middle;
}
.user-show .avatar > img {
.user-show .avatar>img {
display: inline-block;
width: 100%;
height: 100%;
}
.user-show .avatar > i.zmdi {
.user-show .avatar>i.zmdi {
font-size: 1.7rem;
margin-top: 4px;
color: #666;
}
.user-show .name {
margin-left: 6px;
height: 30px;
@ -171,7 +209,8 @@ html, body {
line-height: 30px;
color: #4285f4;
}
.user-show .name>em{
.user-show .name>em {
font-style: normal;
color: #777;
font-size: 12px;
@ -181,18 +220,22 @@ html, body {
.view-operating>div.view-user {
margin-bottom: 0px !important;
}
.view-user .row .col-8 {
min-height: 30px;
margin-top: -6px;
margin-bottom: 0;
}
.view-user .row ul>li {
margin-bottom: 6px;
margin-right: 6px;
}
.view-user .row ul>li:last-child{
.view-user .row ul>li:last-child {
margin-right: 0;
}
.view-user .row:last-child {
margin-bottom: 0;
margin-top: 18px;
@ -204,10 +247,12 @@ html, body {
margin-right: 0;
margin-bottom: 21px;
}
.sharing-list ul > li {
.sharing-list ul>li {
margin-bottom: 0.5rem;
}
.sharing-list ul > li > div {
.sharing-list ul>li>div {
border: 1px solid #eee;
padding: 6px 10px;
border-radius: 2px;
@ -216,24 +261,28 @@ html, body {
position: relative;
height: 44px;
}
.sharing-list ul > li > div:hover {
border-color: #eee;
.sharing-list ul>li>div:hover {
border: 1px solid #4285f4;
}
.sharing-list ul > li > div .zmdi {
.sharing-list ul>li>div .zmdi {
position: absolute;
right: 8px;
top: 11px;
font-size: 1.4rem;
color: #4285f4
}
.sharing-list ul > li > div .user-show .name {
.sharing-list ul>li>div .user-show .name {
color: #555;
max-width: 90px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.sharing-list .dialog-footer {
margin-left: -20px;
margin-right: -25px;
}
}

View file

@ -134,10 +134,11 @@ const RbViewPage = {
renderRbcomp(<UserShow id={v[0]} name={v[1]} avatarUrl={v[2]} showName={true} deptName2={v[3]} onClick={() => { this.clickViewUser(v[0]) }} />, $('.J_owningUser')[0])
} else if (k === 'sharingList') {
let list = $('<ul class="list-unstyled list-inline mb-0"></ul>').appendTo('.J_sharingList')
let _this = this
$(v).each(function () {
let _this = this
let $v = this
let item = $('<li class="list-inline-item"></li>').appendTo(list)
renderRbcomp(<UserShow id={_this[0]} name={_this[1]} avatarUrl={_this[2]} onClick={() => { this.clickViewUser(_this[0]) }} />, item[0])
renderRbcomp(<UserShow id={$v[0]} name={$v[1]} avatarUrl={$v[2]} onClick={() => { _this.clickViewUser($v[0]) }} />, item[0])
})
if (this.__ep && this.__ep.S === true) {

View file

@ -35,7 +35,7 @@ public class ChartsTest extends TestSupport {
@Test
public void testTable() throws Exception {
JSONObject config = JSON.parseObject(
"{'entity':'kehu','title':'表格','type':'TABLE','axis':{'dimension':[{'field':'modifiedOn','sort':'DESC','label':'','calc':'D'}],'numerical':[{'field':'kehumingcheng','sort':'NONE','label':'','calc':'COUNT'}]}}");
"{'entity':'testallfields','title':'未命名图表','type':'TABLE','axis':{'dimension':[],'numerical':[{'field':'testallfieldsName','sort':'NONE','label':'','calc':'COUNT'}]},'option':{'showLineNumber':'false','showSums':'false'}}");
ChartData index = ChartDataFactory.create(config, UserService.ADMIN_USER);
System.out.println(index.build());
}
@ -47,4 +47,20 @@ public class ChartsTest extends TestSupport {
ChartData index = ChartDataFactory.create(config, UserService.ADMIN_USER);
System.out.println(index.build());
}
@Test
public void testPie() throws Exception {
JSONObject config = JSON.parseObject(
"{'entity':'testallfields','title':'未命名图表','type':'PIE','axis':{'dimension':[{'field':'testallfieldsName','sort':'NONE','label':''}],'numerical':[{'field':'testallfieldsName','sort':'NONE','label':'','calc':'COUNT'}]},'option':{}}");
ChartData pie = ChartDataFactory.create(config, UserService.ADMIN_USER);
System.out.println(pie.build());
}
@Test
public void testLine() throws Exception {
JSONObject config = JSON.parseObject(
"{'entity':'testallfields','title':'未命名图表','type':'LINE','axis':{'dimension':[{'field':'createdOn','sort':'NONE','label':'','calc':'H'}],'numerical':[{'field':'testallfieldsName','sort':'NONE','label':'','calc':'COUNT'}]},'option':{}}");
ChartData line = ChartDataFactory.create(config, UserService.ADMIN_USER);
System.out.println(line.build());
}
}

View file

@ -18,6 +18,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
package com.rebuild.server.business.series;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
@ -59,8 +60,8 @@ public class SeriesGeneratorTest extends TestSupport {
@Test
public void testIncrementVarNThreads() throws Exception {
final IncreasingVar var = new IncreasingVar("0000", getSeriesField(), "Y");
final Set<String> set = new HashSet<>();
final int N = 500;
final Set<String> set = Collections.synchronizedSet(new HashSet<>());
final int N = 200;
for (int i = 0; i < N; i++) {
ThreadPool.exec(new Runnable() {
@Override

View file

@ -0,0 +1,35 @@
/*
rebuild - Building your system freely.
Copyright (C) 2019 devezhao <zhaofang123@gmail.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.rebuild.server.helper;
import org.junit.Assert;
import org.junit.Test;
/**
* @author devezhao zhaofang123@gmail.com
* @since 2019/03/08
*/
public class BlackListTest {
@Test
public void testInList() throws Exception {
Assert.assertTrue(BlackList.isBlack("admin"));
Assert.assertFalse(BlackList.isBlack("imnotadmin"));
}
}

View file

@ -0,0 +1,47 @@
/*
rebuild - Building your system freely.
Copyright (C) 2019 devezhao <zhaofang123@gmail.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.rebuild.server.helper;
import java.io.File;
import java.net.URL;
import org.junit.Test;
import com.rebuild.server.TestSupport;
/**
* @author devezhao zhaofang123@gmail.com
* @since 2019/03/08
*/
public class QiniuCloudTest extends TestSupport {
@Test
public void testUploadAndMakeUrl() throws Exception {
URL fileUrl = QiniuCloudTest.class.getClassLoader().getResource("blacklist.json");
File file = new File(fileUrl.toURI());
String uploadKey = QiniuCloud.instance().upload(file);
System.out.println("uploadKey ... " + uploadKey);
String downloadUrl = QiniuCloud.instance().url(uploadKey);
System.out.println("downloadUrl ... " + downloadUrl);
QiniuCloud.instance().delete(uploadKey);
}
}

View file

@ -0,0 +1,42 @@
/*
rebuild - Building your system freely.
Copyright (C) 2019 devezhao <zhaofang123@gmail.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.rebuild.server.helper;
import org.junit.Ignore;
import org.junit.Test;
import com.rebuild.server.TestSupport;
/**
* @author devezhao zhaofang123@gmail.com
* @since 2019/03/08
*/
@Ignore
public class SMSenderTest extends TestSupport {
@Test
public void testSendSMS() throws Exception {
SMSender.sendSMS("17301829039", "SMSenderTest#testSendSMS");
}
@Test
public void testSendMail() throws Exception {
SMSender.sendMail("getrebuild@sina.com", "SMSenderTest#testSendMail", "test content");
}
}

View file

@ -0,0 +1,38 @@
/*
rebuild - Building your system freely.
Copyright (C) 2019 devezhao <zhaofang123@gmail.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.rebuild.server.helper;
import org.junit.Test;
import com.rebuild.server.TestSupport;
/**
* @author devezhao zhaofang123@gmail.com
* @since 2019/03/08
*/
public class SystemConfigTest extends TestSupport {
@Test
public void testKnowConfig() throws Exception {
for (ConfigItem item : ConfigItem.values()) {
String v = SystemConfig.get(item);
System.out.println(item + " = " + v);
}
}
}

View file

@ -0,0 +1,39 @@
/*
rebuild - Building your system freely.
Copyright (C) 2019 devezhao <zhaofang123@gmail.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.rebuild.server.helper;
import org.junit.Assert;
import org.junit.Test;
import com.rebuild.server.TestSupport;
/**
* @author devezhao zhaofang123@gmail.com
* @since 2019/03/08
*/
public class VCodeTest extends TestSupport {
@Test
public void testCodeMatching() throws Exception {
String key = "testCodeMatching";
String vcode = VCode.generate(key);
boolean isMatch = VCode.verfiy(key, vcode);
Assert.assertTrue(isMatch);
}
}

View file

@ -0,0 +1,37 @@
/*
rebuild - Building your system freely.
Copyright (C) 2019 devezhao <zhaofang123@gmail.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.rebuild.server.helper.manager;
import org.junit.Test;
import com.rebuild.server.TestSupport;
import com.rebuild.server.service.bizz.UserService;
/**
* @author devezhao zhaofang123@gmail.com
* @since 2019/03/09
*/
public class AdvFilterManagerTest extends TestSupport {
@Test
public void testGetAdvFilterList() throws Exception {
Object[][] list = AdvFilterManager.getAdvFilterList("User", UserService.ADMIN_USER);
System.out.println("AdvFilterManager : " + list.length);
}
}

View file

@ -0,0 +1,38 @@
/*
rebuild - Building your system freely.
Copyright (C) 2019 devezhao <zhaofang123@gmail.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.rebuild.server.helper.manager;
import org.junit.Test;
import com.alibaba.fastjson.JSON;
import com.rebuild.server.TestSupport;
import com.rebuild.server.service.bizz.UserService;
/**
* @author devezhao zhaofang123@gmail.com
* @since 2019/03/09
*/
public class DashboardManagerTest extends TestSupport {
@Test
public void testGetList() throws Exception {
JSON dashs = DashboardManager.getDashList(UserService.ADMIN_USER);
System.out.println(dashs.toJSONString());
}
}

View file

@ -0,0 +1,64 @@
/*
rebuild - Building your system freely.
Copyright (C) 2019 devezhao <zhaofang123@gmail.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.rebuild.server.helper.manager;
import javax.servlet.http.HttpServletRequest;
import org.junit.Test;
import org.springframework.mock.web.MockServletContext;
import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.rebuild.server.TestSupport;
import com.rebuild.server.service.bizz.UserService;
import cn.devezhao.commons.web.WebUtils;
/**
* @author devezhao zhaofang123@gmail.com
* @since 2019/03/09
*/
public class NavManagerTest extends TestSupport {
@Test
public void testGetNav() throws Exception {
JSON nav = NavManager.getNav(UserService.ADMIN_USER);
System.out.println("testGetNav .......... \n" + nav.toJSONString());
}
@Test
public void testPortalNav() throws Exception {
MockHttpServletRequestBuilder builder = MockMvcRequestBuilders
.get("/rebuild")
.sessionAttr(WebUtils.CURRENT_USER, UserService.ADMIN_USER);
HttpServletRequest request = builder.buildRequest(new MockServletContext());
JSON navForPortal = NavManager.getNavForPortal(request);
System.out.println("testPortalNav .......... \n" + navForPortal.toJSONString());
if (!((JSONArray) navForPortal).isEmpty()) {
JSONObject firstNav = (JSONObject) ((JSONArray) navForPortal).get(0);
String navHtml = NavManager.renderNavItem(firstNav, "home", true);
System.out.println(navHtml);
}
}
}

View file

@ -0,0 +1,41 @@
/*
rebuild - Building your system freely.
Copyright (C) 2019 devezhao <zhaofang123@gmail.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.rebuild.server.helper.manager;
import org.junit.Test;
import com.alibaba.fastjson.JSON;
import com.rebuild.server.TestSupport;
import com.rebuild.server.metadata.MetadataHelper;
import cn.devezhao.persist4j.Field;
/**
* @author devezhao zhaofang123@gmail.com
* @since 2019/03/09
*/
public class PickListManagerTest extends TestSupport {
@Test
public void testGetPickList() throws Exception {
Field picklist = MetadataHelper.getEntity(TEST_ENTITY).getField("picklist");
JSON list = PickListManager.getPickList(picklist);
System.out.println(list.toJSONString());
}
}

View file

@ -21,6 +21,7 @@ package com.rebuild.web;
import org.apache.commons.lang.StringUtils;
import org.junit.Before;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.web.WebAppConfiguration;
@ -47,6 +48,8 @@ import cn.devezhao.persist4j.engine.ID;
@ContextConfiguration("classpath:application-web.xml")
@WebAppConfiguration
public class MvcTestSupport extends TestSupport {
public static final String UA_WIN10_CHROME = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36";
@Autowired
private WebApplicationContext context;
@ -87,7 +90,8 @@ public class MvcTestSupport extends TestSupport {
*/
protected MvcResponse perform(MockHttpServletRequestBuilder builder, ID user, boolean redirection) throws Exception {
builder.contentType("text/plain; charset=utf-8")
.accept(MediaType.APPLICATION_JSON_UTF8);
.accept(MediaType.APPLICATION_JSON_UTF8)
.header(HttpHeaders.USER_AGENT, UA_WIN10_CHROME);
if (user != null) {
builder.sessionAttr(WebUtils.CURRENT_USER, user);
}

View file

@ -0,0 +1,51 @@
/*
rebuild - Building your system freely.
Copyright (C) 2019 devezhao <zhaofang123@gmail.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.rebuild.web.admin.entityhub;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import com.rebuild.server.service.bizz.UserService;
import com.rebuild.web.MvcResponse;
import com.rebuild.web.MvcTestSupport;
import cn.devezhao.commons.web.WebUtils;
/**
* @author devezhao zhaofang123@gmail.com
* @since 2019/03/09
*/
@RunWith(SpringJUnit4ClassRunner.class)
public class FormDesignControllTest extends MvcTestSupport {
@Test
public void testPage() throws Exception {
MockHttpServletRequestBuilder builder = MockMvcRequestBuilders
.post("/admin/entity/User/form-design")
.sessionAttr(WebUtils.KEY_PREFIX + "-AdminVerified", "Mock");
MvcResponse resp = perform(builder, UserService.ADMIN_USER);
System.out.println(resp);
Assert.assertTrue(resp.isSuccess());
}
}

View file

@ -0,0 +1,73 @@
/*
rebuild - Building your system freely.
Copyright (C) 2019 devezhao <zhaofang123@gmail.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.rebuild.web.admin.entityhub;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import com.rebuild.server.service.bizz.UserService;
import com.rebuild.web.MvcResponse;
import com.rebuild.web.MvcTestSupport;
import cn.devezhao.commons.web.WebUtils;
/**
* @author devezhao zhaofang123@gmail.com
* @since 2019/03/09
*/
@RunWith(SpringJUnit4ClassRunner.class)
public class MetaEntityControllTest extends MvcTestSupport {
@Test
public void testPageEntities() throws Exception {
MockHttpServletRequestBuilder builder = MockMvcRequestBuilders
.get("/admin/entities")
.sessionAttr(WebUtils.KEY_PREFIX + "-AdminVerified", "Mock");
MvcResponse resp = perform(builder, UserService.ADMIN_USER);
System.out.println(resp);
Assert.assertTrue(resp.isSuccess());
}
@Test
public void testPageEntityList() throws Exception {
MockHttpServletRequestBuilder builder = MockMvcRequestBuilders
.get("/admin/entity/entity-list")
.sessionAttr(WebUtils.KEY_PREFIX + "-AdminVerified", "Mock");
MvcResponse resp = perform(builder, UserService.ADMIN_USER);
System.out.println(resp);
Assert.assertTrue(resp.isSuccess());
}
@Test
public void testPageEntityBase() throws Exception {
MockHttpServletRequestBuilder builder = MockMvcRequestBuilders
.get("/admin/entity/User/base")
.sessionAttr(WebUtils.KEY_PREFIX + "-AdminVerified", "Mock");
MvcResponse resp = perform(builder, UserService.ADMIN_USER);
System.out.println(resp);
Assert.assertTrue(resp.isSuccess());
}
}

View file

@ -0,0 +1,73 @@
/*
rebuild - Building your system freely.
Copyright (C) 2019 devezhao <zhaofang123@gmail.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.rebuild.web.admin.entityhub;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import com.rebuild.server.service.bizz.UserService;
import com.rebuild.web.MvcResponse;
import com.rebuild.web.MvcTestSupport;
import cn.devezhao.commons.web.WebUtils;
/**
* @author devezhao zhaofang123@gmail.com
* @since 2019/03/09
*/
@RunWith(SpringJUnit4ClassRunner.class)
public class MetaFieldControllTest extends MvcTestSupport {
@Test
public void testPageFields() throws Exception {
MockHttpServletRequestBuilder builder = MockMvcRequestBuilders
.get("/admin/entity/User/fields")
.sessionAttr(WebUtils.KEY_PREFIX + "-AdminVerified", "Mock");
MvcResponse resp = perform(builder, UserService.ADMIN_USER);
System.out.println(resp);
Assert.assertTrue(resp.isSuccess());
}
@Test
public void testListField() throws Exception {
MockHttpServletRequestBuilder builder = MockMvcRequestBuilders
.post("/admin/entity/list-field?entity=User")
.sessionAttr(WebUtils.KEY_PREFIX + "-AdminVerified", "Mock");
MvcResponse resp = perform(builder, UserService.ADMIN_USER);
System.out.println(resp);
Assert.assertTrue(resp.isSuccess());
}
@Test
public void testPageEntityField() throws Exception {
MockHttpServletRequestBuilder builder = MockMvcRequestBuilders
.get("/admin/entity/User/field/loginName")
.sessionAttr(WebUtils.KEY_PREFIX + "-AdminVerified", "Mock");
MvcResponse resp = perform(builder, UserService.ADMIN_USER);
System.out.println(resp);
Assert.assertTrue(resp.isSuccess());
}
}

View file

@ -29,6 +29,7 @@ import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.rebuild.server.Application;
import com.rebuild.server.service.bizz.UserService;
import com.rebuild.web.MvcResponse;
import com.rebuild.web.MvcTestSupport;
@ -66,7 +67,6 @@ public class GeneralRecordOperatorControllTest extends MvcTestSupport {
if (lastSaveId == null) {
return;
}
JSONObject fromJson = JSON.parseObject("{ TestAllFieldsName:'test2', metadata:{ entity:'TestAllFields', id:'' } }");
fromJson.getJSONObject("metadata").put("id", lastSaveId.toLiteral());
@ -96,6 +96,34 @@ public class GeneralRecordOperatorControllTest extends MvcTestSupport {
Assert.assertTrue(resp.isSuccess());
}
@Test
public void test5Unshare() throws Exception {
Object[] accessId = Application.createQueryNoFilter(
"select accessId from ShareAccess where belongEntity = ? and recordId = ? and shareTo = ?")
.setParameter(1, "TestAllFields")
.setParameter(2, lastSaveId)
.setParameter(3, UserService.SYSTEM_USER)
.unique();
if (accessId == null) {
return;
}
MockHttpServletRequestBuilder builder = MockMvcRequestBuilders
.post("/app/entity/record-unshare?record=" + lastSaveId + "&id=" + accessId[0]);
MvcResponse resp = perform(builder, UserService.ADMIN_USER);
System.out.println(resp);
Assert.assertTrue(resp.isSuccess());
}
@Test
public void test6FetchRecordMeta() throws Exception {
MockHttpServletRequestBuilder builder = MockMvcRequestBuilders
.post("/app/entity/record-meta?id=" + lastSaveId);
MvcResponse resp = perform(builder, UserService.ADMIN_USER);
System.out.println(resp);
Assert.assertTrue(resp.isSuccess());
}
@Test
public void test9Delete() throws Exception {
MockHttpServletRequestBuilder builder = MockMvcRequestBuilders

View file

@ -0,0 +1,47 @@
/*
rebuild - Building your system freely.
Copyright (C) 2019 devezhao <zhaofang123@gmail.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.rebuild.web.base.entity;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import com.rebuild.server.service.bizz.UserService;
import com.rebuild.web.MvcResponse;
import com.rebuild.web.MvcTestSupport;
/**
* @author devezhao zhaofang123@gmail.com
* @since 2019/03/09
*/
@RunWith(SpringJUnit4ClassRunner.class)
public class ReferenceSearchTest extends MvcTestSupport {
@Test
public void testSearch() throws Exception {
MockHttpServletRequestBuilder builder = MockMvcRequestBuilders
.post("/app/entity/search?entity=User&q=admin&qfields=loginName");
MvcResponse resp = perform(builder, UserService.ADMIN_USER);
System.out.println(resp);
Assert.assertTrue(resp.isSuccess());
}
}

View file

@ -0,0 +1,57 @@
/*
rebuild - Building your system freely.
Copyright (C) 2019 devezhao <zhaofang123@gmail.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.rebuild.web.base.entity;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import com.rebuild.server.service.bizz.DepartmentService;
import com.rebuild.server.service.bizz.UserService;
import com.rebuild.web.MvcResponse;
import com.rebuild.web.MvcTestSupport;
/**
* @author devezhao zhaofang123@gmail.com
* @since 2019/03/09
*/
@RunWith(SpringJUnit4ClassRunner.class)
public class RelatedListControllTest extends MvcTestSupport {
@Test
public void testrRelatedList() throws Exception {
MockHttpServletRequestBuilder builder = MockMvcRequestBuilders
.post("/app/entity/related-list?masterId=" + DepartmentService.ROOT_DEPT + "&related=User");
MvcResponse resp = perform(builder, UserService.ADMIN_USER);
System.out.println(resp);
Assert.assertTrue(resp.isSuccess());
}
@Test
public void testrRelatedCounts() throws Exception {
MockHttpServletRequestBuilder builder = MockMvcRequestBuilders
.post("/app/entity/related-counts?masterId=" + DepartmentService.ROOT_DEPT + "&relateds=User");
MvcResponse resp = perform(builder, UserService.ADMIN_USER);
System.out.println(resp);
Assert.assertTrue(resp.isSuccess());
}
}