sqoop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jar...@apache.org
Subject [2/2] sqoop git commit: SQOOP-2740: Sqoop2: Use name instead of id for ValidationResultBean
Date Thu, 17 Dec 2015 05:45:46 GMT
SQOOP-2740: Sqoop2: Use name instead of id for ValidationResultBean

(Colin Ma via Jarek Jarcec Cecho)


Project: http://git-wip-us.apache.org/repos/asf/sqoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/sqoop/commit/733da6bc
Tree: http://git-wip-us.apache.org/repos/asf/sqoop/tree/733da6bc
Diff: http://git-wip-us.apache.org/repos/asf/sqoop/diff/733da6bc

Branch: refs/heads/sqoop2
Commit: 733da6bc492ec809e8953c5a3cab325fcc127264
Parents: 9ac461c
Author: Jarek Jarcec Cecho <jarcec@apache.org>
Authored: Thu Dec 17 06:44:43 2015 +0100
Committer: Jarek Jarcec Cecho <jarcec@apache.org>
Committed: Thu Dec 17 06:44:43 2015 +0100

----------------------------------------------------------------------
 .../org/apache/sqoop/client/SqoopClient.java     | 12 ++++++------
 .../apache/sqoop/json/ValidationResultBean.java  | 19 +++++++++----------
 .../sqoop/json/TestValidationResultBean.java     | 14 +++++++-------
 .../apache/sqoop/handler/JobRequestHandler.java  |  2 +-
 .../apache/sqoop/handler/LinkRequestHandler.java |  2 +-
 .../sqoop/test/infrastructure/SqoopTestCase.java |  2 --
 .../sqoop/test/testcases/ConnectorTestCase.java  |  6 ++----
 .../server/InformalObjectNameTest.java           | 12 ++++++++----
 8 files changed, 34 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sqoop/blob/733da6bc/client/src/main/java/org/apache/sqoop/client/SqoopClient.java
----------------------------------------------------------------------
diff --git a/client/src/main/java/org/apache/sqoop/client/SqoopClient.java b/client/src/main/java/org/apache/sqoop/client/SqoopClient.java
index e71d3ef..bac7fe8 100644
--- a/client/src/main/java/org/apache/sqoop/client/SqoopClient.java
+++ b/client/src/main/java/org/apache/sqoop/client/SqoopClient.java
@@ -806,9 +806,9 @@ public class SqoopClient {
     ConfigValidationResult linkConfig = bean.getValidationResults()[0];
     // Apply validation results
     ConfigUtils.applyValidation(link.getConnectorLinkConfig(), linkConfig);
-    Long id = bean.getId();
-    if (id != null) {
-      link.setPersistenceId(id);
+    String linkName = bean.getName();
+    if (linkName != null) {
+      link.setName(linkName);
     }
     return Status.getWorstStatus(linkConfig.getStatus());
   }
@@ -830,9 +830,9 @@ public class SqoopClient {
       driver
     );
 
-    Long id = bean.getId();
-    if(id != null) {
-      job.setPersistenceId(id);
+    String jobName = bean.getName();
+    if(jobName != null) {
+      job.setName(jobName);
     }
 
     return Status.getWorstStatus(fromConfig.getStatus(), toConfig.getStatus(), driver.getStatus());

http://git-wip-us.apache.org/repos/asf/sqoop/blob/733da6bc/common/src/main/java/org/apache/sqoop/json/ValidationResultBean.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/json/ValidationResultBean.java b/common/src/main/java/org/apache/sqoop/json/ValidationResultBean.java
index b328a25..09ea847 100644
--- a/common/src/main/java/org/apache/sqoop/json/ValidationResultBean.java
+++ b/common/src/main/java/org/apache/sqoop/json/ValidationResultBean.java
@@ -38,12 +38,11 @@ import java.util.Set;
 public class ValidationResultBean implements JsonBean {
 
   private static final String VALIDATION_RESULT = "validation-result";
-  private static final String ID = "id";
   private static final String STATUS = "status";
   private static final String MESSAGE = "message";
 
   private ConfigValidationResult[] results;
-  private Long id;
+  private String name;
 
   public ValidationResultBean() {
     // Empty, for restore
@@ -60,12 +59,12 @@ public class ValidationResultBean implements JsonBean {
     return results.clone();
   }
 
-  public void setId(Long id) {
-    this.id = id;
+  public String getName() {
+    return name;
   }
 
-  public Long getId() {
-    return id;
+  public void setName(String name) {
+    this.name = name;
   }
 
   @SuppressWarnings("unchecked")
@@ -80,8 +79,8 @@ public class ValidationResultBean implements JsonBean {
 
     JSONObject object = new JSONObject();
     object.put(VALIDATION_RESULT, array);
-    if(id != null) {
-      object.put(ID, id);
+    if(name != null) {
+      object.put(NAME, name);
     }
     return object;
   }
@@ -124,8 +123,8 @@ public class ValidationResultBean implements JsonBean {
     for(Object item : array) {
       results[i++] = restoreValidationResult((JSONObject) item);
     }
-    if(jsonObject.containsKey(ID)) {
-      id = JSONUtils.getLong(jsonObject, ID);
+    if(jsonObject.containsKey(NAME)) {
+      name = JSONUtils.getString(jsonObject, NAME);
     }
   }
 

http://git-wip-us.apache.org/repos/asf/sqoop/blob/733da6bc/common/src/test/java/org/apache/sqoop/json/TestValidationResultBean.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/json/TestValidationResultBean.java b/common/src/test/java/org/apache/sqoop/json/TestValidationResultBean.java
index 0381c7d..8b50797 100644
--- a/common/src/test/java/org/apache/sqoop/json/TestValidationResultBean.java
+++ b/common/src/test/java/org/apache/sqoop/json/TestValidationResultBean.java
@@ -71,11 +71,11 @@ public class TestValidationResultBean {
 
   @Test
   public void testId() {
-    long id = transfer(10L);
-    assertEquals(10L, id);
+    String name = transfer("testName");
+    assertEquals("testName", name);
 
-    Long idNull = transfer((Long)null);
-    assertNull(idNull);
+    String nameNull = transfer((String)null);
+    assertNull(nameNull);
   }
 
   public void verifyResultA(ConfigValidationResult result) {
@@ -107,9 +107,9 @@ public class TestValidationResultBean {
   }
 
 
-  private Long transfer(Long id) {
+  private String transfer(String name) {
     ValidationResultBean bean = new ValidationResultBean(new ConfigValidationResult[0]);
-    bean.setId(id);
+    bean.setName(name);
     JSONObject json = bean.extract(false);
 
     String string = json.toString();
@@ -118,7 +118,7 @@ public class TestValidationResultBean {
     ValidationResultBean retrievedBean = new ValidationResultBean();
     retrievedBean.restore(retrievedJson);
 
-    return retrievedBean.getId();
+    return retrievedBean.getName();
   }
 
   private ConfigValidationResult[] transfer(ConfigValidationResult [] results) {

http://git-wip-us.apache.org/repos/asf/sqoop/blob/733da6bc/server/src/main/java/org/apache/sqoop/handler/JobRequestHandler.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/sqoop/handler/JobRequestHandler.java b/server/src/main/java/org/apache/sqoop/handler/JobRequestHandler.java
index 666116e..7fa6a3b 100644
--- a/server/src/main/java/org/apache/sqoop/handler/JobRequestHandler.java
+++ b/server/src/main/java/org/apache/sqoop/handler/JobRequestHandler.java
@@ -250,7 +250,7 @@ public class JobRequestHandler implements RequestHandler {
         postedJob.setCreationUser(username);
         postedJob.setLastUpdateUser(username);
         repository.createJob(postedJob);
-        validationResultBean.setId(postedJob.getPersistenceId());
+        validationResultBean.setName(postedJob.getName());
       } else {
         AuditLoggerManager.getInstance().logAuditEvent(ctx.getUserName(),
             ctx.getRequest().getRemoteAddr(), "update", "job",

http://git-wip-us.apache.org/repos/asf/sqoop/blob/733da6bc/server/src/main/java/org/apache/sqoop/handler/LinkRequestHandler.java
----------------------------------------------------------------------
diff --git a/server/src/main/java/org/apache/sqoop/handler/LinkRequestHandler.java b/server/src/main/java/org/apache/sqoop/handler/LinkRequestHandler.java
index cc07fc8..189293a 100644
--- a/server/src/main/java/org/apache/sqoop/handler/LinkRequestHandler.java
+++ b/server/src/main/java/org/apache/sqoop/handler/LinkRequestHandler.java
@@ -174,7 +174,7 @@ public class LinkRequestHandler implements RequestHandler {
         postedLink.setCreationUser(username);
         postedLink.setLastUpdateUser(username);
         repository.createLink(postedLink);
-        linkValidationBean.setId(postedLink.getPersistenceId());
+        linkValidationBean.setName(postedLink.getName());
       } else {
         AuditLoggerManager.getInstance().logAuditEvent(ctx.getUserName(),
             ctx.getRequest().getRemoteAddr(), "update", "link",

http://git-wip-us.apache.org/repos/asf/sqoop/blob/733da6bc/test/src/main/java/org/apache/sqoop/test/infrastructure/SqoopTestCase.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/sqoop/test/infrastructure/SqoopTestCase.java b/test/src/main/java/org/apache/sqoop/test/infrastructure/SqoopTestCase.java
index fc7e172..dbe2195 100644
--- a/test/src/main/java/org/apache/sqoop/test/infrastructure/SqoopTestCase.java
+++ b/test/src/main/java/org/apache/sqoop/test/infrastructure/SqoopTestCase.java
@@ -361,7 +361,6 @@ public class SqoopTestCase implements ITest {
   public void saveLink(MLink link) {
     SqoopUtils.fillObjectName(link);
     assertEquals(Status.OK, getClient().saveLink(link));
-    assertNotSame(MPersistableEntity.PERSISTANCE_ID_DEFAULT, link.getPersistenceId());
   }
 
   /**
@@ -372,7 +371,6 @@ public class SqoopTestCase implements ITest {
   public void saveJob(MJob job) {
     SqoopUtils.fillObjectName(job);
     assertEquals(Status.OK, getClient().saveJob(job));
-    assertNotSame(MPersistableEntity.PERSISTANCE_ID_DEFAULT, job.getPersistenceId());
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/sqoop/blob/733da6bc/test/src/main/java/org/apache/sqoop/test/testcases/ConnectorTestCase.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/sqoop/test/testcases/ConnectorTestCase.java b/test/src/main/java/org/apache/sqoop/test/testcases/ConnectorTestCase.java
index 378c1f3..f071786 100644
--- a/test/src/main/java/org/apache/sqoop/test/testcases/ConnectorTestCase.java
+++ b/test/src/main/java/org/apache/sqoop/test/testcases/ConnectorTestCase.java
@@ -242,7 +242,6 @@ abstract public class  ConnectorTestCase extends JettyTestCase {
   protected void saveLink(MLink link) {
     SqoopUtils.fillObjectName(link);
     assertEquals(getClient().saveLink(link), Status.OK);
-    assertNotSame(link.getPersistenceId(), MPersistableEntity.PERSISTANCE_ID_DEFAULT);
   }
 
  /**
@@ -255,13 +254,12 @@ abstract public class  ConnectorTestCase extends JettyTestCase {
  protected void saveJob(MJob job) {
    SqoopUtils.fillObjectName(job);
    assertEquals(getClient().saveJob(job), Status.OK);
-   assertNotSame(job.getPersistenceId(), MPersistableEntity.PERSISTANCE_ID_DEFAULT);
   }
 
   /**
-   * Run job with given jid.
+   * Run job with given job name.
    *
-   * @param jid Job id
+   * @param jobName Job Name
    * @throws Exception
    */
   protected void executeJob(String jobName) throws Exception {

http://git-wip-us.apache.org/repos/asf/sqoop/blob/733da6bc/test/src/test/java/org/apache/sqoop/integration/server/InformalObjectNameTest.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/sqoop/integration/server/InformalObjectNameTest.java
b/test/src/test/java/org/apache/sqoop/integration/server/InformalObjectNameTest.java
index cb8c5de..1056f12 100644
--- a/test/src/test/java/org/apache/sqoop/integration/server/InformalObjectNameTest.java
+++ b/test/src/test/java/org/apache/sqoop/integration/server/InformalObjectNameTest.java
@@ -87,8 +87,10 @@ public class InformalObjectNameTest extends SqoopTestCase {
     fillRdbmsLinkConfig(rdbmsLink);
     rdbmsLink.setName(linkName);
     saveLink(rdbmsLink);
-    // read link
-    assertEquals(rdbmsLink, getClient().getLink(linkName));
+    // read link, copy the id to current link, then do the compare.
+    MLink repositoryLink = getClient().getLink(linkName);
+    rdbmsLink.setPersistenceId(repositoryLink.getPersistenceId());
+    assertEquals(rdbmsLink, repositoryLink);
 
     // update link
     getClient().updateLink(rdbmsLink);
@@ -130,8 +132,10 @@ public class InformalObjectNameTest extends SqoopTestCase {
     job.setName(jobName);
     saveJob(job);
 
-    // read job
-    assertEquals(job, getClient().getJob(jobName));
+    // read job, copy the id to current job, then do the compare.
+    MJob repositoryJob = getClient().getJob(jobName);
+    job.setPersistenceId(repositoryJob.getPersistenceId());
+    assertEquals(job, repositoryJob);
 
     // update job
     getClient().updateJob(job);


Mime
View raw message