@Test
  public void testRemoveColumn() throws IOException, ExecutionException, InterruptedException {
    Table table = Table.open("Keyspace1");
    ColumnFamilyStore store = table.getColumnFamilyStore("Standard1");
    RowMutation rm;
    DecoratedKey dk = Util.dk("key1");

    // add data
    rm = new RowMutation("Keyspace1", dk.key);
    rm.add(
        new QueryPath("Standard1", null, "Column1".getBytes()),
        "asdf".getBytes(),
        new TimestampClock(0));
    rm.apply();
    store.forceBlockingFlush();

    // remove
    rm = new RowMutation("Keyspace1", dk.key);
    rm.delete(new QueryPath("Standard1", null, "Column1".getBytes()), new TimestampClock(1));
    rm.apply();

    ColumnFamily retrieved =
        store.getColumnFamily(
            QueryFilter.getNamesFilter(dk, new QueryPath("Standard1"), "Column1".getBytes()));
    assert retrieved.getColumn("Column1".getBytes()).isMarkedForDelete();
    assertNull(Util.cloneAndRemoveDeleted(retrieved, Integer.MAX_VALUE));
    assertNull(
        Util.cloneAndRemoveDeleted(
            store.getColumnFamily(QueryFilter.getIdentityFilter(dk, new QueryPath("Standard1"))),
            Integer.MAX_VALUE));
  }
  /** Verify {@link BaseProjectProperty#getValue()} method. */
  @Test
  public void testGetValue() {
    Integer propertyValue = 10;
    property.setValue(propertyValue);
    // if value is not null - return it
    assertEquals(propertyValue, property.getValue());
    property.setValue(null);
    assertNull(property.getValue());

    BaseProjectProperty parentProperty = new BaseProjectProperty(parent);
    parentProperty.setKey(propertyKey);
    parentProperty.setValue(propertyValue);
    parent.putProjectProperty(propertyKey, parentProperty);

    project.setCascadingProject(parent);
    property = new BaseProjectProperty(project);
    property.setKey(propertyKey);
    // if current value is null and is not overridden value, take from cascading
    assertNull(property.getOriginalValue());
    assertEquals(propertyValue, property.getValue());

    property.setOverridden(true);
    // Property is overridden - return current value even if it is null.
    assertNull(property.getOriginalValue());
    assertNull(property.getValue());
  }
  public void testDeleteObjectWithInheritAssociatedObjects() {
    log.debug("\n------testDeleteObjectWithInheritAssociatedObjects()--------\n");
    SportsShoes sportsShoes = new SportsShoes();
    sportsShoes.setColor("sportsColor");
    sportsShoes.setSportsType("Sports");

    DesignerShoes designerShoes = new DesignerShoes();
    designerShoes.setColor("designerColor");
    Designer designer = new Designer();
    designer.setName("designer");
    designerShoes.setDesigner(designer);

    save(designer);
    save(sportsShoes);
    save(designerShoes);

    SportsShoes deleteSportShoes = (SportsShoes) getObject(SportsShoes.class, sportsShoes.getId());
    DesignerShoes deleteDesignerShoes =
        (DesignerShoes)
            getObjectAndLazyObject(DesignerShoes.class, designerShoes.getId(), "designer");

    delete(deleteSportShoes);
    delete(deleteDesignerShoes);

    SportsShoes resultSportShoes =
        (SportsShoes) getObject(SportsShoes.class, deleteSportShoes.getId());
    DesignerShoes resultDesignerShoes =
        (DesignerShoes)
            getObjectAndLazyObject(DesignerShoes.class, deleteDesignerShoes.getId(), "designer");
    Designer resultDesigner = (Designer) getObject(Designer.class, designer.getId());
    Assert.assertNull(resultSportShoes);
    Assert.assertNull(resultDesignerShoes);
    Assert.assertEquals(designer.getName(), resultDesigner.getName());
  }
  @Test
  public void deleteStudy_shouldDeleteGivenStudy() throws Exception {

    final String studyName = "Study Name";

    List<StudyDef> studies = studyManagerService.getStudies();
    Assert.assertEquals("There are 4 studies", 4, studies.size());
    Assert.assertNull(getStudy(studyName, studies));

    StudyDef study = new StudyDef();
    study.setName(studyName);
    study.setCreator(userService.getUsers().get(0));
    study.setDateCreated(new Date());

    studyManagerService.saveStudy(study);
    studies = studyManagerService.getStudies();
    Assert.assertEquals("Added 1 study, now there are 5", 5, studies.size());

    study = getStudy(studyName, studies);
    Assert.assertNotNull(study);

    studyManagerService.deleteStudy(study);

    studies = studyManagerService.getStudies();
    Assert.assertEquals("Deleted the study so there are 4 studies again", 4, studies.size());
    Assert.assertNull(getStudy(studyName, studies));
  }
Example #5
0
  public void testSuccessfulEditPreview() throws Exception {
    fee =
        TestObjectFactory.createOneTimeAmountFee(
            "One Time Fee", FeeCategory.ALLCUSTOMERS, "100", FeePayment.UPFRONT);
    request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
    SessionUtils.setAttribute(Constants.BUSINESS_KEY, fee, request);
    setRequestPathInfo("/feeaction.do");
    addRequestParameter("method", "manage");
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();

    setRequestPathInfo("/feeaction.do");
    addRequestParameter("method", "editPreview");
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    addRequestParameter("amount", "200.0");
    addRequestParameter("feeStatus", FeeStatus.INACTIVE.getValue().toString());
    actionPerform();
    verifyNoActionErrors();
    verifyForward(ActionForwards.editPreview_success.toString());

    FeeActionForm actionForm = (FeeActionForm) request.getSession().getAttribute("feeactionform");
    Assert.assertEquals("200.0", actionForm.getAmount());
    Assert.assertEquals(FeeStatus.INACTIVE, actionForm.getFeeStatusValue());
    Assert.assertNull(actionForm.getRate());
    Assert.assertNull(actionForm.getFeeFormula());
  }
Example #6
0
  public void testSuccessfulManage_AmountFee() throws Exception {
    fee =
        TestObjectFactory.createOneTimeAmountFee(
            "One Time Fee", FeeCategory.ALLCUSTOMERS, "100.0", FeePayment.UPFRONT);
    request.setAttribute(Constants.CURRENTFLOWKEY, flowKey);
    SessionUtils.setAttribute(Constants.BUSINESS_KEY, fee, request);
    setRequestPathInfo("/feeaction.do");
    addRequestParameter("method", "manage");
    addRequestParameter(Constants.CURRENTFLOWKEY, flowKey);
    actionPerform();
    verifyNoActionErrors();
    verifyNoActionMessages();
    verifyForward(ActionForwards.manage_success.toString());

    FeeActionForm actionForm = (FeeActionForm) request.getSession().getAttribute("feeactionform");
    Assert.assertEquals("100.0", actionForm.getAmount());
    Assert.assertNull(actionForm.getRate());
    Assert.assertNull(actionForm.getFeeFormula());

    Assert.assertEquals(
        "The size of master data for status",
        2,
        ((List<MasterDataEntity>) SessionUtils.getAttribute(FeeConstants.STATUSLIST, request))
            .size());
  }
  @Test
  public void testFindNextToCompact() throws Exception {
    CompactionRequest rqst = new CompactionRequest("foo", "bar", CompactionType.MINOR);
    rqst.setPartitionname("ds=today");
    txnHandler.compact(rqst);
    long now = System.currentTimeMillis();
    CompactionInfo ci = txnHandler.findNextToCompact("fred");
    assertNotNull(ci);
    assertEquals("foo", ci.dbname);
    assertEquals("bar", ci.tableName);
    assertEquals("ds=today", ci.partName);
    assertEquals(CompactionType.MINOR, ci.type);
    assertNull(ci.runAs);
    assertNull(txnHandler.findNextToCompact("fred"));

    txnHandler.setRunAs(ci.id, "bob");

    ShowCompactResponse rsp = txnHandler.showCompact(new ShowCompactRequest());
    List<ShowCompactResponseElement> compacts = rsp.getCompacts();
    assertEquals(1, compacts.size());
    ShowCompactResponseElement c = compacts.get(0);
    assertEquals("foo", c.getDbname());
    assertEquals("bar", c.getTablename());
    assertEquals("ds=today", c.getPartitionname());
    assertEquals(CompactionType.MINOR, c.getType());
    assertEquals("working", c.getState());
    assertTrue(c.getStart() - 5000 < now && c.getStart() + 5000 > now);
    assertEquals("fred", c.getWorkerid());
    assertEquals("bob", c.getRunAs());
  }
  public void testIdTagSingleRetrieval() {
    DefaultIdTagManager m = getManager();
    IdTag t = m.newIdTag("ID0413276BC1", "Test Tag");

    Assert.assertNotNull("Returned IdTag is not null", t);

    Assert.assertNotNull("Get by system name is not null", m.getBySystemName("ID0413276BC1"));
    Assert.assertNotNull("Get by user name is not null", m.getByUserName("Test Tag"));
    Assert.assertNotNull("Get by tag id is not null", m.getByTagID("0413276BC1"));

    Assert.assertNotNull("Get IdTag using system name is not null", m.getIdTag("ID0413276BC1"));
    Assert.assertNotNull("Get IdTag using user name is not null", m.getIdTag("Test Tag"));
    Assert.assertNotNull("Get IdTag using tag id is not null", m.getIdTag("0413276BC1"));

    Assert.assertTrue(
        "Matching IdTag returned from manager by system name",
        t.getSystemName().equals(m.getBySystemName("ID0413276BC1").getSystemName()));
    Assert.assertTrue(
        "Matching IdTag returned from manager by user name",
        t.getUserName().equals(m.getByUserName("Test Tag").getUserName()));
    Assert.assertTrue(
        "Matching IdTag returned from manager by tag id",
        t.getTagID().equals(m.getByTagID("0413276BC1").getTagID()));

    Assert.assertNull(
        "Null Object returned from manager by system name", m.getBySystemName("ID99999999"));
    Assert.assertNull(
        "Null Object returned from manager by user name", m.getBySystemName("This doesn't exist"));
    Assert.assertNull(
        "Null Object returned from manager by tagID", m.getBySystemName("XXXXXXXXXX"));
  }
  @Test
  public void testGetValue() {
    WEmailField field = new WEmailField();
    field.setLocked(true);

    setActiveContext(createUIContext());

    // Set data as a null value
    field.setData(null);
    Assert.assertNull("getValue should return null when data is null", field.getValue());

    // Set data as a empty string
    field.setData("");
    Assert.assertNull("getValue should return null when data is an empty string", field.getValue());

    // Set data as a String value
    field.setData("A");
    Assert.assertEquals(
        "getValue returned the incorrect value for the data", "A", field.getValue());

    // Set data as an Object
    Object object = new Date();
    field.setData(object);
    Assert.assertEquals(
        "getValue should return the string value of the data", object.toString(), field.getValue());
  }
  @Test
  public void testRemoveColumnFamily()
      throws IOException, ExecutionException, InterruptedException {
    Table table = Table.open("Keyspace1");
    ColumnFamilyStore store = table.getColumnFamilyStore("Standard1");
    RowMutation rm;

    // add data
    rm = new RowMutation("Keyspace1", "key1");
    rm.add(new QueryPath("Standard1", null, "Column1".getBytes()), "asdf".getBytes(), 0);
    rm.apply();

    // remove
    rm = new RowMutation("Keyspace1", "key1");
    rm.delete(new QueryPath("Standard1"), 1);
    rm.apply();

    ColumnFamily retrieved =
        store.getColumnFamily(
            new IdentityQueryFilter(
                "key1", new QueryPath("Standard1", null, "Column1".getBytes())));
    assert retrieved.isMarkedForDelete();
    assertNull(retrieved.getColumn("Column1".getBytes()));
    assertNull(ColumnFamilyStore.removeDeleted(retrieved, Integer.MAX_VALUE));
  }
Example #11
0
  private void testNonRedirectingStringPost(String url) throws Exception {
    // test a non-redirecting servlet
    String content = "postContent";
    String contentType = "text/xml";
    HttpPost httpPost = new HttpPost(new URL(url + "?redirect=false"), content, contentType, false);
    httpPost.setMaxRetries(4);
    httpPost.run();
    log.debug("throwable: " + httpPost.getThrowable());
    Assert.assertNull("Wrong throwable", httpPost.getThrowable());
    Assert.assertEquals("Wrong size", "postContent".length(), httpPost.getResponseBody().length());
    Assert.assertEquals("Wrong content", "postContent", httpPost.getResponseBody());
    Assert.assertNull("Wrong redirect URL", httpPost.getRedirectURL());
    Assert.assertEquals("Wrong number of retries.", 2, httpPost.getRetriesPerformed());

    // same test but with the test servlet redirecting
    httpPost = new HttpPost(new URL(url + "?redirect=true"), content, contentType, false);
    httpPost.setMaxRetries(4);
    httpPost.run();
    Assert.assertNull("Wrong content", httpPost.getResponseBody());
    Assert.assertEquals(
        "Wrong redirect URL size",
        (url + "?post=true").length(),
        httpPost.getRedirectURL().toString().length());
    Assert.assertEquals(
        "Wrong redirect URL", url + "?post=true", httpPost.getRedirectURL().toString());
    Assert.assertEquals("Wrong number of retries.", 2, httpPost.getRetriesPerformed());
    Assert.assertNull("Wrong throwable", httpPost.getThrowable());
  }
Example #12
0
  @Test
  public void testBatchChangeKeyByDepartment() {
    Department department = new Department();
    Employee employee1 = new Employee();
    Employee employee2 = new Employee();
    Employee employee3 = new Employee();
    department.getEmployees().put("I", employee1);
    department.getEmployees().put("II", employee2);
    department.getEmployees().put("III", employee3);
    Utils.assertCollection(department.getEmployees().keySet(), "I", "II", "III");
    Utils.assertCollection(department.getEmployees().values(), employee1, employee2, employee3);
    Assert.assertEquals("I", employee1.getCodeInDepartment());
    Assert.assertEquals(department, employee1.getDepartment());
    Assert.assertEquals("II", employee2.getCodeInDepartment());
    Assert.assertEquals(department, employee2.getDepartment());
    Assert.assertEquals("III", employee3.getCodeInDepartment());
    Assert.assertEquals(department, employee3.getDepartment());

    Map<String, Employee> map = new LinkedHashMap<String, Employee>();
    map.put("I", employee1);
    map.put("II", employee1);
    map.put("IV", employee3);
    department.getEmployees().putAll(map);
    Utils.assertCollection(department.getEmployees().keySet(), "II", "IV");
    Utils.assertCollection(department.getEmployees().values(), employee1, employee3);
    Assert.assertEquals("II", employee1.getCodeInDepartment());
    Assert.assertEquals(department, employee1.getDepartment());
    Assert.assertNull(employee2.getCodeInDepartment());
    Assert.assertNull(employee2.getDepartment());
    Assert.assertEquals("IV", employee3.getCodeInDepartment());
    Assert.assertEquals(department, employee3.getDepartment());
  }
Example #13
0
 private void testDynamicNameRevocation(
     KeyStore serverKeyStore,
     KeyStore serverTrustStore,
     KeyStore clientKeyStore,
     KeyStore clientTrustStore,
     String revokeName)
     throws Exception {
   logger.info("testRevoke: " + revokeName);
   Set<String> revokedNames = new ConcurrentSkipListSet();
   SSLContext serverSSLContext =
       RevocableNameSSLContexts.create(serverKeyStore, pass, serverTrustStore, revokedNames);
   SSLContext clientSSLContext = SSLContexts.create(clientKeyStore, pass, clientTrustStore);
   ServerThread serverThread = new ServerThread();
   try {
     serverThread.start(serverSSLContext, port, 2);
     Assert.assertNull(ClientThread.connect(clientSSLContext, port));
     Assert.assertNull(serverThread.getErrorMessage());
     revokedNames.add(revokeName);
     logger.debug("revokedNames: " + revokedNames);
     Thread.sleep(1000);
     Assert.assertNotNull(ClientThread.connect(clientSSLContext, port));
     Assert.assertNotNull(serverThread.getErrorMessage());
   } finally {
     serverThread.close();
     serverThread.join(1000);
   }
 }
Example #14
0
  @Test
  public void testGetAndDeleteIndicator() throws Exception {
    IndicatorType type = new IndicatorType("IndicatorType", 100, false);

    indicatorTypeStore.save(type);

    Indicator indicatorA = createIndicator('A', type);
    Indicator indicatorB = createIndicator('B', type);

    int idA = indicatorStore.save(indicatorA);
    int idB = indicatorStore.save(indicatorB);

    assertNotNull(indicatorStore.get(idA));
    assertNotNull(indicatorStore.get(idB));

    indicatorStore.delete(indicatorA);

    assertNull(indicatorStore.get(idA));
    assertNotNull(indicatorStore.get(idB));

    indicatorStore.delete(indicatorB);

    assertNull(indicatorStore.get(idA));
    assertNull(indicatorStore.get(idB));
  }
 @Test
 public void putShouldCreateAndReturnAnEmptyXmlUser() throws Exception {
   final User u = helper.putAndGetXmlResponse("/user/id/98", User.class);
   assertEquals(new Integer(98), u.getId());
   assertNull(u.getName());
   assertNull(u.getNick());
 }
  @Test
  public void testFindNextToClean() throws Exception {
    CompactionRequest rqst = new CompactionRequest("foo", "bar", CompactionType.MINOR);
    rqst.setPartitionname("ds=today");
    txnHandler.compact(rqst);
    assertEquals(0, txnHandler.findReadyToClean().size());
    CompactionInfo ci = txnHandler.findNextToCompact("fred");
    assertNotNull(ci);

    assertEquals(0, txnHandler.findReadyToClean().size());
    txnHandler.markCompacted(ci);
    assertNull(txnHandler.findNextToCompact("fred"));

    List<CompactionInfo> toClean = txnHandler.findReadyToClean();
    assertEquals(1, toClean.size());
    assertNull(txnHandler.findNextToCompact("fred"));

    ShowCompactResponse rsp = txnHandler.showCompact(new ShowCompactRequest());
    List<ShowCompactResponseElement> compacts = rsp.getCompacts();
    assertEquals(1, compacts.size());
    ShowCompactResponseElement c = compacts.get(0);
    assertEquals("foo", c.getDbname());
    assertEquals("bar", c.getTablename());
    assertEquals("ds=today", c.getPartitionname());
    assertEquals(CompactionType.MINOR, c.getType());
    assertEquals("ready for cleaning", c.getState());
    assertNull(c.getWorkerid());
  }
  @Test
  public void testExecute_WithSecondState() throws Exception {
    User user = TestUtil.createUser();
    user.setActiveted(null);
    Site parentSite = TestUtil.createSite();
    DraftChildSiteRegistration registration = TestUtil.createChildSiteRegistration(parentSite);
    ChildSiteSettings settings = TestUtil.createChildSiteSettings(registration, parentSite);
    settings.setCreatedDate(new Date());
    settings.setUserId(user.getUserId());
    settings.setConfirmCode("confirm");
    action.setSettingsId(settings.getChildSiteSettingsId());
    action.setConfirmCode("confirm");

    DraftChildSiteRegistration childSiteRegistration =
        TestUtil.createChildSiteRegistration("name", "comment");
    childSiteRegistration.setBlueprintsId(Arrays.asList(1, 2));
    settings.setRequiredToUseSiteBlueprint(true);
    settings.setSitePaymentSettings(new SitePaymentSettings());
    settings.setChildSiteRegistration(childSiteRegistration);

    Assert.assertNull(user.getActiveted());
    Assert.assertNull(new UsersManager().getLoginedUser());

    ForwardResolution resolutionMock = (ForwardResolution) action.show();
    Assert.assertNotNull(new UsersManager().getLoginedUser());
    Assert.assertEquals(user, new UsersManager().getLoginedUser());
    Assert.assertEquals(
        "/account/registration/childSiteRigistrationConfirmationSecondState.jsp",
        resolutionMock.getPath());

    Assert.assertNotNull(user.getActiveted());
    Assert.assertNotNull(new UsersManager().getLoginedUser());
    Assert.assertEquals(user, new UsersManager().getLoginedUser());
    Assert.assertNull(action.getTellFriendHtml());
  }
  // Test attribute-property transparency
  public boolean doTestAttributesTransparency(ValueHolder vh, UIComponent newComp) {
    assertEquals(vh.getValue(), (String) newComp.getAttributes().get("value"));
    vh.setValue("foo");
    assertEquals("foo", (String) newComp.getAttributes().get("value"));
    vh.setValue(null);
    assertNull((String) newComp.getAttributes().get("value"));
    newComp.getAttributes().put("value", "bar");
    assertEquals("bar", vh.getValue());
    newComp.getAttributes().put("value", null);
    assertNull(vh.getValue());

    assertEquals(vh.getConverter(), (String) newComp.getAttributes().get("converter"));
    vh.setConverter(new LongConverter());
    assertNotNull((Converter) newComp.getAttributes().get("converter"));
    assertTrue(newComp.getAttributes().get("converter") instanceof LongConverter);
    vh.setConverter(null);
    assertNull(newComp.getAttributes().get("converter"));
    newComp.getAttributes().put("converter", new ShortConverter());
    assertNotNull(vh.getConverter());
    assertTrue(vh.getConverter() instanceof ShortConverter);
    newComp.getAttributes().put("converter", null);
    assertNull(vh.getConverter());

    return true;
  }
  @Test
  public void testMergePackages() {
    greenProject.addClassData(firstClass);
    greenProject.addClassData(fourthClass);
    redProject.addClassData(fifthClass);
    redProject.addClassData(sixthClass);
    redProject.addClassData(seventhClass);

    // merge with null - should not change the greenProject
    greenProject.merge(null);

    greenProject.merge(redProject);

    Iterator subpackages = greenProject.getSubPackages("").iterator();
    assertEquals("", ((PackageData) subpackages.next()).getName());
    assertEquals("beautiful", ((PackageData) subpackages.next()).getName());
    assertEquals("test", ((PackageData) subpackages.next()).getName());
    assertEquals("test.me", ((PackageData) subpackages.next()).getName());
    assertFalse(subpackages.hasNext());

    assertEquals(5, greenProject.getClasses().size());
    assertEquals(3, redProject.getClasses().size());

    assertNotNull(greenProject.getClassData("test.First"));
    assertNotNull(greenProject.getClassData("test.me.Fourth"));
    assertNotNull(greenProject.getClassData("beautiful.Fourth"));
    assertNotNull(greenProject.getClassData("Fourth"));
    assertNotNull(greenProject.getClassData("Seventh"));
    assertNull(redProject.getClassData("test.First"));

    Iterator packages = greenProject.getPackages().iterator();

    PackageData first = (PackageData) packages.next();
    assertEquals("", first.getName());
    assertEquals(2, first.getNumberOfChildren());
    assertNotNull(first.getChild("Fourth"));
    assertNotNull(first.getChild("Seventh"));

    PackageData beautiful = (PackageData) packages.next();
    assertEquals("beautiful", beautiful.getName());
    assertEquals(1, beautiful.getNumberOfChildren());
    assertNotNull(beautiful.getChild("Fourth"));

    PackageData test = (PackageData) packages.next();
    assertEquals("test", test.getName());
    assertEquals(1, test.getNumberOfChildren());
    assertNotNull(test.getChild("First"));
    assertNull(test.getChild("test/me/First.java"));
    assertNull(test.getChild("Fourth.java"));

    PackageData testMe = (PackageData) packages.next();
    assertEquals("test.me", testMe.getName());
    assertEquals(1, testMe.getNumberOfChildren());
    assertNull(testMe.getChild("test/First.java"));
    assertNotNull(testMe.getChild("Fourth"));
    assertNull(testMe.getChild("Fourth.java"));

    assertFalse(packages.hasNext());
  }
 public void test_childOperationsOnNull() throws Exception {
   this.addNodeById("8758390115029078425");
   this.addNodeById("5815925154349132136");
   this.addNodeById("2166349271756548530");
   SNode nullNode = null;
   Assert.assertNull(SNodeOperations.getContainingLinkDeclaration(nullNode));
   Assert.assertNull(SNodeOperations.getContainingLinkRole(nullNode));
 }
  @Test
  public void testDoHandleRequest() {
    WEmailField field = new WEmailField();
    field.setLocked(true);

    setActiveContext(createUIContext());

    // Request with Empty Value and Field is null (No Change)
    field.setData(null);
    MockRequest request = new MockRequest();
    request.setParameter(field.getId(), "");
    boolean changed = field.doHandleRequest(request);

    Assert.assertFalse(
        "doHandleRequest should have returned false for request with empty value and field is null",
        changed);
    Assert.assertNull("Value should still be null after empty request", field.getData());

    // Request with Empty Value and Field is empty (No Change)
    field.setData("");
    request = new MockRequest();
    request.setParameter(field.getId(), "");
    changed = field.doHandleRequest(request);

    Assert.assertFalse(
        "doHandleRequest should have returned false for request with empty value and field is empty",
        changed);
    Assert.assertEquals("Value should still be empty after empty request", "", field.getData());

    // Request with Different Value (Change)
    request = new MockRequest();
    request.setParameter(field.getId(), "X");
    changed = field.doHandleRequest(request);

    Assert.assertTrue(
        "doHandleRequest should have returned true for request with different value", changed);
    Assert.assertEquals("Value not set after request", "X", field.getData());

    // Request with Same Value (No Change)
    request = new MockRequest();
    request.setParameter(field.getId(), "X");
    changed = field.doHandleRequest(request);

    Assert.assertFalse(
        "doHandleRequest should have returned false for request with same value", changed);
    Assert.assertEquals(
        "Value should not have changed after request with same value", "X", field.getData());

    // Request with Empty Value (Change)
    request = new MockRequest();
    request.setParameter(field.getId(), "");
    changed = field.doHandleRequest(request);

    Assert.assertTrue(
        "doHandleRequest should have returned true for request going back to an empty value",
        changed);
    Assert.assertNull("Value should go back to null for request with empty value", field.getData());
  }
  /**
   * Tests the behavior of reference <code>conflict</code>'s accessors.
   *
   * @generated
   */
  @Test
  public void testConflict() {
    EStructuralFeature feature =
        org.eclipse.emf.compare.ComparePackage.eINSTANCE.getDiff_Conflict();
    ReferenceChange referenceChange = CompareFactory.eINSTANCE.createReferenceChange();
    referenceChange.eAdapters().add(new MockEAdapter());
    org.eclipse.emf.compare.Conflict conflictValue =
        org.eclipse.emf.compare.CompareFactory.eINSTANCE.createConflict();

    assertFalse(referenceChange.eIsSet(feature));
    assertNull(referenceChange.getConflict());

    referenceChange.setConflict(conflictValue);
    assertTrue(notified);
    notified = false;
    assertSame(conflictValue, referenceChange.getConflict());
    assertSame(referenceChange.getConflict(), referenceChange.eGet(feature));
    assertSame(referenceChange.getConflict(), referenceChange.eGet(feature, false));
    assertTrue(referenceChange.eIsSet(feature));
    assertTrue(conflictValue.getDifferences().contains(referenceChange));

    referenceChange.eUnset(feature);
    assertTrue(notified);
    notified = false;
    assertNull(referenceChange.getConflict());
    assertSame(referenceChange.getConflict(), referenceChange.eGet(feature));
    assertSame(referenceChange.getConflict(), referenceChange.eGet(feature, false));
    assertFalse(referenceChange.eIsSet(feature));
    assertFalse(conflictValue.getDifferences().contains(referenceChange));

    referenceChange.setConflict(conflictValue);
    assertTrue(notified);
    notified = false;
    assertSame(conflictValue, referenceChange.getConflict());
    assertSame(referenceChange.getConflict(), referenceChange.eGet(feature));
    assertSame(referenceChange.getConflict(), referenceChange.eGet(feature, false));
    assertTrue(referenceChange.eIsSet(feature));
    assertTrue(conflictValue.getDifferences().contains(referenceChange));

    referenceChange.eSet(feature, conflictValue);
    assertTrue(notified);
    notified = false;
    assertSame(conflictValue, referenceChange.getConflict());
    assertSame(referenceChange.getConflict(), referenceChange.eGet(feature));
    assertSame(referenceChange.getConflict(), referenceChange.eGet(feature, false));
    assertTrue(referenceChange.eIsSet(feature));
    assertTrue(conflictValue.getDifferences().contains(referenceChange));

    referenceChange.setConflict(null);
    assertTrue(notified);
    notified = false;
    assertNull(referenceChange.getConflict());
    assertSame(feature.getDefaultValue(), referenceChange.getConflict());
    assertSame(referenceChange.getConflict(), referenceChange.eGet(feature));
    assertSame(referenceChange.getConflict(), referenceChange.eGet(feature, false));
    assertFalse(referenceChange.eIsSet(feature));
    assertFalse(conflictValue.getDifferences().contains(referenceChange));
  }
  @Test
  public void testGenerateBundleSelectionCriteriaID() {
    final CatalogVersionModel catalogVersion =
        catalogVersionService.getSessionCatalogVersions().iterator().next();

    final AutoPickBundleSelectionCriteriaModel selecCrit1 =
        modelService.create(AutoPickBundleSelectionCriteriaModel.class);
    Assert.assertNull(selecCrit1.getId());
    selecCrit1.setCatalogVersion(catalogVersion);
    modelService.save(selecCrit1);
    Assert.assertNotNull(selecCrit1.getId());
    LOG.info("selecCrit1.id: " + selecCrit1.getId());

    final PickExactlyNBundleSelectionCriteriaModel selecCrit2 =
        modelService.create(PickExactlyNBundleSelectionCriteriaModel.class);
    Assert.assertNull(selecCrit2.getId());
    selecCrit2.setCatalogVersion(catalogVersion);
    selecCrit2.setN(Integer.valueOf(1));
    modelService.save(selecCrit2);
    Assert.assertNotNull(selecCrit2.getId());
    Assert.assertTrue(!selecCrit1.getId().equals(selecCrit2.getId()));
    LOG.info("selecCrit2.id: " + selecCrit2.getId());

    final PickNToMBundleSelectionCriteriaModel selecCrit3 =
        modelService.create(PickNToMBundleSelectionCriteriaModel.class);
    Assert.assertNull(selecCrit3.getId());
    selecCrit3.setCatalogVersion(catalogVersion);
    selecCrit3.setN(Integer.valueOf(1));
    selecCrit3.setM(Integer.valueOf(2));
    modelService.save(selecCrit3);
    Assert.assertNotNull(selecCrit3.getId());
    Assert.assertTrue(!selecCrit1.getId().equals(selecCrit3.getId()));
    Assert.assertTrue(!selecCrit2.getId().equals(selecCrit3.getId()));
    LOG.info("selecCrit3.id: " + selecCrit3.getId());

    final AutoPickBundleSelectionCriteriaModel selecCrit4 =
        modelService.create(AutoPickBundleSelectionCriteriaModel.class);
    Assert.assertNull(selecCrit4.getId());
    selecCrit4.setCatalogVersion(catalogVersion);
    selecCrit4.setId("MyOwnSelecCritID");
    modelService.save(selecCrit4);
    Assert.assertEquals("MyOwnSelecCritID", selecCrit4.getId());
    LOG.info("selecCrit4.id: " + selecCrit4.getId());

    final PickNToMBundleSelectionCriteriaModel selecCrit5 =
        modelService.create(PickNToMBundleSelectionCriteriaModel.class);
    Assert.assertNull(selecCrit5.getId());
    selecCrit5.setCatalogVersion(catalogVersion);
    selecCrit5.setN(Integer.valueOf(1));
    selecCrit5.setM(Integer.valueOf(2));
    modelService.save(selecCrit5);
    Assert.assertNotNull(selecCrit5.getId());
    Assert.assertTrue(!selecCrit1.getId().equals(selecCrit5.getId()));
    Assert.assertTrue(!selecCrit2.getId().equals(selecCrit5.getId()));
    Assert.assertTrue(!selecCrit3.getId().equals(selecCrit5.getId()));
    LOG.info("selecCrit5.id: " + selecCrit5.getId());
  }
Example #24
0
        @Override
        public void renderStart(ExecuteContext ctx) {
            renderStart = ++callbackCount;
            checkBase(ctx);

            assertNull(ctx.batchSQL()[0]);
            assertNull(ctx.sql());
            assertNull(ctx.statement());
        }
 @Test
 public void emptyDeleteAt() {
   expectStatusCode(202);
   List<Header> headers = new ArrayList<Header>();
   prepareHeader(response, LAST_MODIFIED, "Mon, 03 Sep 2012 05:40:33 GMT", headers);
   prepareHeadersForRetrieval(response, headers);
   assertNull(object.getDeleteAt());
   assertNull(object.getDeleteAtAsDate());
 }
  public void testChangeSet() {
    ArrayList<String> lines = new ArrayList<String>();
    lines.add("Some header junk we should ignore...");
    lines.add("header line 2");
    lines.add("commit 123abc456def");
    lines.add("tree 789ghi012jkl");
    lines.add("parent 345mno678pqr");
    lines.add("author John Author <*****@*****.**> 1234567 -0600");
    lines.add("commiter John Committer <*****@*****.**> 1234567 -0600");
    lines.add("");
    lines.add("    Commit title.");
    lines.add("    Commit extended description.");
    lines.add("");
    lines.add(
        ":000000 123456 0000000000000000000000000000000000000000 123abc456def789abc012def345abc678def901a A\tsrc/test/add.file");
    lines.add(
        ":123456 000000 123abc456def789abc012def345abc678def901a 0000000000000000000000000000000000000000 D\tsrc/test/deleted.file");
    lines.add(
        ":123456 789012 123abc456def789abc012def345abc678def901a bc234def567abc890def123abc456def789abc01 M\tsrc/test/modified.file");
    lines.add(
        ":123456 789012 123abc456def789abc012def345abc678def901a bc234def567abc890def123abc456def789abc01 R012\tsrc/test/renamedFrom.file\tsrc/test/renamedTo.file");
    GitChangeSet changeSet = new GitChangeSet(lines);

    Assert.assertEquals("123abc456def", changeSet.getId());
    Assert.assertEquals("Commit title.", changeSet.getMsg());
    Assert.assertEquals("Commit title.\nCommit extended description.\n", changeSet.getComment());
    HashSet<String> expectedAffectedPaths = new HashSet<String>(7);
    expectedAffectedPaths.add("src/test/add.file");
    expectedAffectedPaths.add("src/test/deleted.file");
    expectedAffectedPaths.add("src/test/modified.file");
    expectedAffectedPaths.add("src/test/renamedFrom.file\tsrc/test/renamedTo.file");
    Assert.assertEquals(expectedAffectedPaths, changeSet.getAffectedPaths());

    Collection<Path> actualPaths = changeSet.getPaths();
    Assert.assertEquals(4, actualPaths.size());
    for (Path path : actualPaths) {
      if ("src/test/add.file".equals(path.getPath())) {
        Assert.assertEquals(EditType.ADD, path.getEditType());
        Assert.assertNull(path.getSrc());
        Assert.assertEquals("123abc456def789abc012def345abc678def901a", path.getDst());
      } else if ("src/test/deleted.file".equals(path.getPath())) {
        Assert.assertEquals(EditType.DELETE, path.getEditType());
        Assert.assertEquals("123abc456def789abc012def345abc678def901a", path.getSrc());
        Assert.assertNull(path.getDst());
      } else if ("src/test/modified.file".equals(path.getPath())) {
        Assert.assertEquals(EditType.EDIT, path.getEditType());
        Assert.assertEquals("123abc456def789abc012def345abc678def901a", path.getSrc());
        Assert.assertEquals("bc234def567abc890def123abc456def789abc01", path.getDst());
      } else if ("src/test/renamedFrom.file\tsrc/test/renamedTo.file".equals(path.getPath())) {
        Assert.assertEquals(EditType.EDIT, path.getEditType());
        Assert.assertNull(path.getSrc());
        Assert.assertNull(path.getDst());
      } else {
        Assert.fail("Unrecognized path.");
      }
    }
  }
  // Test a pristine ValueHolderBase instance
  @Override
  public void testPristine() {
    super.testPristine();
    ValueHolder vh = (ValueHolder) component;

    // Validate properties
    assertNull("no value", vh.getValue());
    assertNull("no converter", vh.getConverter());
  }
 /** Test method for {@link org.gedcom4j.parser.GedcomParserException#GedcomParserException()} . */
 @Test
 public void testGedcomWriterException() {
   try {
     throw new GedcomParserException();
   } catch (GedcomParserException e) {
     Assert.assertNotNull(e);
     Assert.assertNull(e.getMessage());
     Assert.assertNull(e.getCause());
   }
 }
  @Test
  public void testGetRemoteServiceInterface() {
    final AutowiredRemoteServiceGroupConfig config;

    config = new AutowiredRemoteServiceGroupConfig();
    Assert.assertEquals(
        TestService1.class, config.getRemoteServiceInterface(TestService1Impl.class));
    Assert.assertNull(config.getRemoteServiceInterface(TestService10Impl.class));
    Assert.assertNull(config.getRemoteServiceInterface(ByteArrayInputStream.class));
  }
 @Test
 public void shouldGetTheEnumValueForAString() {
   assertEquals(
       SubscriberCareReasons.NEW_SUBSCRIPTION,
       SubscriberCareReasons.getFor("  new_Subscription "));
   assertEquals(SubscriberCareReasons.HELP, SubscriberCareReasons.getFor("  helP "));
   assertNull(SubscriberCareReasons.getFor("  some "));
   assertNull(SubscriberCareReasons.getFor(""));
   assertNull(SubscriberCareReasons.getFor(null));
 }