Search in sources :

Example 1 with JsonMapper

use of com.epam.pipeline.config.JsonMapper in project cloud-pipeline by epam.

the class PipelineRunMapper method map.

/**
 * Mapping a {@code PipelineRun}
 * @param run {@code PipelineRun}
 * @param threshold
 * @return a mapped {@code PipelineRun}, {@code Map} key - a field name of {@code PipelineRun},
 * {@code Map} value - a {@code PipelineRun} field value
 */
public static Map<String, Object> map(PipelineRun run, Long threshold) {
    JsonMapper mapper = new JsonMapper();
    Map<String, Object> params = mapper.convertValue(run, mapper.getTypeFactory().constructParametricType(Map.class, String.class, Object.class));
    if (threshold != null) {
        params.put("timeThreshold", threshold / SECONDS_IN_MINUTE);
    }
    params.put("runningTime", Duration.between(run.getStartDate().toInstant(), DateUtils.now().toInstant()).abs().getSeconds() / SECONDS_IN_MINUTE);
    return params;
}
Also used : JsonMapper(com.epam.pipeline.config.JsonMapper) Map(java.util.Map)

Example 2 with JsonMapper

use of com.epam.pipeline.config.JsonMapper in project cloud-pipeline by epam.

the class CAdvisorMonitoringManagerTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    JsonMapper objectMapper = new JsonMapper();
    cAdvisorMonitoringManager = new CAdvisorMonitoringManager(nodesManager, messageHelper, objectMapper, kubernetesManager, TIMEOUT, C_ADVISOR_PORT, false);
}
Also used : JsonMapper(com.epam.pipeline.config.JsonMapper) Before(org.junit.Before)

Aggregations

JsonMapper (com.epam.pipeline.config.JsonMapper)2 Map (java.util.Map)1 Before (org.junit.Before)1