@Test public void joinTargetObjectsAlreadyJoinedNonNull() throws SMGInconsistentException { smg1.addValue(value1); smg2.addValue(value2); smg1.addObject(obj1); smg2.addObject(obj2); destSMG.addObject(destObj); smg1.addPointsToEdge(pt1); smg2.addPointsToEdge(pt2); mapping1.map(obj1, destObj); mapping2.map(obj2, destObj); // See TODO below // SMGMapTargetAddress mta = new SMGMapTargetAddress(new SMG(smg1), new SMG(smg2), new // SMG(destSMG), // new SMGNodeMapping(mapping1), new // SMGNodeMapping(mapping2), // value1, value2); SMGJoinTargetObjects jto = new SMGJoinTargetObjects( SMGJoinStatus.EQUAL, smg1, smg2, destSMG, mapping1, mapping2, SMGLevelMapping.createDefaultLevelMap(), value1, value2, 0, 0, 0, false, null, null); Assert.assertTrue(jto.isDefined()); Assert.assertEquals(SMGJoinStatus.EQUAL, jto.getStatus()); Assert.assertSame(smg1, jto.getInputSMG1()); Assert.assertSame(smg2, jto.getInputSMG2()); // TODO: Not equal, but isomorphic (newly created values differ in mta and jto) // But we currently do not have isomorphism // Assert.assertEquals(mta.getSMG(), jto.getDestinationSMG()); Assert.assertTrue(jto.getMapping1().containsKey(value1)); Assert.assertEquals(jto.getMapping1().get(value1), jto.getValue()); Assert.assertTrue(jto.getMapping2().containsKey(value2)); Assert.assertEquals(jto.getMapping2().get(value2), jto.getValue()); }
@Test public void mapTargetAddressNew() { smg1.addValue(value1); smg1.addObject(obj1); smg1.addPointsToEdge(edge1); destSMG.addObject(destObj); mapping1.map(obj1, destObj); SMGNodeMapping origMapping1 = new SMGNodeMapping(mapping1); SMGNodeMapping origMapping2 = new SMGNodeMapping(mapping2); SMG origDestSMG = new SMG(destSMG); SMGJoinMapTargetAddress mta = new SMGJoinMapTargetAddress(smg1, null, destSMG, mapping1, mapping2, value1, value2); Assert.assertNotEquals(origDestSMG, mta.getSMG()); Assert.assertNotEquals(origMapping1, mta.getMapping1()); Assert.assertNotEquals(origMapping2, mta.getMapping2()); Assert.assertFalse(origDestSMG.getValues().contains(mta.getValue())); SMGEdgePointsTo newEdge = destSMG.getPointer(mta.getValue()); Assert.assertSame(destObj, newEdge.getObject()); Assert.assertEquals(0, newEdge.getOffset()); Assert.assertSame(mta.getValue(), mta.getMapping1().get(value1)); Assert.assertSame(mta.getValue(), mta.getMapping2().get(value2)); }
@Test public void mapTargetAddressExisting() { SMGEdgePointsTo destEdge = new SMGEdgePointsTo(destValue, destObj, 0); smg1.addValue(value1); smg1.addObject(obj1); smg1.addPointsToEdge(edge1); destSMG.addValue(destValue); destSMG.addObject(destObj); destSMG.addPointsToEdge(destEdge); mapping1.map(obj1, destObj); SMGNodeMapping origMapping1 = new SMGNodeMapping(mapping1); SMG origDestSMG = new SMG(destSMG); SMGJoinMapTargetAddress mta = new SMGJoinMapTargetAddress(smg1, null, destSMG, mapping1, null, value1, null); Assert.assertEquals(origDestSMG, mta.getSMG()); Assert.assertEquals(origMapping1, mta.getMapping1()); Assert.assertNull(mta.getMapping2()); Assert.assertSame(destValue, mta.getValue()); }