Collector
This commit is contained in:
		
							parent
							
								
									d6e3450e2b
								
							
						
					
					
						commit
						d4861a8c95
					
				| @ -1,4 +1,4 @@ | |||||||
| package com.loafle.bridge.collector.entity; | package com.loafle.bridge.collector; | ||||||
| 
 | 
 | ||||||
| import javax.persistence.*; | import javax.persistence.*; | ||||||
| import java.util.Date; | import java.util.Date; | ||||||
| @ -7,14 +7,6 @@ import java.util.Date; | |||||||
|  * Created by root on 16. 11. 15. |  * Created by root on 16. 11. 15. | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| enum License { |  | ||||||
|     LICENSE1, |  | ||||||
|     LICENSE2, |  | ||||||
|     LICENSE3, |  | ||||||
|     LICENSE4, |  | ||||||
|     LICENSE5; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| @Entity | @Entity | ||||||
| public class Collector { | public class Collector { | ||||||
| 
 | 
 | ||||||
| @ -25,14 +17,11 @@ public class Collector { | |||||||
|     @Column(nullable = false) |     @Column(nullable = false) | ||||||
|     private String productId; |     private String productId; | ||||||
| 
 | 
 | ||||||
|     @Column(columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", nullable = false, insertable = false, updatable = false) |     @Column(nullable = false) | ||||||
|     private Date installedDate; |     private String version; | ||||||
| 
 |  | ||||||
|     @Column(columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP") |  | ||||||
|     private Date updatedDate; |  | ||||||
| 
 | 
 | ||||||
|     @Enumerated(EnumType.STRING) |     @Enumerated(EnumType.STRING) | ||||||
|     private License licenseType; |     private LicenseType licenseType; | ||||||
| 
 | 
 | ||||||
|     @Column(columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP") |     @Column(columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP") | ||||||
|     private Date licenseDueDate; |     private Date licenseDueDate; | ||||||
| @ -40,8 +29,11 @@ public class Collector { | |||||||
|     @Column(nullable = false) |     @Column(nullable = false) | ||||||
|     private String configPath; |     private String configPath; | ||||||
| 
 | 
 | ||||||
|     @Column(nullable = false) |     @Column(columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP", nullable = false) | ||||||
|     private String collectorVersion; |     private Date installDate; | ||||||
|  | 
 | ||||||
|  |     @Column(columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP") | ||||||
|  |     private Date updateDate; | ||||||
| 
 | 
 | ||||||
|     public Collector() { |     public Collector() { | ||||||
|     } |     } | ||||||
| @ -62,19 +54,27 @@ public class Collector { | |||||||
|         this.productId = productId; |         this.productId = productId; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public Date getInstalledDate() { |     public Date getInstallDate() { | ||||||
|         return installedDate; |         return installDate; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public void setInstalledDate(Date installedDate) { |     public void setInstallDate(Date installDate) { | ||||||
|         this.installedDate = installedDate; |         this.installDate = installDate; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public License getLicenseType() { |     public Date getUpdateDate() { | ||||||
|  |         return updateDate; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public void setUpdateDate(Date updateDate) { | ||||||
|  |         this.updateDate = updateDate; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     public LicenseType getLicenseType() { | ||||||
|         return licenseType; |         return licenseType; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public void setLicenseType(License licenseType) { |     public void setLicenseType(LicenseType licenseType) { | ||||||
|         this.licenseType = licenseType; |         this.licenseType = licenseType; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -94,19 +94,11 @@ public class Collector { | |||||||
|         this.configPath = configPath; |         this.configPath = configPath; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public String getCollectorVersion() { |     public String getVersion() { | ||||||
|         return collectorVersion; |         return version; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public void setCollectorVersion(String collectorVersion) { |     public void setVersion(String version) { | ||||||
|         this.collectorVersion = collectorVersion; |         this.version = version; | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     public Date getUpdatedDate() { |  | ||||||
|         return updatedDate; |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     public void setUpdatedDate(Date updatedDate) { |  | ||||||
|         this.updatedDate = updatedDate; |  | ||||||
|     } |     } | ||||||
| } | } | ||||||
| @ -1,4 +1,4 @@ | |||||||
| package com.loafle.bridge.collector.controller; | package com.loafle.bridge.collector; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * Created by root on 16. 11. 15. |  * Created by root on 16. 11. 15. | ||||||
| @ -1,6 +1,6 @@ | |||||||
| package com.loafle.bridge.collector.repository; | package com.loafle.bridge.collector; | ||||||
| 
 | 
 | ||||||
| import com.loafle.bridge.collector.entity.Collector; | import com.loafle.bridge.collector.Collector; | ||||||
| import org.springframework.data.jpa.repository.JpaRepository; | import org.springframework.data.jpa.repository.JpaRepository; | ||||||
| import org.springframework.data.rest.core.annotation.RepositoryRestResource; | import org.springframework.data.rest.core.annotation.RepositoryRestResource; | ||||||
| 
 | 
 | ||||||
							
								
								
									
										21
									
								
								src/main/java/com/loafle/bridge/collector/LicenseType.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								src/main/java/com/loafle/bridge/collector/LicenseType.java
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,21 @@ | |||||||
|  | package com.loafle.bridge.collector; | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * Created by root on 16. 11. 16. | ||||||
|  |  */ | ||||||
|  | public enum LicenseType { | ||||||
|  | 
 | ||||||
|  |     LICENSE1("License 1"), | ||||||
|  |     LICENSE2("License 2"), | ||||||
|  |     LICENSE3("License 3"), | ||||||
|  |     LICENSE4("License 4"), | ||||||
|  |     LICENSE5("License 5"); | ||||||
|  | 
 | ||||||
|  |     private String stringValue; | ||||||
|  |     LicenseType(String string) {stringValue = string;} | ||||||
|  | 
 | ||||||
|  |     @Override | ||||||
|  |     public String toString() { | ||||||
|  |         return stringValue; | ||||||
|  |     } | ||||||
|  | } | ||||||
| @ -0,0 +1,66 @@ | |||||||
|  | package com.loafle.bridge.collector; | ||||||
|  | 
 | ||||||
|  | import com.loafle.bridge.Application; | ||||||
|  | import org.apache.log4j.Logger; | ||||||
|  | import org.junit.After; | ||||||
|  | import org.junit.Test; | ||||||
|  | import org.junit.runner.RunWith; | ||||||
|  | import org.springframework.beans.factory.annotation.Autowired; | ||||||
|  | import org.springframework.test.context.ContextConfiguration; | ||||||
|  | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; | ||||||
|  | 
 | ||||||
|  | import java.util.Date; | ||||||
|  | 
 | ||||||
|  | import static org.junit.Assert.assertEquals; | ||||||
|  | 
 | ||||||
|  | /** | ||||||
|  |  * Created by root on 16. 11. 15. | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | @RunWith(SpringJUnit4ClassRunner.class) | ||||||
|  | @ContextConfiguration(classes = Application.class) | ||||||
|  | public class CollectorRepositoryTest { | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |     @Autowired | ||||||
|  |     private CollectorRepository repo; | ||||||
|  | 
 | ||||||
|  |     Logger l = Logger.getLogger(this.getClass()); | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | //    @Before | ||||||
|  | //    public void Before() { | ||||||
|  | //        Collector c = new Collector(); | ||||||
|  | //        c.setCollectorVersion("1.0.0"); | ||||||
|  | //        c.setConfigPath("/root"); | ||||||
|  | //        c.setInstalledDate(new Date()); | ||||||
|  | //        c.setLicenseDueDate(new Date()); | ||||||
|  | //        c.setProductId("1111111"); | ||||||
|  | //        repo.save(c); | ||||||
|  | //    } | ||||||
|  | 
 | ||||||
|  |     @After | ||||||
|  |     public void After() { | ||||||
|  |         repo.deleteAll(); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     @Test | ||||||
|  |     public void TestInsertPort() { | ||||||
|  | 
 | ||||||
|  |         Collector c = new Collector(); | ||||||
|  |         c.setVersion("1.0.0"); | ||||||
|  |         c.setConfigPath("/root"); | ||||||
|  |         c.setInstallDate(new Date()); | ||||||
|  |         c.setUpdateDate(new Date()); | ||||||
|  |         c.setLicenseDueDate(new Date()); | ||||||
|  |         c.setProductId("1111111"); | ||||||
|  |         repo.save(c); | ||||||
|  | 
 | ||||||
|  |         Collector res = repo.findOne(c.getId()); | ||||||
|  | 
 | ||||||
|  |         assertEquals(c.getId(),res.getId()); | ||||||
|  | 
 | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | } | ||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user