Examples of Allocation


Examples of com.ib.controller.Profile.Allocation

  static ArrayList<Profile> getProfiles_( String xml) throws IOException {
    ArrayList<Profile> list = new ArrayList<Profile>();

    Profile profile = null;
    Allocation alloc = null;

    BufferedReader reader = new BufferedReader( new StringReader( xml) );
    String line;
    int state = 0; // 0=none; 1=list of groups; 2=reading group 3=listOfAllocations 4=allocation
    for( int lc = 0; ((line=reader.readLine()) != null); lc++) {
      line = line.trim();

      switch( state) {
        // top of file
        case 0:
          if (line.equals( "<ListOfAllocationProfiles>")) {
            state = 1;
          }
          break;

        // reading profiles
        case 1:
          if (line.equals( "<AllocationProfile>")) {
            profile = new Profile();
            state = 2;
          }
          else if (line.equals( "</ListOfAllocationProfiles>")) {
            state = 0;
          }
          else {
            err( line);
          }
          break;

        // reading Profile
        case 2:
          if (line.startsWith( "<name>") ) {
            profile.name( getVal( line) );
          }
          else if (line.startsWith( "<type>")) {
            int i = Integer.parseInt( getVal( line) );
            profile.type( Type.get( i) );
          }
          else if (line.startsWith( "<ListOfAllocations")) {
            state = 3;
          }
          else if (line.equals( "</AllocationProfile>")) {
            list.add( profile);
            state = 1;
          }
          else {
            err( line);
          }
          break;

        // reading list of allocations
        case 3:
          if (line.equals( "<Allocation>")) {
            alloc = new Allocation();
            state = 4;
          }
          else if (line.equals( "</ListOfAllocations>")) {
            state = 2;
          }
          else {
            err( line);
          }
          break;

        // reading Allocation
        case 4:
          if (line.startsWith( "<acct>") ) {
            alloc.account( getVal( line) );
          }
          else if (line.startsWith( "<amount>") ) {
            alloc.amount( getVal( line) );
          }
          else if (line.startsWith( "<posEff>") ) {
            // skip this
          }
          else if (line.equals( "</Allocation>") ) {
View Full Code Here

Examples of com.indeed.proctor.common.model.Allocation

        testDefinition.setConstants(Collections.<String, Object>emptyMap());

        testDefinition.setBuckets(buckets);

        final List<Allocation> allocations = Lists.newArrayList();
        allocations.add(new Allocation("${}", ranges));
        testDefinition.setAllocations(allocations);

        final RandomTestChooser rtc = new RandomTestChooser(expressionFactory, functionMapper, "testName", testDefinition);
        return rtc;
    }
View Full Code Here

Examples of com.indeed.proctor.common.model.Allocation

        }
    }

    private void updateAllocations(final ImmutableList<Range> ranges) {
        final List<Allocation> allocations = Lists.newArrayList();
        allocations.add(new Allocation("${}", ranges));
        testDefinition.setAllocations(allocations);
    }
View Full Code Here

Examples of com.indeed.proctor.common.model.Allocation

        final Map<String, Object> specialConstants = Collections.emptyMap();
        final String description = "test description";

        for(final String tdRule : emptyRules) {
            for(String allocRule : emptyRules) {
                final Allocation allocation = new Allocation(allocRule, Collections.singletonList(range));
                final TestDefinition testDefinition = new TestDefinition(
                    version,
                    tdRule,
                    testType,
                    salt,
                    buckets,
                    Collections.singletonList(allocation),
                    constants,
                    specialConstants,
                    description
                );

                final ConsumableTestDefinition ctd = ProctorUtils.convertToConsumableTestDefinition(testDefinition);
                assertEquals(version, ctd.getVersion());
                assertEquals(testType, ctd.getTestType());
                assertEquals(salt, ctd.getSalt());
                assertEquals(description, ctd.getDescription());
                assertEquals(0, ctd.getConstants().size());
                assertEquals(buckets, ctd.getBuckets());

                assertEquals(String.format("TestDefinition rule '%s' should convert to a null ConsumableTestDefinition.rule", tdRule), null, ctd.getRule());

                assertEquals(1, ctd.getAllocations().size());
                final Allocation ctdAllocation = ctd.getAllocations().get(0);
                assertEquals(String.format("Allocation rule '%s' should convert to a null ConsumableTestDefinition.Allocation.rule", allocRule), null, ctdAllocation.getRule());
                assertEquals(allocation.getRanges(), ctdAllocation.getRanges());
            }
        }
    }
View Full Code Here

Examples of com.indeed.proctor.common.model.Allocation

        final String description = "test description";


        for(final String rule : new String[] { "lang == 'en'", "${lang == 'en'}"})
        {
            final Allocation allocation = new Allocation(rule, Collections.singletonList(range));
            final TestDefinition testDefinition = new TestDefinition(
                version,
                rule,
                testType,
                salt,
                buckets,
                Collections.singletonList(allocation),
                constants,
                specialConstants,
                description
            );

            final ConsumableTestDefinition ctd = ProctorUtils.convertToConsumableTestDefinition(testDefinition);
            assertEquals(String.format("TestDefinition rule '%s' should convert to a ${lang == 'en'} ConsumableTestDefinition.rule", rule), "${lang == 'en'}", ctd.getRule());

            assertEquals(1, ctd.getAllocations().size());
            final Allocation ctdAllocation = ctd.getAllocations().get(0);
            assertEquals(String.format("Allocation rule '%s' should convert to a ${lang == 'en'} ConsumableTestDefinition.Allocation.rule", rule), "${lang == 'en'}", ctdAllocation.getRule());
            assertEquals(allocation.getRanges(), ctdAllocation.getRanges());
        }
    }
View Full Code Here

Examples of com.indeed.proctor.common.model.Allocation

        final List<TestBucket> buckets = fromCompactBucketFormat("inactive:-1,control:0,test:1");
        final Map<String, Object> constants = Collections.emptyMap();
        final Map<String, Object> specialConstants = Collections.<String, Object>singletonMap("__COUNTRIES", Lists.newArrayList("US", "CA"));
        final String description = "test description";

        final Allocation allocation = new Allocation(null, Collections.singletonList(range));

        for(final String tdRule : new String[] { "lang == 'en'", "${lang == 'en'}"})
        {
            final TestDefinition testDefinition = new TestDefinition(
                version,
View Full Code Here

Examples of com.indeed.proctor.common.model.Allocation

        double DELTA = 0;

        List<Allocation> allocations = fromCompactAllocationFormat("ruleA|10:0,11:0.5,12:0.5", "0:0,1:0.5,2:0.5");
        assertEquals(2, allocations.size());
        {
            Allocation allocationA = allocations.get(0);
            assertEquals("ruleA", allocationA.getRule());
            assertEquals(3, allocationA.getRanges().size());
            assertEquals(10, allocationA.getRanges().get(0).getBucketValue());
            assertEquals(0, allocationA.getRanges().get(0).getLength(), DELTA);
            assertEquals(11, allocationA.getRanges().get(1).getBucketValue());
            assertEquals(0.5, allocationA.getRanges().get(1).getLength(), DELTA);
            assertEquals(12, allocationA.getRanges().get(2).getBucketValue());
            assertEquals(0.5, allocationA.getRanges().get(2).getLength(), DELTA);
        }
        {
            Allocation allocationB = allocations.get(1);
            assertNull(allocationB.getRule());
            assertEquals(3, allocationB.getRanges().size());
            assertEquals(0, allocationB.getRanges().get(0).getBucketValue());
            assertEquals(0, allocationB.getRanges().get(0).getLength(), DELTA);
            assertEquals(1, allocationB.getRanges().get(1).getBucketValue());
            assertEquals(0.5, allocationB.getRanges().get(1).getLength(), DELTA);
            assertEquals(2, allocationB.getRanges().get(2).getBucketValue());
            assertEquals(0.5, allocationB.getRanges().get(2).getLength(), DELTA);
        }
    }
View Full Code Here

Examples of com.indeed.proctor.common.model.Allocation

        final Map<String, Object> specialConstants = Collections.emptyMap();
        final String description = "test description";

        for(final String tdRule : emptyRules) {
            for(String allocRule : emptyRules) {
                final Allocation allocation = new Allocation(allocRule, Collections.singletonList(range));
                final TestDefinition testDefinition = new TestDefinition(
                    version,
                    tdRule,
                    testType,
                    salt,
                    buckets,
                    Collections.singletonList(allocation),
                    constants,
                    specialConstants,
                    description
                );

                final ConsumableTestDefinition ctd = ProctorUtils.convertToConsumableTestDefinition(testDefinition);
                assertEquals(version, ctd.getVersion());
                assertEquals(testType, ctd.getTestType());
                assertEquals(salt, ctd.getSalt());
                assertEquals(description, ctd.getDescription());
                assertEquals(0, ctd.getConstants().size());
                assertEquals(buckets, ctd.getBuckets());

                assertEquals(String.format("TestDefinition rule '%s' should convert to a null ConsumableTestDefinition.rule", tdRule), null, ctd.getRule());

                assertEquals(1, ctd.getAllocations().size());
                final Allocation ctdAllocation = ctd.getAllocations().get(0);
                assertEquals(String.format("Allocation rule '%s' should convert to a null ConsumableTestDefinition.Allocation.rule", allocRule), null, ctdAllocation.getRule());
                assertEquals(allocation.getRanges(), ctdAllocation.getRanges());
            }
        }
    }
View Full Code Here

Examples of com.indeed.proctor.common.model.Allocation

        final String description = "test description";


        for(final String rule : new String[] { "lang == 'en'", "${lang == 'en'}"})
        {
            final Allocation allocation = new Allocation(rule, Collections.singletonList(range));
            final TestDefinition testDefinition = new TestDefinition(
                version,
                rule,
                testType,
                salt,
                buckets,
                Collections.singletonList(allocation),
                constants,
                specialConstants,
                description
            );

            final ConsumableTestDefinition ctd = ProctorUtils.convertToConsumableTestDefinition(testDefinition);
            assertEquals(String.format("TestDefinition rule '%s' should convert to a ${lang == 'en'} ConsumableTestDefinition.rule", rule), "${lang == 'en'}", ctd.getRule());

            assertEquals(1, ctd.getAllocations().size());
            final Allocation ctdAllocation = ctd.getAllocations().get(0);
            assertEquals(String.format("Allocation rule '%s' should convert to a ${lang == 'en'} ConsumableTestDefinition.Allocation.rule", rule), "${lang == 'en'}", ctdAllocation.getRule());
            assertEquals(allocation.getRanges(), ctdAllocation.getRanges());
        }
    }
View Full Code Here

Examples of com.indeed.proctor.common.model.Allocation

        final List<TestBucket> buckets = fromCompactBucketFormat("inactive:-1,control:0,test:1");
        final Map<String, Object> constants = Collections.emptyMap();
        final Map<String, Object> specialConstants = Collections.<String, Object>singletonMap("__COUNTRIES", Lists.newArrayList("US", "CA"));
        final String description = "test description";

        final Allocation allocation = new Allocation(null, Collections.singletonList(range));

        for(final String tdRule : new String[] { "lang == 'en'", "${lang == 'en'}"})
        {
            final TestDefinition testDefinition = new TestDefinition(
                version,
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.