Commit 5ed45a67 by Yiming Liu

Merge pull request #5 from yiming187/lombok_update

Portal Test Configuration update
parents d1771497 30bade80
......@@ -11,8 +11,12 @@
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
# Eclipse
.classpath
.project
target
.settings
# Idea
.idea
*.iml
\ No newline at end of file
package com.ctrip.apollo.portal.controller;
import java.util.Date;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.web.PageableDefault;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
......@@ -19,14 +21,13 @@ public class AppController {
private AppRepository appRepository;
@RequestMapping("")
public Page<App> list() {
Pageable pageable = new PageRequest(0, 10);
public Page<App> list(@PageableDefault(size = 50) Pageable pageable) {
return appRepository.findAll(pageable);
}
@RequestMapping(value = "", method = RequestMethod.POST)
public App create() {
App ramdomApp = new App();
return appRepository.save(ramdomApp);
public App create(App app) {
app.setCreateTimestamp(new Date());
return appRepository.save(app);
}
}
......@@ -7,10 +7,7 @@ import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import lombok.Data;
@Entity
@Data
public class App implements Serializable {
/**
......@@ -38,4 +35,60 @@ public class App implements Serializable {
@Column
private Date lastUpdatedTimestamp;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getOwner() {
return owner;
}
public void setOwner(String owner) {
this.owner = owner;
}
public String getOwnerPhone() {
return ownerPhone;
}
public void setOwnerPhone(String ownerPhone) {
this.ownerPhone = ownerPhone;
}
public String getOwnerMail() {
return ownerMail;
}
public void setOwnerMail(String ownerMail) {
this.ownerMail = ownerMail;
}
public Date getCreateTimestamp() {
return createTimestamp;
}
public void setCreateTimestamp(Date createTimestamp) {
this.createTimestamp = createTimestamp;
}
public Date getLastUpdatedTimestamp() {
return lastUpdatedTimestamp;
}
public void setLastUpdatedTimestamp(Date lastUpdatedTimestamp) {
this.lastUpdatedTimestamp = lastUpdatedTimestamp;
}
}
package com.ctrip.apollo.portal;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class PortalApplicationTestConfiguration {
}
package com.ctrip.apollo.portal.repository;
import java.util.Date;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import com.ctrip.apollo.portal.PortalApplicationTestConfiguration;
import com.ctrip.apollo.portal.entities.App;
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = PortalApplicationTestConfiguration.class)
public class AppRepositoryTest {
@Autowired
AppRepository repository;
@Test
public void testCreate() {
Assert.assertEquals(0, repository.count());
App ramdomApp = new App();
ramdomApp.setId(String.valueOf(System.currentTimeMillis()));
ramdomApp.setName("new app " + System.currentTimeMillis());
ramdomApp.setOwner("owner " + System.currentTimeMillis());
ramdomApp.setCreateTimestamp(new Date());
repository.save(ramdomApp);
Assert.assertEquals(1, repository.count());
}
}
......@@ -15,13 +15,6 @@
<module>apollo-portal</module>
<module>apollo-assembly</module>
</modules>
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
......@@ -47,11 +40,6 @@
<artifactId>mysql-connector-java</artifactId>
<version>5.1.38</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.8</version>
</dependency>
<!--for test -->
<dependency>
<groupId>com.h2database</groupId>
......@@ -111,7 +99,7 @@
<plugin>
<groupId>org.eluder.coveralls</groupId>
<artifactId>coveralls-maven-plugin</artifactId>
<version>3.1.0</version>
<version>4.1.0</version>
</plugin>
</plugins>
</build>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment