-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added unit test to usage metrics endpoints (#1133)
* Added unit test to usage metrics endpoints
- Loading branch information
Showing
5 changed files
with
1,034 additions
and
28 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
src/main/java/org/mskcc/cbio/oncokb/config/ClockConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package org.mskcc.cbio.oncokb.config; | ||
|
||
import java.time.Clock; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
public class ClockConfig { | ||
|
||
@Bean | ||
public Clock clock() { | ||
return Clock.systemUTC(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,37 @@ | ||
package org.mskcc.cbio.oncokb.util; | ||
|
||
import org.mskcc.cbio.oncokb.config.Constants; | ||
|
||
import java.time.Clock; | ||
import java.time.Instant; | ||
import java.time.ZoneId; | ||
import java.time.ZonedDateTime; | ||
import java.time.format.DateTimeFormatter; | ||
import java.time.format.FormatStyle; | ||
import java.util.Locale; | ||
import org.mskcc.cbio.oncokb.config.Constants; | ||
|
||
/** | ||
* Created by Hongxin Zhang on 4/6/21. | ||
*/ | ||
public class TimeUtil { | ||
public static String toSystemDefaultZoneTime(Instant time) { | ||
DateTimeFormatter formatter = | ||
DateTimeFormatter.ofLocalizedDateTime(FormatStyle.FULL) | ||
.withLocale(Locale.US) | ||
.withZone(ZoneId.systemDefault()); | ||
return formatter.format(time); | ||
} | ||
|
||
public static String toNYZoneTime(Instant time) { | ||
DateTimeFormatter formatter = | ||
DateTimeFormatter.ofLocalizedDateTime(FormatStyle.FULL) | ||
.withLocale(Locale.US) | ||
.withZone(ZoneId.of(Constants.NY_ZONE_ID)); | ||
return formatter.format(time); | ||
} | ||
public static String toSystemDefaultZoneTime(Instant time) { | ||
DateTimeFormatter formatter = DateTimeFormatter | ||
.ofLocalizedDateTime(FormatStyle.FULL) | ||
.withLocale(Locale.US) | ||
.withZone(ZoneId.systemDefault()); | ||
return formatter.format(time); | ||
} | ||
|
||
public static String toNYZoneTime(Instant time) { | ||
DateTimeFormatter formatter = DateTimeFormatter | ||
.ofLocalizedDateTime(FormatStyle.FULL) | ||
.withLocale(Locale.US) | ||
.withZone(ZoneId.of(Constants.NY_ZONE_ID)); | ||
return formatter.format(time); | ||
} | ||
|
||
public static ZonedDateTime getCurrentNYTime() { | ||
return ZonedDateTime.now(ZoneId.of(Constants.NY_ZONE_ID)); | ||
} | ||
// TODO: Convert TimeUtil into a service class so we don't have autowire a clock into every class | ||
public static ZonedDateTime getCurrentNYTime(Clock clock) { | ||
return ZonedDateTime.now(clock.withZone(ZoneId.of(Constants.NY_ZONE_ID))); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.