コード例 #1
0
  public boolean stopGame(Context context) {
    this.androidImage.setVisibility(View.GONE);
    this.waitForRed.setVisibility(View.GONE);
    this.pressGreen.setVisibility(View.GONE);
    this.resultView.setVisibility(View.VISIBLE);
    this.restartButton.setVisibility(View.VISIBLE);

    if (this.startTime == 0) {
      String failString = "You tapped too soon!";
      this.resultView.setText(failString.toCharArray(), 0, failString.length());
      return false;
    }

    long deltaTimeNS = System.nanoTime() - this.startTime;
    Double deltaTimeS = deltaTimeNS / 1000000000.0;

    DataCenter.sharedDataCenter().singlePlayerTimes.add(deltaTimeS);
    DataCenter.sharedDataCenter().save(context);

    String resultString = String.format("You took %.2f seconds", deltaTimeS);
    this.resultView.setText(resultString.toCharArray(), 0, resultString.length());

    this.startTime = 0;

    return true;
  }
コード例 #2
0
ファイル: Regression636Test.java プロジェクト: 9esa/Resteasy
  // @Test
  public void testInheritance() throws Exception {
    ResteasyDeployment dep = deployment;
    ClientRequest request = new ClientRequest(generateURL("/datacenters/1"));
    ClientResponse res = request.get();
    Assert.assertEquals(200, res.getStatus());
    DataCenter dc = (DataCenter) res.getEntity(DataCenter.class);
    Assert.assertEquals(dc.getName(), "Bill");
    request = new ClientRequest(generateURL("/datacenters/1"));

    res = request.body("application/xml", dc).put();
    Assert.assertEquals(200, res.getStatus());
    dc = (DataCenter) res.getEntity(DataCenter.class);
    Assert.assertEquals(dc.getName(), "Bill");
  }
コード例 #3
0
ファイル: RowTest.java プロジェクト: benito1er/test-snippets
  @Test
  public void testInit() {
    // Prepare
    DataCenter dc = new DataCenterReader().readResource("dc.in");
    Row row0 = dc.getRow(0);
    if (DEBUG) dumper.dumpRow(row0);
    //        Row[0] unassigned remainingSize:269
    //        spaceCount[74] : remainingCount=1
    //        spaceCount[52] : remainingCount=1
    //        spaceCount[48] : remainingCount=1
    //        spaceCount[43] : remainingCount=1
    //        spaceCount[41] : remainingCount=1
    //        spaceCount[11] : remainingCount=1
    int spaceSize0 = 74;
    int spaceSize1 = 52;
    int spaceSize2 = 48;
    int spaceSizeLast = 11;
    RowRemainingSpacesCountPerSpaceType head0 = row0.getSortedSpaceTypeCountListHead();
    RowRemainingSpacesCountPerSpaceType tail = row0.getSortedSpaceTypeCountListTail();

    RowRemainingSpacesCountPerSpaceType count0 = row0.getSpaceTypeCountPerSize(spaceSize0);
    RowRemainingSpacesCountPerSpaceType count1 = row0.getSpaceTypeCountPerSize(spaceSize1);
    RowRemainingSpacesCountPerSpaceType count2 = row0.getSpaceTypeCountPerSize(spaceSize2);
    RowRemainingSpacesCountPerSpaceType countLast = row0.getSpaceTypeCountPerSize(spaceSizeLast);

    Assert.assertSame(count0, head0.getNextRemaining());
    Assert.assertSame(head0, count0.getPrevRemaining());

    Assert.assertSame(count1, count0.getNextRemaining());
    Assert.assertSame(count0, count1.getPrevRemaining());

    Assert.assertSame(count2, count1.getNextRemaining());
    Assert.assertSame(count1, count2.getPrevRemaining());

    Assert.assertSame(tail, countLast.getNextRemaining());
    Assert.assertSame(countLast, tail.getPrevRemaining());
  }
コード例 #4
0
ファイル: StubFactory.java プロジェクト: RamGanesh/atlas-lb
  public static Clusters getClustersDetails() {
    Cluster cluster = new Cluster();
    cluster.setDataCenter(DataCenter.DFW);
    cluster.setDescription("aDesc");
    cluster.setName("aClusterName");

    Cluster cluster2 = new Cluster();
    cluster2.setDataCenter((DataCenter) rndChoice(DataCenter.values()));
    cluster2.setDescription("aDesc");
    cluster2.setName("aSecondCluster");

    Clusters clusters = new Clusters();
    clusters.getClusters().add(cluster);
    clusters.getClusters().add(cluster2);

    return clusters;
  }
コード例 #5
0
ファイル: RowTest.java プロジェクト: benito1er/test-snippets
  @Test
  public void testAssignIncrServerTypeToSpaceType() {
    // Prepare
    DataCenter dc = new DataCenterReader().readResource("dc.in");
    Row row0 = dc.getRow(0);
    final int row0RemainingSizeBefore = row0.getUnassignedTotalRemainingSize();
    if (DEBUG) dumper.dumpRow(row0);
    //        Row[0] unassigned remainingSize:269
    //        spaceCount[74] : remainingCount=1
    //        spaceCount[52] : remainingCount=1
    //        spaceCount[48] : remainingCount=1
    //        spaceCount[43] : remainingCount=1
    //        spaceCount[41] : remainingCount=1
    //        spaceCount[11] : remainingCount=1
    int spaceSize0 = 74;
    int spaceSize1 = 52;
    int spaceSize2 = 48;
    int spaceSizeLast = 11;
    RowRemainingSpacesCountPerSpaceType head0 = row0.getSortedSpaceTypeCountListHead();
    RowRemainingSpacesCountPerSpaceType tail = row0.getSortedSpaceTypeCountListTail();

    RowRemainingSpacesCountPerSpaceType count0 = row0.getSpaceTypeCountPerSize(spaceSize0);
    RowRemainingSpacesCountPerSpaceType count1 = row0.getSpaceTypeCountPerSize(spaceSize1);
    RowRemainingSpacesCountPerSpaceType count2 = row0.getSpaceTypeCountPerSize(spaceSize2);
    RowRemainingSpacesCountPerSpaceType countLast = row0.getSpaceTypeCountPerSize(spaceSizeLast);

    int spaceSizeLeft01 = 72;
    RowRemainingSpacesCountPerSpaceType newCount01 = row0.getSpaceTypeCountPerSize(spaceSizeLeft01);
    Assert.assertEquals(0, newCount01.getRemainingCount());

    int server0Cap = 10;
    int server0Size = 2;
    ServerType st = dc.getOrCreateCountPerServerType(server0Cap, server0Size).serverType;
    int stCount = 1;
    // Perform
    // assign 1 x server (size=2)   => decr 1 occurrences of space 74, incr 1 occ of space 72,
    // totalSlots=4
    row0.assignIncrServerTypeToSpaceType(spaceSize0, st, stCount);
    // Post-check
    if (DEBUG) {
      System.out.println("=> after assign:");
      dumper.dumpRow(row0);
    }
    //        => after assign:
    //            Row[0] unassigned remainingSize:267
    //            spaceCount[72] : remainingCount=1
    //            spaceCount[52] : remainingCount=1
    //            spaceCount[48] : remainingCount=1
    //            spaceCount[43] : remainingCount=1
    //            spaceCount[41] : remainingCount=1
    //            spaceCount[11] : remainingCount=1

    RowRemainingSpacesCountPerSpaceType countSize0 = row0.getSpaceTypeCountPerSize(spaceSize0);
    Assert.assertEquals(0, countSize0.remainingCount);
    RowRemainingSpacesCountPerSpaceType countLeftSize0 =
        row0.getSpaceTypeCountPerSize(spaceSize0 - server0Size);
    Assert.assertEquals(1, countLeftSize0.remainingCount);

    final int row0RemainingSizeAfter = row0.getUnassignedTotalRemainingSize();
    Assert.assertEquals(row0RemainingSizeAfter, row0RemainingSizeBefore - server0Size * stCount);

    Assert.assertSame(newCount01, head0.getNextRemaining());
    Assert.assertSame(head0, newCount01.getPrevRemaining());

    Assert.assertEquals(0, count0.remainingCount);

    Assert.assertSame(count1, newCount01.getNextRemaining());
    Assert.assertSame(newCount01, count1.getPrevRemaining());

    Assert.assertSame(count2, count1.getNextRemaining());
    Assert.assertSame(count1, count2.getPrevRemaining());

    // Prepare

    // Perform
    row0.assignIncrServerTypeToSpaceType(spaceSizeLast, st, stCount);
    // Post-check
    int spaceSizeLeftLast = spaceSizeLast - st.size;
    RowRemainingSpacesCountPerSpaceType newCountLast =
        row0.getSpaceTypeCountPerSize(spaceSizeLeftLast);
    Assert.assertEquals(0, countLast.remainingCount);
    Assert.assertEquals(1, newCountLast.remainingCount);

    Assert.assertSame(tail, newCountLast.getNextRemaining());
    Assert.assertSame(newCountLast, tail.getPrevRemaining());

    Assert.assertEquals(41, newCountLast.getPrevRemaining().getSize());
  }
コード例 #6
0
 @Override
 public DataCenter get() {
   DataCenter dc = new DataCenter();
   dc.setName("Bill");
   return dc;
 }