Association links generation fixed.
1.1 --- a/mdr/test/unit/src/org/netbeans/mdr/test/RandomDataGenerator.java Mon Sep 23 18:13:15 2002 +0000
1.2 +++ b/mdr/test/unit/src/org/netbeans/mdr/test/RandomDataGenerator.java Wed Sep 25 08:58:54 2002 +0000
1.3 @@ -215,63 +215,57 @@
1.4
1.5 public void generateAssociation (RefAssociation proxy, int count) {
1.6 Association assoc = (Association) proxy.refMetaObject ();
1.7 + if (assoc.isDerived ())
1.8 + return;
1.9
1.10 - try {
1.11 -
1.12 - AssociationEnd endA = null, endB = null;
1.13 - Iterator content = assoc.getContents ().iterator ();
1.14 - while (content.hasNext ()) {
1.15 - Object elem = content.next ();
1.16 - if (elem instanceof AssociationEnd) {
1.17 - if (endA == null)
1.18 - endA = (AssociationEnd) elem;
1.19 - else {
1.20 - endB = (AssociationEnd) elem;
1.21 - break;
1.22 - } // if
1.23 + AssociationEnd endA = null, endB = null;
1.24 + Iterator content = assoc.getContents ().iterator ();
1.25 + while (content.hasNext ()) {
1.26 + Object elem = content.next ();
1.27 + if (elem instanceof AssociationEnd) {
1.28 + if (endA == null)
1.29 + endA = (AssociationEnd) elem;
1.30 + else {
1.31 + endB = (AssociationEnd) elem;
1.32 + break;
1.33 } // if
1.34 - } // while
1.35 + } // if
1.36 + } // while
1.37
1.38 - MofClass typeA = findSubtype ((MofClass) endA.getType ());
1.39 - MofClass typeB = findSubtype ((MofClass) endB.getType ());
1.40 + MofClass typeA = findSubtype ((MofClass) endA.getType ());
1.41 + MofClass typeB = findSubtype ((MofClass) endB.getType ());
1.42
1.43 - if ((typeA == null) || (typeB == null))
1.44 - return;
1.45 + if ((typeA == null) || (typeB == null))
1.46 + return;
1.47
1.48 - MultiplicityType multA = endA.getMultiplicity ();
1.49 - MultiplicityType multB = endB.getMultiplicity ();
1.50 - int lowerA = Math.max (1, multA.getLower ());
1.51 - int lowerB = Math.max (1, multB.getLower ());
1.52 - int upperA = lowerA + 4;
1.53 - int upperB = lowerB + 4;
1.54 - if (multA.getUpper () != -1)
1.55 - upperA = Math.min (upperA, multA.getUpper ());
1.56 - if (multB.getUpper () != -1)
1.57 - upperB = Math.min (upperB, multB.getUpper ());
1.58 + MultiplicityType multA = endA.getMultiplicity ();
1.59 + MultiplicityType multB = endB.getMultiplicity ();
1.60 + int lowerA = Math.max (1, multA.getLower ());
1.61 + int lowerB = Math.max (1, multB.getLower ());
1.62 + int upperA = lowerA + 4;
1.63 + int upperB = lowerB + 4;
1.64 + if (multA.getUpper () != -1)
1.65 + upperA = Math.min (upperA, multA.getUpper ());
1.66 + if (multB.getUpper () != -1)
1.67 + upperB = Math.min (upperB, multB.getUpper ());
1.68
1.69 - do {
1.70 - int x, y;
1.71 - int countA = lowerA + ((upperA - lowerA > 0) ? random.nextInt (upperA - lowerA) : 0);
1.72 - int countB = lowerB + ((upperB - lowerB > 0) ? random.nextInt (upperB - lowerB) : 0);
1.73 - RefObject [] objA = new RefObject [countA];
1.74 - RefObject [] objB = new RefObject [countB];
1.75 - for (x = 0; x < countA; x++) {
1.76 - objA [x] = generateInstance (typeA);
1.77 - }
1.78 - for (x = 0; x < countB; x++) {
1.79 - objB [x] = generateInstance (typeB);
1.80 - }
1.81 - for (x = 0; x < countA; x++)
1.82 - for (y = 0; y < countB; y++)
1.83 - proxy.refAddLink (objA[x], objB[y]);
1.84 - } while (--count > 0);
1.85 -
1.86 - } catch (Exception e) {
1.87 - // [PENDING]
1.88 - System.out.println(assoc.getName ());
1.89 - e.printStackTrace ();
1.90 - }
1.91 -
1.92 + do {
1.93 + int x, y;
1.94 + int countA = lowerA + ((upperA - lowerA > 0) ? random.nextInt (upperA - lowerA) : 0);
1.95 + int countB = lowerB + ((upperB - lowerB > 0) ? random.nextInt (upperB - lowerB) : 0);
1.96 + RefObject [] objA = new RefObject [countA];
1.97 + RefObject [] objB = new RefObject [countB];
1.98 + for (x = 0; x < countA; x++) {
1.99 + objA [x] = generateInstance (typeA);
1.100 + }
1.101 + for (x = 0; x < countB; x++) {
1.102 + objB [x] = generateInstance (typeB);
1.103 + }
1.104 + for (x = 0; x < countA; x++)
1.105 + for (y = 0; y < countB; y++)
1.106 + proxy.refAddLink (objA[x], objB[y]);
1.107 + } while (--count > 0);
1.108 +
1.109 }
1.110
1.111 public MofClass findSubtype (MofClass mofClass) {