Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
coderzc committed Aug 5, 2022
1 parent 50b0534 commit 0dba887
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.json.JsonMapper;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import lombok.extern.slf4j.Slf4j;
import org.apache.qpid.server.exchange.ExchangeDefaults;
Expand Down Expand Up @@ -76,16 +77,24 @@ public static String covertObjectValueAsString(Object obj) {
}
return JSON_MAPPER.writeValueAsString(obj);
} catch (Exception e) {
log.error("Failed to covert object: {}", e.getMessage());
throw new RuntimeException(e);
}
}

public static <T> T covertStringValueAsObject(String value, Class<T> clazz) {
return JSON_MAPPER.convertValue(value, clazz);
try {
if (List.class.isAssignableFrom(clazz)) {
return JSON_MAPPER.readValue(value, clazz);
}
return JSON_MAPPER.convertValue(value, clazz);
} catch (Exception e) {
log.error("Failed to covert string: {}", e.getMessage());
throw new RuntimeException(e);
}
}

public static Object covertStringValueAsObject(String value) {
return covertStringValueAsObject(value, Object.class);
}

}

0 comments on commit 0dba887

Please sign in to comment.