Skip to content

Instantly share code, notes, and snippets.

View sahoosunilkumar's full-sized avatar

Sunil Kumar Sahoo sahoosunilkumar

View GitHub Profile
package com.sunilsahoo.sonarqube;
import androidx.annotation.VisibleForTesting;
public class PrivateMethodUtils {
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
boolean isEmpty(String str) {
return (str == null || str.length() == 0);
}
}
package com.sunilsahoo.sonarqube;
public class PrivateMethodUtils {
private boolean isEmpty(String str) {
return (str == null || str.length() == 0);
}
public boolean isCsv(String str) {
if (isEmpty(str)) {
return false;
package com.sunilsahoo.sonarqube.validator;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MediatorLiveData;
import androidx.lifecycle.ViewModel;
public class HomeViewModel extends ViewModel {
private MediatorLiveData<String> liveData = new MediatorLiveData<>();
public LiveData<String> getLiveData() {
import org.junit.rules.TestRule;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;
import io.reactivex.Scheduler;
import io.reactivex.android.plugins.RxAndroidPlugins;
import io.reactivex.plugins.RxJavaPlugins;
import io.reactivex.schedulers.Schedulers;
public class RxImmediateSchedulerRule implements TestRule {
@sahoosunilkumar
sahoosunilkumar / TextUtils.java
Last active December 27, 2019 22:54
Text Utils-
public class TextUtils {
private TextUtils(){
}
/**
* Returns true if the string is null or 0-length.
* @param str the string to be examined
* @return true if str is null or zero length
*/
public static boolean isEmpty(CharSequence str) {
@sahoosunilkumar
sahoosunilkumar / Utils.java
Created May 28, 2019 08:29
understanding JUnit Test methods
package com.sunilsahoo.unittesting.utils;
public class Utils {
private Utils(){
}
public static int divide(String dividend, String divisor){
return Integer.parseInt(dividend)/Integer.parseInt(divisor);
}
@sahoosunilkumar
sahoosunilkumar / AnnotationTest
Created May 28, 2019 08:24
Unit Testing for JUnit Annotations
package com.sunilsahoo.unittesting.test;
import org.junit.jupiter.api.*;
class AnnotationTest {
@BeforeAll
static void setup(){
System.out.println("@BeforeAll executed");
import { INCREMENT, DECREMENT } from "./types";
export const incrementBy = by => {
return {
type: INCREMENT,
payload: by
};
};
export const decrementBy = by => {
import { INCREMENT, DECREMENT } from "../actions/types";
const initialState = {
counter: 0
};
const counterReducer = (state = initialState, action) => {
switch (action.type) {
case INCREMENT:
return {
...state,
import { createStore, combineReducers } from "redux";
import counterReducer from "../reducers/counterReducer";
const rootReducer = combineReducers({
counterOperation: counterReducer
});
const configureStore = () => {
return createStore(rootReducer);
};