// Path: src/main/java/org/rhq/simone/util/TickUtil.java
// public static long ticksToTimeUnit(long clockTicks, long ticksPerSecond, TimeUnit unit) {
//   switch (unit) {
//     case DAYS:
//     case HOURS:
//     case MINUTES:
//       return unit.convert(clockTicks / ticksPerSecond, SECONDS);
//     case SECONDS:
//       return clockTicks / ticksPerSecond;
//     case MILLISECONDS:
//     case MICROSECONDS:
//     case NANOSECONDS:
//       return unit.convert(1, SECONDS) * clockTicks / ticksPerSecond;
//     default:
//       throw new UnsupportedOperationException(String.valueOf(unit));
//   }
// }


import static java.util.concurrent.TimeUnit.DAYS;
import static java.util.concurrent.TimeUnit.HOURS;
import static java.util.concurrent.TimeUnit.MICROSECONDS;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static java.util.concurrent.TimeUnit.MINUTES;
import static java.util.concurrent.TimeUnit.NANOSECONDS;
import static java.util.concurrent.TimeUnit.SECONDS;
import static junit.framework.Assert.assertEquals;
import static org.rhq.simone.util.TickUtil.ticksToTimeUnit;
import org.junit.Test;
/*
 * Copyright 2014 Red Hat, Inc
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.rhq.simone.util;



/**
 * @author Thomas Segismont
 */
public class TickUtilTest {

  @Test
  public void testTicksToTimeUnit() throws Exception {
    long ticksPerSecond = 87, clockTicks = ticksPerSecond * DAYS.toSeconds(1);
// Path: src/main/java/org/rhq/simone/util/TickUtil.java
// public static long ticksToTimeUnit(long clockTicks, long ticksPerSecond, TimeUnit unit) {
//   switch (unit) {
//     case DAYS:
//     case HOURS:
//     case MINUTES:
//       return unit.convert(clockTicks / ticksPerSecond, SECONDS);
//     case SECONDS:
//       return clockTicks / ticksPerSecond;
//     case MILLISECONDS:
//     case MICROSECONDS:
//     case NANOSECONDS:
//       return unit.convert(1, SECONDS) * clockTicks / ticksPerSecond;
//     default:
//       throw new UnsupportedOperationException(String.valueOf(unit));
//   }
// }


// Path: src/test/java/org/rhq/simone/util/TickUtilTest.java
import static java.util.concurrent.TimeUnit.DAYS;
import static java.util.concurrent.TimeUnit.HOURS;
import static java.util.concurrent.TimeUnit.MICROSECONDS;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static java.util.concurrent.TimeUnit.MINUTES;
import static java.util.concurrent.TimeUnit.NANOSECONDS;
import static java.util.concurrent.TimeUnit.SECONDS;
import static junit.framework.Assert.assertEquals;
import static org.rhq.simone.util.TickUtil.ticksToTimeUnit;
import org.junit.Test;

/*
 * Copyright 2014 Red Hat, Inc
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.rhq.simone.util;



/**
 * @author Thomas Segismont
 */
public class TickUtilTest {

  @Test
  public void testTicksToTimeUnit() throws Exception {
    long ticksPerSecond = 87, clockTicks = ticksPerSecond * DAYS.toSeconds(1);
    assertEquals(1, ticksToTimeUnit(clockTicks, ticksPerSecond, DAYS));