⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ierrelationshiptest.java

📁 是高效开发JAVA的XML工具
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
		} catch (InvalidEditingException e) {
			TransactionManager.abortTransaction();
			assertEquals(e.getKey(), InvalidEditingException.PARAMETER_ERROR_KEY);
		}
    }

    public void testSetVerbPhraseChild() {
        try {
        	TransactionManager.beginTransaction();
            IEREntity entity = getEntity(schema.getEntities(), "Entity2");
            IERAttribute attribute = getERAttribute(entity, "e1_Attribute2");
            IERRelationship relationship = attribute.getReferencedRelationship();
            relationship.setVerbPhraseChild("verbChild");
			assertEquals(relationship.getVerbPhraseChild(), "verbChild");
			TransactionManager.endTransaction();
		} catch (InvalidEditingException e) {
			TransactionManager.abortTransaction();
			e.printStackTrace();
		}
    }

    public void testSetNullVerbPhraseChild() {
        try {
        	TransactionManager.beginTransaction();
            IEREntity entity = getEntity(schema.getEntities(), "Entity2");
            IERAttribute attribute = getERAttribute(entity, "e1_Attribute2");
            IERRelationship relationship = attribute.getReferencedRelationship();
            relationship.setVerbPhraseChild(null);
			TransactionManager.endTransaction();
			fail();
		} catch (InvalidEditingException e) {
			TransactionManager.abortTransaction();
			assertEquals(e.getKey(), InvalidEditingException.PARAMETER_ERROR_KEY);
		}
    }

    public void testSetParentRequiredTrueInIdentifyRelationship() {
        try {
        	TransactionManager.beginTransaction();
            IEREntity entity = getEntity(schema.getEntities(), "Entity1");
            IERAttribute attribute = getERAttribute(entity, "e1_Attribute2");
            IERRelationship identifyRelationship = attribute.getReferencedRelationship();
            identifyRelationship.setParentRequired(true);
            assertEquals(true, identifyRelationship.isParentRequired());
			TransactionManager.endTransaction();
		} catch (InvalidEditingException e) {
			TransactionManager.abortTransaction();
			e.printStackTrace();
		}
    }

    public void testSetParentRequiredFalseInIdentifyRelationship() {
        try {
        	TransactionManager.beginTransaction();
            IEREntity entity = getEntity(schema.getEntities(), "Entity1");
            IERAttribute attribute = getERAttribute(entity, "e1_Attribute2");
            IERRelationship identifyRelationship = attribute.getReferencedRelationship();
            identifyRelationship.setParentRequired(false);
            TransactionManager.endTransaction();
            fail();
        } catch (InvalidEditingException e) {
			TransactionManager.abortTransaction();
			assertEquals(e.getKey(), InvalidEditingException.PARENT_REQUIRED_ERROR_KEY);
		}
    }

    public void testSetParentRequiredTrueInNonIdentifyRelationship() {
        try {
        	TransactionManager.beginTransaction();
            IEREntity entity = getEntity(schema.getEntities(), "Entity3");
            IERAttribute attribute = getERAttribute(entity, "e3_Attribute2");
            IERRelationship nonIdentifyRelationship = attribute.getReferencedRelationship();
            nonIdentifyRelationship.setParentRequired(true);
			TransactionManager.endTransaction();
			assertEquals(true, nonIdentifyRelationship.isParentRequired());
		} catch (InvalidEditingException e) {
			TransactionManager.abortTransaction();
			fail();
		}
    }

    public void testSetParentRequiredFalseInNonIdentifyRelationship() {
        try {
        	TransactionManager.beginTransaction();
            IEREntity entity = getEntity(schema.getEntities(), "Entity3");
            IERAttribute attribute = getERAttribute(entity, "e3_Attribute2");
            IERRelationship nonIdentifyRelationship = attribute.getReferencedRelationship();
            nonIdentifyRelationship.setParentRequired(false);
			TransactionManager.endTransaction();
			assertEquals(false, nonIdentifyRelationship.isParentRequired());
		} catch (InvalidEditingException e) {
			TransactionManager.abortTransaction();
			fail();
		}
    }

    public void testSetParentRequiredTrueInMultToMultRelationship() {
        try {
        	TransactionManager.beginTransaction();
            IEREntity entity = getEntity(schema.getEntities(), "Entity8");
            IERRelationship multToMultRelationship = entity.getChildrenRelationships()[0];
            multToMultRelationship.setParentRequired(true);
			TransactionManager.endTransaction();
			assertEquals(true, multToMultRelationship.isParentRequired());
		} catch (InvalidEditingException e) {
			TransactionManager.abortTransaction();
			fail();
		}
    }

    public void testSetParentRequiredFalseInMultToMultRelationship() {
        try {
        	TransactionManager.beginTransaction();
            IEREntity entity = getEntity(schema.getEntities(), "Entity8");
            IERRelationship multToMultRelationship = entity.getChildrenRelationships()[0];
            multToMultRelationship.setParentRequired(false);
			TransactionManager.endTransaction();
			assertEquals(false, multToMultRelationship.isParentRequired());
		} catch (InvalidEditingException e) {
			TransactionManager.abortTransaction();
			fail();
		}
    }

    public void testIdentifyRelationshipSetForeignKeyWithNull() {
        try {
        	TransactionManager.beginTransaction();
            IEREntity entity18 = getEntity(schema.getEntities(), "Entity18");
            IERRelationship identifyRelationship = entity18.getChildrenRelationships()[0];
            IERAttribute parent = 
            	(IERAttribute)getElement(entity18.getPrimaryKeys(), "Attribute0");
            identifyRelationship.setForeignKey(parent, null);
            TransactionManager.endTransaction();
            fail();
		} catch (InvalidEditingException e) {
			TransactionManager.abortTransaction();
			assertEquals(e.getKey(), InvalidEditingException.PARAMETER_ERROR_KEY);
		}
    }
    
    public void testIdentifyRelationshipSetForeignKey() {
        try {
        	TransactionManager.beginTransaction();
            IEREntity entity18 = getEntity(schema.getEntities(), "Entity18");
            IEREntity entity19 = getEntity(schema.getEntities(), "Entity19");
            IERRelationship identifyRelationship = entity18.getChildrenRelationships()[0];
            IERAttribute parent = 
            	(IERAttribute)getElement(entity18.getPrimaryKeys(), "Attribute0");
            IERAttribute child = 
            	(IERAttribute)getElement(entity19.getPrimaryKeys(), "Attribute1");
            identifyRelationship.setForeignKey(parent, child);
            TransactionManager.endTransaction();
		} catch (InvalidEditingException e) {
			TransactionManager.abortTransaction();
			fail();
		}
    }

    public void testIdentifyRelationshipSetIllegalForeignKey1() {
    	try {
        	TransactionManager.beginTransaction();
            IEREntity entity18 = getEntity(schema.getEntities(), "Entity18");
            IEREntity entity19 = getEntity(schema.getEntities(), "Entity19");
            IERRelationship identifyRelationship = entity18.getChildrenRelationships()[0];
            IERAttribute parent = 
            	(IERAttribute)getElement(entity18.getPrimaryKeys(), "Attribute0");
            IERAttribute child = 
            	(IERAttribute)getElement(entity19.getNonPrimaryKeys(), "Attribute2");
            identifyRelationship.setForeignKey(parent, child);
            TransactionManager.endTransaction();
            fail();
		} catch (InvalidEditingException e) {
			TransactionManager.abortTransaction();
			assertEquals(e.getKey(), InvalidEditingException.IERRElATIONSHIP_SETFORIGENKEY_FAIL_KEY);
		}
    }
    
    public void testIdentifyRelationshipSetIllegalForeignKey2() {
    	try {
        	TransactionManager.beginTransaction();
            IEREntity entity18 = getEntity(schema.getEntities(), "Entity18");
            IEREntity entity19 = getEntity(schema.getEntities(), "Entity19");
            IERRelationship identifyRelationship = entity18.getChildrenRelationships()[0];
            IERAttribute parent = 
            	(IERAttribute)getElement(entity18.getPrimaryKeys(), "Attribute0");
            IERAttribute child = 
            	(IERAttribute)getElement(entity19.getPrimaryKeys(), "Attribute3");
            identifyRelationship.setForeignKey(parent, child);
            TransactionManager.endTransaction();
            fail();
		} catch (InvalidEditingException e) {
			TransactionManager.abortTransaction();
			assertEquals(e.getKey(), InvalidEditingException.IERRElATIONSHIP_SETFORIGENKEY_FAIL_KEY);
		}
    }
    
    public void testNonIdentifyRelationshipSetForeignKeyWithNull() {
        try {
        	TransactionManager.beginTransaction();
            IEREntity entity21 = getEntity(schema.getEntities(), "Entity21");
            IERRelationship identifyRelationship = entity21.getChildrenRelationships()[0];
            IERAttribute parent = 
            	(IERAttribute)getElement(entity21.getPrimaryKeys(), "Attribute0");
            identifyRelationship.setForeignKey(parent, null);
            TransactionManager.endTransaction();
            fail();
		} catch (InvalidEditingException e) {
			TransactionManager.abortTransaction();
			assertEquals(e.getKey(), InvalidEditingException.PARAMETER_ERROR_KEY);
		}
    }
    
    public void testNonIdentifyRelationshipSetForeignKey1() {
        try {
        	TransactionManager.beginTransaction();
            IEREntity entity20 = getEntity(schema.getEntities(), "Entity20");
            IEREntity entity22 = getEntity(schema.getEntities(), "Entity22");
            IERRelationship identifyRelationship = entity20.getChildrenRelationships()[1];
            IERAttribute parent = 
            	(IERAttribute)getElement(entity20.getPrimaryKeys(), "Attribute0");
            IERAttribute child = 
            	(IERAttribute)getElement(entity22.getNonPrimaryKeys(), "Attribute1");
            identifyRelationship.setForeignKey(parent, child);
            TransactionManager.endTransaction();
		} catch (InvalidEditingException e) {
			TransactionManager.abortTransaction();
			fail();
		}
    }

    public void testNonIdentifyRelationshipSetForeignKey2() {
    	try {
        	TransactionManager.beginTransaction();
            IEREntity entity20 = getEntity(schema.getEntities(), "Entity20");
            IEREntity entity22 = getEntity(schema.getEntities(), "Entity22");
            IERRelationship identifyRelationship = entity20.getChildrenRelationships()[1];
            IERAttribute parent = 
            	(IERAttribute)getElement(entity20.getPrimaryKeys(), "Attribute0");
            IERAttribute child = 
            	(IERAttribute)getElement(entity22.getPrimaryKeys(), "Attribute2");
            identifyRelationship.setForeignKey(parent, child);
            TransactionManager.endTransaction();
		} catch (InvalidEditingException e) {
			TransactionManager.abortTransaction();
			fail();
		}
    }
    
    public void testNonIdentifyRelationshipSetIllegalForeignKey() {
    	try {
        	TransactionManager.beginTransaction();
            IEREntity entity20 = getEntity(schema.getEntities(), "Entity20");
            IEREntity entity22 = getEntity(schema.getEntities(), "Entity22");
            IERRelationship identifyRelationship = entity20.getChildrenRelationships()[1];
            IERAttribute parent = 
            	(IERAttribute)getElement(entity20.getPrimaryKeys(), "Attribute0");
            IERAttribute child = 
            	(IERAttribute)getElement(entity22.getNonPrimaryKeys(), "Attribute3");
            identifyRelationship.setForeignKey(parent, child);
            TransactionManager.endTransaction();
            fail();
		} catch (InvalidEditingException e) {
			TransactionManager.abortTransaction();
			assertEquals(e.getKey(), InvalidEditingException.IERRElATIONSHIP_SETFORIGENKEY_FAIL_KEY);
		}
    }
    
    public void testSetERIndex() throws InvalidEditingException {
    	try {
	    	TransactionManager.beginTransaction();
	        IEREntity entity26 = getEntity(schema.getEntities(), "Entity26");
	        IEREntity entity27 = getEntity(schema.getEntities(), "Entity27");
	        IERRelationship identifyRelationship = entity26.getChildrenRelationships()[0];
	        assertTrue(entity27.getForeignKeys().length == 2);
	        assertNotNull(getElement(entity27.getForeignKeys(), "Attribute0"));
	        assertNotNull(getElement(entity27.getForeignKeys(), "Attribute1"));
	        assertTrue(entity26.getERIndices().length == 1);
	        identifyRelationship.setERIndex(entity26.getERIndices()[0]);
	        assertTrue(identifyRelationship.getERIndex() == entity26.getERIndices()[0]);
	        assertTrue(entity27.getForeignKeys().length == 2);
	        assertNotNull(getElement(entity27.getForeignKeys(), "Attribute1"));
	        assertNotNull(getElement(entity27.getForeignKeys(), "Attribute3"));        
	        TransactionManager.endTransaction();
    	} catch (InvalidEditingException e) {
			TransactionManager.abortTransaction();
			assertEquals(e.getKey(), InvalidEditingException.IERRElATIONSHIP_SETFORIGENKEY_FAIL_KEY);
		}
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -