Skip to content

Commit

Permalink
W-16656937: add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
pdmoineau committed Sep 12, 2024
1 parent e3ec850 commit 55f3862
Showing 1 changed file with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* Copyright (c) 2018, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: BSD-3-Clause
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
package com.demandware.core.metric;

import java.net.InetAddress;
import java.net.UnknownHostException;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

public class TestUtil
{
private static String falconPrefix = "cc-umon-client.falcon-fi";
private static String umDevPrefix = "um.dev.carbonj.";

@Test
public void testGetGraphiteMetricPrefix() throws UnknownHostException
{
String fqdn = InetAddress.getLocalHost().getHostName();
String hostname = fqdn.substring(0, fqdn.indexOf( "." ) == -1 ? fqdn.length() : fqdn.indexOf( "." ) );

assertEquals(falconPrefix + "." + hostname, Util.getGraphiteMetricPrefix(falconPrefix, true, -1, "00", "v1"));
assertEquals(falconPrefix, Util.getGraphiteMetricPrefix(falconPrefix, false, -1, "00", "v1"));
assertEquals("pod100.00.carbonj." + hostname + ".v1", Util.getGraphiteMetricPrefix(null, false, 100, "00", "v1"));
assertEquals(umDevPrefix + hostname, Util.getGraphiteMetricPrefix(null, false, -1, "00", "v1"));
}
}

0 comments on commit 55f3862

Please sign in to comment.