repo_name
stringlengths 7
104
| file_path
stringlengths 13
198
| context
stringlengths 67
7.15k
| import_statement
stringlengths 16
4.43k
| code
stringlengths 40
6.98k
| prompt
stringlengths 227
8.27k
| next_line
stringlengths 8
795
|
---|---|---|---|---|---|---|
mobilejazz/CacheIO | cacheio-core/src/main/java/com/mobilejazz/cacheio/wrappers/FutureCacheWrapper.java | // Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/FutureCache.java
// public interface FutureCache<K, V> {
//
// Future<V> get(K key);
//
// Future<V> put(K key, V value, long expiry, TimeUnit unit);
//
// Future<K> remove(K key);
//
// Future<Map<K, V>> getAll(Collection<K> keys);
//
// Future<Map<K, V>> putAll(Map<K, V> map, long expiry, TimeUnit unit);
//
// Future<Collection<K>> removeAll(Collection<K> keys);
//
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/RxCache.java
// public interface RxCache<K, V> {
//
// Single<V> get(K key);
//
// Single<V> put(K key, V value, long expiry, TimeUnit unit);
//
// Single<K> remove(K key);
//
// Single<Map<K, V>> getAll(Collection<K> keys);
//
// Single<Map<K, V>> putAll(Map<K, V> map, long expiry, TimeUnit unit);
//
// Single<Collection<K>> removeAll(Collection<K> keys);
//
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/helper/Preconditions.java
// public static <T> T checkArgument(T object, String message) {
// if (object == null) {
// throw new IllegalArgumentException(message);
// }
//
// return object;
// }
| import com.mobilejazz.cacheio.FutureCache;
import com.mobilejazz.cacheio.RxCache;
import rx.Single;
import java.util.*;
import java.util.concurrent.*;
import static com.mobilejazz.cacheio.helper.Preconditions.checkArgument; | @Override public Future<V> get(K key) {
return future(config.delegate.get(key));
}
@Override public Future<V> put(K key, V value, long expiry, TimeUnit unit) {
return future(config.delegate.put(key, value, expiry, unit));
}
@Override public Future<K> remove(K key) {
return future(config.delegate.remove(key));
}
@Override public Future<Map<K, V>> getAll(Collection<K> keys) {
return future(config.delegate.getAll(keys));
}
@Override public Future<Map<K, V>> putAll(Map<K, V> map, long expiry, TimeUnit unit) {
return future(config.delegate.putAll(map, expiry, unit));
}
@Override public Future<Collection<K>> removeAll(Collection<K> keys) {
return future(config.delegate.removeAll(keys));
}
public static <K, V> Builder<K, V> newBuilder(Class<K> keyType, Class<V> valueType) {
return new Builder<K, V>().setKeyType(keyType).setValueType(valueType);
}
public static final class Builder<K, V> {
| // Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/FutureCache.java
// public interface FutureCache<K, V> {
//
// Future<V> get(K key);
//
// Future<V> put(K key, V value, long expiry, TimeUnit unit);
//
// Future<K> remove(K key);
//
// Future<Map<K, V>> getAll(Collection<K> keys);
//
// Future<Map<K, V>> putAll(Map<K, V> map, long expiry, TimeUnit unit);
//
// Future<Collection<K>> removeAll(Collection<K> keys);
//
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/RxCache.java
// public interface RxCache<K, V> {
//
// Single<V> get(K key);
//
// Single<V> put(K key, V value, long expiry, TimeUnit unit);
//
// Single<K> remove(K key);
//
// Single<Map<K, V>> getAll(Collection<K> keys);
//
// Single<Map<K, V>> putAll(Map<K, V> map, long expiry, TimeUnit unit);
//
// Single<Collection<K>> removeAll(Collection<K> keys);
//
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/helper/Preconditions.java
// public static <T> T checkArgument(T object, String message) {
// if (object == null) {
// throw new IllegalArgumentException(message);
// }
//
// return object;
// }
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/wrappers/FutureCacheWrapper.java
import com.mobilejazz.cacheio.FutureCache;
import com.mobilejazz.cacheio.RxCache;
import rx.Single;
import java.util.*;
import java.util.concurrent.*;
import static com.mobilejazz.cacheio.helper.Preconditions.checkArgument;
@Override public Future<V> get(K key) {
return future(config.delegate.get(key));
}
@Override public Future<V> put(K key, V value, long expiry, TimeUnit unit) {
return future(config.delegate.put(key, value, expiry, unit));
}
@Override public Future<K> remove(K key) {
return future(config.delegate.remove(key));
}
@Override public Future<Map<K, V>> getAll(Collection<K> keys) {
return future(config.delegate.getAll(keys));
}
@Override public Future<Map<K, V>> putAll(Map<K, V> map, long expiry, TimeUnit unit) {
return future(config.delegate.putAll(map, expiry, unit));
}
@Override public Future<Collection<K>> removeAll(Collection<K> keys) {
return future(config.delegate.removeAll(keys));
}
public static <K, V> Builder<K, V> newBuilder(Class<K> keyType, Class<V> valueType) {
return new Builder<K, V>().setKeyType(keyType).setValueType(valueType);
}
public static final class Builder<K, V> {
| private RxCache<K, V> delegate; |
mobilejazz/CacheIO | cacheio-core/src/main/java/com/mobilejazz/cacheio/wrappers/FutureCacheWrapper.java | // Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/FutureCache.java
// public interface FutureCache<K, V> {
//
// Future<V> get(K key);
//
// Future<V> put(K key, V value, long expiry, TimeUnit unit);
//
// Future<K> remove(K key);
//
// Future<Map<K, V>> getAll(Collection<K> keys);
//
// Future<Map<K, V>> putAll(Map<K, V> map, long expiry, TimeUnit unit);
//
// Future<Collection<K>> removeAll(Collection<K> keys);
//
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/RxCache.java
// public interface RxCache<K, V> {
//
// Single<V> get(K key);
//
// Single<V> put(K key, V value, long expiry, TimeUnit unit);
//
// Single<K> remove(K key);
//
// Single<Map<K, V>> getAll(Collection<K> keys);
//
// Single<Map<K, V>> putAll(Map<K, V> map, long expiry, TimeUnit unit);
//
// Single<Collection<K>> removeAll(Collection<K> keys);
//
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/helper/Preconditions.java
// public static <T> T checkArgument(T object, String message) {
// if (object == null) {
// throw new IllegalArgumentException(message);
// }
//
// return object;
// }
| import com.mobilejazz.cacheio.FutureCache;
import com.mobilejazz.cacheio.RxCache;
import rx.Single;
import java.util.*;
import java.util.concurrent.*;
import static com.mobilejazz.cacheio.helper.Preconditions.checkArgument; |
private Class<K> keyType;
private Class<V> valueType;
private Builder() {
}
private Builder(Builder<K, V> proto) {
this.delegate = proto.delegate;
this.keyType = proto.keyType;
this.valueType = proto.valueType;
}
public Builder<K, V> setDelegate(RxCache<K, V> delegate) {
this.delegate = delegate;
return this;
}
protected Builder<K, V> setKeyType(Class<K> keyType) {
this.keyType = keyType;
return this;
}
protected Builder<K, V> setValueType(Class<V> valueType) {
this.valueType = valueType;
return this;
}
public FutureCacheWrapper<K, V> build() {
| // Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/FutureCache.java
// public interface FutureCache<K, V> {
//
// Future<V> get(K key);
//
// Future<V> put(K key, V value, long expiry, TimeUnit unit);
//
// Future<K> remove(K key);
//
// Future<Map<K, V>> getAll(Collection<K> keys);
//
// Future<Map<K, V>> putAll(Map<K, V> map, long expiry, TimeUnit unit);
//
// Future<Collection<K>> removeAll(Collection<K> keys);
//
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/RxCache.java
// public interface RxCache<K, V> {
//
// Single<V> get(K key);
//
// Single<V> put(K key, V value, long expiry, TimeUnit unit);
//
// Single<K> remove(K key);
//
// Single<Map<K, V>> getAll(Collection<K> keys);
//
// Single<Map<K, V>> putAll(Map<K, V> map, long expiry, TimeUnit unit);
//
// Single<Collection<K>> removeAll(Collection<K> keys);
//
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/helper/Preconditions.java
// public static <T> T checkArgument(T object, String message) {
// if (object == null) {
// throw new IllegalArgumentException(message);
// }
//
// return object;
// }
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/wrappers/FutureCacheWrapper.java
import com.mobilejazz.cacheio.FutureCache;
import com.mobilejazz.cacheio.RxCache;
import rx.Single;
import java.util.*;
import java.util.concurrent.*;
import static com.mobilejazz.cacheio.helper.Preconditions.checkArgument;
private Class<K> keyType;
private Class<V> valueType;
private Builder() {
}
private Builder(Builder<K, V> proto) {
this.delegate = proto.delegate;
this.keyType = proto.keyType;
this.valueType = proto.valueType;
}
public Builder<K, V> setDelegate(RxCache<K, V> delegate) {
this.delegate = delegate;
return this;
}
protected Builder<K, V> setKeyType(Class<K> keyType) {
this.keyType = keyType;
return this;
}
protected Builder<K, V> setValueType(Class<V> valueType) {
this.valueType = valueType;
return this;
}
public FutureCacheWrapper<K, V> build() {
| checkArgument(keyType, "Key type cannot be null"); |
mobilejazz/CacheIO | cacheio-serializers/cacheio-gson-serializer/src/test/java/com/mobilejazz/cacheio/serializers/gson/GsonValueMapperTest.java | // Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/ValueMapper.java
// public interface ValueMapper {
//
// void write(Object value, OutputStream out) throws SerializerException;
//
// <T> T read(Class<T> type, InputStream in) throws SerializerException;
// }
//
// Path: cacheio-serializers/cacheio-gson-serializer/src/test/java/com/mobilejazz/cacheio/serializers/gson/model/UserTestModel.java
// public class UserTestModel {
//
// private int id;
// private String name;
//
// public UserTestModel() {
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
// }
| import com.google.gson.Gson;
import com.mobilejazz.cacheio.BuildConfig;
import com.mobilejazz.cacheio.mappers.ValueMapper;
import com.mobilejazz.cacheio.serializers.gson.model.UserTestModel;
import org.assertj.core.api.Assertions;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import java.io.*; | package com.mobilejazz.cacheio.serializers.gson;
@RunWith(RobolectricTestRunner.class)
@Config(constants = BuildConfig.class, sdk = 21, manifest = Config.NONE)
public class GsonValueMapperTest {
| // Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/ValueMapper.java
// public interface ValueMapper {
//
// void write(Object value, OutputStream out) throws SerializerException;
//
// <T> T read(Class<T> type, InputStream in) throws SerializerException;
// }
//
// Path: cacheio-serializers/cacheio-gson-serializer/src/test/java/com/mobilejazz/cacheio/serializers/gson/model/UserTestModel.java
// public class UserTestModel {
//
// private int id;
// private String name;
//
// public UserTestModel() {
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
// }
// Path: cacheio-serializers/cacheio-gson-serializer/src/test/java/com/mobilejazz/cacheio/serializers/gson/GsonValueMapperTest.java
import com.google.gson.Gson;
import com.mobilejazz.cacheio.BuildConfig;
import com.mobilejazz.cacheio.mappers.ValueMapper;
import com.mobilejazz.cacheio.serializers.gson.model.UserTestModel;
import org.assertj.core.api.Assertions;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import java.io.*;
package com.mobilejazz.cacheio.serializers.gson;
@RunWith(RobolectricTestRunner.class)
@Config(constants = BuildConfig.class, sdk = 21, manifest = Config.NONE)
public class GsonValueMapperTest {
| private ValueMapper valueMapper; |
mobilejazz/CacheIO | cacheio-serializers/cacheio-gson-serializer/src/test/java/com/mobilejazz/cacheio/serializers/gson/GsonValueMapperTest.java | // Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/ValueMapper.java
// public interface ValueMapper {
//
// void write(Object value, OutputStream out) throws SerializerException;
//
// <T> T read(Class<T> type, InputStream in) throws SerializerException;
// }
//
// Path: cacheio-serializers/cacheio-gson-serializer/src/test/java/com/mobilejazz/cacheio/serializers/gson/model/UserTestModel.java
// public class UserTestModel {
//
// private int id;
// private String name;
//
// public UserTestModel() {
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
// }
| import com.google.gson.Gson;
import com.mobilejazz.cacheio.BuildConfig;
import com.mobilejazz.cacheio.mappers.ValueMapper;
import com.mobilejazz.cacheio.serializers.gson.model.UserTestModel;
import org.assertj.core.api.Assertions;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import java.io.*; | package com.mobilejazz.cacheio.serializers.gson;
@RunWith(RobolectricTestRunner.class)
@Config(constants = BuildConfig.class, sdk = 21, manifest = Config.NONE)
public class GsonValueMapperTest {
private ValueMapper valueMapper;
@Before public void setUp() throws Exception {
Gson gson = new Gson();
valueMapper = new GsonValueMapper(gson);
}
@Test public void shouldWriteTheBytesOfObject() throws Exception { | // Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/ValueMapper.java
// public interface ValueMapper {
//
// void write(Object value, OutputStream out) throws SerializerException;
//
// <T> T read(Class<T> type, InputStream in) throws SerializerException;
// }
//
// Path: cacheio-serializers/cacheio-gson-serializer/src/test/java/com/mobilejazz/cacheio/serializers/gson/model/UserTestModel.java
// public class UserTestModel {
//
// private int id;
// private String name;
//
// public UserTestModel() {
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
// }
// Path: cacheio-serializers/cacheio-gson-serializer/src/test/java/com/mobilejazz/cacheio/serializers/gson/GsonValueMapperTest.java
import com.google.gson.Gson;
import com.mobilejazz.cacheio.BuildConfig;
import com.mobilejazz.cacheio.mappers.ValueMapper;
import com.mobilejazz.cacheio.serializers.gson.model.UserTestModel;
import org.assertj.core.api.Assertions;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import java.io.*;
package com.mobilejazz.cacheio.serializers.gson;
@RunWith(RobolectricTestRunner.class)
@Config(constants = BuildConfig.class, sdk = 21, manifest = Config.NONE)
public class GsonValueMapperTest {
private ValueMapper valueMapper;
@Before public void setUp() throws Exception {
Gson gson = new Gson();
valueMapper = new GsonValueMapper(gson);
}
@Test public void shouldWriteTheBytesOfObject() throws Exception { | UserTestModel userTestModel = fakeUserTestObject(); |
mobilejazz/CacheIO | cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/key/LongKeyMapper.java | // Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/KeyMapper.java
// public interface KeyMapper<T> {
//
// String toString(T model);
//
// T fromString(String str);
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/helper/Preconditions.java
// public static <T> T checkArgument(T object, String message) {
// if (object == null) {
// throw new IllegalArgumentException(message);
// }
//
// return object;
// }
| import com.mobilejazz.cacheio.mappers.KeyMapper;
import static com.mobilejazz.cacheio.helper.Preconditions.checkArgument; | package com.mobilejazz.cacheio.mappers.key;
public class LongKeyMapper implements KeyMapper<Long> {
@Override public String toString(Long model) { | // Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/KeyMapper.java
// public interface KeyMapper<T> {
//
// String toString(T model);
//
// T fromString(String str);
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/helper/Preconditions.java
// public static <T> T checkArgument(T object, String message) {
// if (object == null) {
// throw new IllegalArgumentException(message);
// }
//
// return object;
// }
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/key/LongKeyMapper.java
import com.mobilejazz.cacheio.mappers.KeyMapper;
import static com.mobilejazz.cacheio.helper.Preconditions.checkArgument;
package com.mobilejazz.cacheio.mappers.key;
public class LongKeyMapper implements KeyMapper<Long> {
@Override public String toString(Long model) { | checkArgument(model, "key cannot be null"); |
mobilejazz/CacheIO | cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/key/FloatKeyMapper.java | // Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/KeyMapper.java
// public interface KeyMapper<T> {
//
// String toString(T model);
//
// T fromString(String str);
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/helper/Preconditions.java
// public static <T> T checkArgument(T object, String message) {
// if (object == null) {
// throw new IllegalArgumentException(message);
// }
//
// return object;
// }
| import com.mobilejazz.cacheio.mappers.KeyMapper;
import static com.mobilejazz.cacheio.helper.Preconditions.checkArgument; | /*
* Copyright (C) 2016 Mobile Jazz
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.mobilejazz.cacheio.mappers.key;
public class FloatKeyMapper implements KeyMapper<Float> {
@Override public String toString(Float model) { | // Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/KeyMapper.java
// public interface KeyMapper<T> {
//
// String toString(T model);
//
// T fromString(String str);
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/helper/Preconditions.java
// public static <T> T checkArgument(T object, String message) {
// if (object == null) {
// throw new IllegalArgumentException(message);
// }
//
// return object;
// }
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/key/FloatKeyMapper.java
import com.mobilejazz.cacheio.mappers.KeyMapper;
import static com.mobilejazz.cacheio.helper.Preconditions.checkArgument;
/*
* Copyright (C) 2016 Mobile Jazz
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.mobilejazz.cacheio.mappers.key;
public class FloatKeyMapper implements KeyMapper<Float> {
@Override public String toString(Float model) { | checkArgument(model, "key cannot be null"); |
mobilejazz/CacheIO | cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/value/DefaultValueMapper.java | // Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/ValueMapper.java
// public interface ValueMapper {
//
// void write(Object value, OutputStream out) throws SerializerException;
//
// <T> T read(Class<T> type, InputStream in) throws SerializerException;
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/exceptions/SerializerException.java
// public class SerializerException extends CacheIOException {
//
// public SerializerException() {
// }
//
// public SerializerException(String detailMessage) {
// super(detailMessage);
// }
//
// public SerializerException(String detailMessage, Throwable throwable) {
// super(detailMessage, throwable);
// }
//
// public SerializerException(Throwable throwable) {
// super(throwable);
// }
// }
| import com.mobilejazz.cacheio.mappers.ValueMapper;
import com.mobilejazz.cacheio.exceptions.SerializerException;
import java.io.*;
import java.util.*;
import java.util.concurrent.*; | /*
* Copyright (C) 2016 Mobile Jazz
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.mobilejazz.cacheio.mappers.value;
public class DefaultValueMapper implements ValueMapper {
private final Random random = new Random();
private final Map<SerializedValue, Object> bytesToValue = new ConcurrentHashMap<>();
| // Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/ValueMapper.java
// public interface ValueMapper {
//
// void write(Object value, OutputStream out) throws SerializerException;
//
// <T> T read(Class<T> type, InputStream in) throws SerializerException;
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/exceptions/SerializerException.java
// public class SerializerException extends CacheIOException {
//
// public SerializerException() {
// }
//
// public SerializerException(String detailMessage) {
// super(detailMessage);
// }
//
// public SerializerException(String detailMessage, Throwable throwable) {
// super(detailMessage, throwable);
// }
//
// public SerializerException(Throwable throwable) {
// super(throwable);
// }
// }
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/value/DefaultValueMapper.java
import com.mobilejazz.cacheio.mappers.ValueMapper;
import com.mobilejazz.cacheio.exceptions.SerializerException;
import java.io.*;
import java.util.*;
import java.util.concurrent.*;
/*
* Copyright (C) 2016 Mobile Jazz
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.mobilejazz.cacheio.mappers.value;
public class DefaultValueMapper implements ValueMapper {
private final Random random = new Random();
private final Map<SerializedValue, Object> bytesToValue = new ConcurrentHashMap<>();
| @Override public void write(Object value, OutputStream out) throws SerializerException { |
mobilejazz/CacheIO | cacheio-repository/src/androidTest/java/com/mobilejazz/cacheio/RxRepositoryTests.java | // Path: cacheio-repository/src/main/java/com/mobilejazz/cacheio/mappers/DefaultQueryMapper.java
// public class DefaultQueryMapper implements KeyMapper<DefaultQuery> {
//
// @Override public String toString(DefaultQuery model) {
// checkArgument(model, "DefaultQuery == null");
// return model.getId();
// }
//
// @Override public DefaultQuery fromString(String str) {
// checkArgument(str, "DefaultQuery string value == null");
// return new DefaultQuery(str);
// }
// }
//
// Path: cacheio-repository/src/main/java/com/mobilejazz/cacheio/mappers/PaginatedQueryMapper.java
// public class PaginatedQueryMapper implements KeyMapper<PaginatedQuery> {
//
// private final static String DELIMITER = "_";
//
// @Override public String toString(PaginatedQuery model) {
// checkArgument(model, "PaginatedQuery == null");
// return String.valueOf(model.getId() + DELIMITER + model.getOffset())
// + DELIMITER
// + model.getLimit();
// }
//
// @Override public PaginatedQuery fromString(String str) {
// checkArgument(str, "PaginatedQuery string value == null");
// String[] tokens = str.split(DELIMITER);
// String id = tokens[0];
// String offset = tokens[1];
// String limit = tokens[2];
// return new PaginatedQuery(id, Integer.parseInt(offset), Integer.parseInt(limit));
// }
// }
//
// Path: cacheio-repository/src/androidTest/java/com/mobilejazz/cacheio/model/TestUser.java
// public class TestUser implements HasId<String> {
//
// private String id;
// private String name;
//
// public TestUser(String id, String name) {
// this.id = id;
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
//
// @Override public String getId() {
// return this.id;
// }
// }
//
// Path: cacheio-repository/src/main/java/com/mobilejazz/cacheio/query/DefaultQuery.java
// public class DefaultQuery implements Query {
//
// private final String id;
//
// public DefaultQuery(String id) {
// this.id = id;
// }
//
// @Override public String getId() {
// return this.id;
// }
//
// @Override public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// DefaultQuery query = (DefaultQuery) o;
//
// return !(id != null ? !id.equals(query.id) : query.id != null);
//
// }
//
// @Override public int hashCode() {
// return id != null ? id.hashCode() : 0;
// }
// }
//
// Path: cacheio-repository/src/main/java/com/mobilejazz/cacheio/query/PaginatedQuery.java
// public class PaginatedQuery implements Query {
//
// private final String id;
// private final int offset;
// private final int limit;
//
// public PaginatedQuery(String id, int offset, int limit) {
// this.id = id;
// this.offset = offset;
// this.limit = limit;
// }
//
// public int getOffset() {
// return offset;
// }
//
// public int getLimit() {
// return limit;
// }
//
// @Override public String getId() {
// return id;
// }
//
// @Override public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// PaginatedQuery that = (PaginatedQuery) o;
//
// if (offset != that.offset) return false;
// if (limit != that.limit) return false;
// return id.equals(that.id);
//
// }
//
// @Override public int hashCode() {
// int result = id.hashCode();
// result = 31 * result + offset;
// result = 31 * result + limit;
// return result;
// }
// }
| import java.util.concurrent.*;
import static org.assertj.core.api.Assertions.assertThat;
import android.support.annotation.NonNull;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import com.mobilejazz.cacheio.mappers.DefaultQueryMapper;
import com.mobilejazz.cacheio.mappers.PaginatedQueryMapper;
import com.mobilejazz.cacheio.model.TestUser;
import com.mobilejazz.cacheio.query.DefaultQuery;
import com.mobilejazz.cacheio.query.PaginatedQuery;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import rx.Single;
import java.util.*; | /*
* Copyright (C) 2016 Mobile Jazz
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.mobilejazz.cacheio;
@RunWith(AndroidJUnit4.class) public class RxRepositoryTests {
private CacheIO cacheIO;
public static final String FAKE_TEST_USER_ID = "fake.user.id";
public static final String FAKE_TEST_USER_NAME = "fake.test.user.name";
@Before public void setUp() throws Exception {
this.cacheIO = CacheIO.with(InstrumentationRegistry.getContext())
.identifier("test.database")
.executor(Executors.newSingleThreadExecutor()) | // Path: cacheio-repository/src/main/java/com/mobilejazz/cacheio/mappers/DefaultQueryMapper.java
// public class DefaultQueryMapper implements KeyMapper<DefaultQuery> {
//
// @Override public String toString(DefaultQuery model) {
// checkArgument(model, "DefaultQuery == null");
// return model.getId();
// }
//
// @Override public DefaultQuery fromString(String str) {
// checkArgument(str, "DefaultQuery string value == null");
// return new DefaultQuery(str);
// }
// }
//
// Path: cacheio-repository/src/main/java/com/mobilejazz/cacheio/mappers/PaginatedQueryMapper.java
// public class PaginatedQueryMapper implements KeyMapper<PaginatedQuery> {
//
// private final static String DELIMITER = "_";
//
// @Override public String toString(PaginatedQuery model) {
// checkArgument(model, "PaginatedQuery == null");
// return String.valueOf(model.getId() + DELIMITER + model.getOffset())
// + DELIMITER
// + model.getLimit();
// }
//
// @Override public PaginatedQuery fromString(String str) {
// checkArgument(str, "PaginatedQuery string value == null");
// String[] tokens = str.split(DELIMITER);
// String id = tokens[0];
// String offset = tokens[1];
// String limit = tokens[2];
// return new PaginatedQuery(id, Integer.parseInt(offset), Integer.parseInt(limit));
// }
// }
//
// Path: cacheio-repository/src/androidTest/java/com/mobilejazz/cacheio/model/TestUser.java
// public class TestUser implements HasId<String> {
//
// private String id;
// private String name;
//
// public TestUser(String id, String name) {
// this.id = id;
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
//
// @Override public String getId() {
// return this.id;
// }
// }
//
// Path: cacheio-repository/src/main/java/com/mobilejazz/cacheio/query/DefaultQuery.java
// public class DefaultQuery implements Query {
//
// private final String id;
//
// public DefaultQuery(String id) {
// this.id = id;
// }
//
// @Override public String getId() {
// return this.id;
// }
//
// @Override public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// DefaultQuery query = (DefaultQuery) o;
//
// return !(id != null ? !id.equals(query.id) : query.id != null);
//
// }
//
// @Override public int hashCode() {
// return id != null ? id.hashCode() : 0;
// }
// }
//
// Path: cacheio-repository/src/main/java/com/mobilejazz/cacheio/query/PaginatedQuery.java
// public class PaginatedQuery implements Query {
//
// private final String id;
// private final int offset;
// private final int limit;
//
// public PaginatedQuery(String id, int offset, int limit) {
// this.id = id;
// this.offset = offset;
// this.limit = limit;
// }
//
// public int getOffset() {
// return offset;
// }
//
// public int getLimit() {
// return limit;
// }
//
// @Override public String getId() {
// return id;
// }
//
// @Override public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// PaginatedQuery that = (PaginatedQuery) o;
//
// if (offset != that.offset) return false;
// if (limit != that.limit) return false;
// return id.equals(that.id);
//
// }
//
// @Override public int hashCode() {
// int result = id.hashCode();
// result = 31 * result + offset;
// result = 31 * result + limit;
// return result;
// }
// }
// Path: cacheio-repository/src/androidTest/java/com/mobilejazz/cacheio/RxRepositoryTests.java
import java.util.concurrent.*;
import static org.assertj.core.api.Assertions.assertThat;
import android.support.annotation.NonNull;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import com.mobilejazz.cacheio.mappers.DefaultQueryMapper;
import com.mobilejazz.cacheio.mappers.PaginatedQueryMapper;
import com.mobilejazz.cacheio.model.TestUser;
import com.mobilejazz.cacheio.query.DefaultQuery;
import com.mobilejazz.cacheio.query.PaginatedQuery;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import rx.Single;
import java.util.*;
/*
* Copyright (C) 2016 Mobile Jazz
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.mobilejazz.cacheio;
@RunWith(AndroidJUnit4.class) public class RxRepositoryTests {
private CacheIO cacheIO;
public static final String FAKE_TEST_USER_ID = "fake.user.id";
public static final String FAKE_TEST_USER_NAME = "fake.test.user.name";
@Before public void setUp() throws Exception {
this.cacheIO = CacheIO.with(InstrumentationRegistry.getContext())
.identifier("test.database")
.executor(Executors.newSingleThreadExecutor()) | .setKeyMapper(PaginatedQuery.class, new PaginatedQueryMapper()) |
mobilejazz/CacheIO | cacheio-repository/src/androidTest/java/com/mobilejazz/cacheio/RxRepositoryTests.java | // Path: cacheio-repository/src/main/java/com/mobilejazz/cacheio/mappers/DefaultQueryMapper.java
// public class DefaultQueryMapper implements KeyMapper<DefaultQuery> {
//
// @Override public String toString(DefaultQuery model) {
// checkArgument(model, "DefaultQuery == null");
// return model.getId();
// }
//
// @Override public DefaultQuery fromString(String str) {
// checkArgument(str, "DefaultQuery string value == null");
// return new DefaultQuery(str);
// }
// }
//
// Path: cacheio-repository/src/main/java/com/mobilejazz/cacheio/mappers/PaginatedQueryMapper.java
// public class PaginatedQueryMapper implements KeyMapper<PaginatedQuery> {
//
// private final static String DELIMITER = "_";
//
// @Override public String toString(PaginatedQuery model) {
// checkArgument(model, "PaginatedQuery == null");
// return String.valueOf(model.getId() + DELIMITER + model.getOffset())
// + DELIMITER
// + model.getLimit();
// }
//
// @Override public PaginatedQuery fromString(String str) {
// checkArgument(str, "PaginatedQuery string value == null");
// String[] tokens = str.split(DELIMITER);
// String id = tokens[0];
// String offset = tokens[1];
// String limit = tokens[2];
// return new PaginatedQuery(id, Integer.parseInt(offset), Integer.parseInt(limit));
// }
// }
//
// Path: cacheio-repository/src/androidTest/java/com/mobilejazz/cacheio/model/TestUser.java
// public class TestUser implements HasId<String> {
//
// private String id;
// private String name;
//
// public TestUser(String id, String name) {
// this.id = id;
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
//
// @Override public String getId() {
// return this.id;
// }
// }
//
// Path: cacheio-repository/src/main/java/com/mobilejazz/cacheio/query/DefaultQuery.java
// public class DefaultQuery implements Query {
//
// private final String id;
//
// public DefaultQuery(String id) {
// this.id = id;
// }
//
// @Override public String getId() {
// return this.id;
// }
//
// @Override public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// DefaultQuery query = (DefaultQuery) o;
//
// return !(id != null ? !id.equals(query.id) : query.id != null);
//
// }
//
// @Override public int hashCode() {
// return id != null ? id.hashCode() : 0;
// }
// }
//
// Path: cacheio-repository/src/main/java/com/mobilejazz/cacheio/query/PaginatedQuery.java
// public class PaginatedQuery implements Query {
//
// private final String id;
// private final int offset;
// private final int limit;
//
// public PaginatedQuery(String id, int offset, int limit) {
// this.id = id;
// this.offset = offset;
// this.limit = limit;
// }
//
// public int getOffset() {
// return offset;
// }
//
// public int getLimit() {
// return limit;
// }
//
// @Override public String getId() {
// return id;
// }
//
// @Override public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// PaginatedQuery that = (PaginatedQuery) o;
//
// if (offset != that.offset) return false;
// if (limit != that.limit) return false;
// return id.equals(that.id);
//
// }
//
// @Override public int hashCode() {
// int result = id.hashCode();
// result = 31 * result + offset;
// result = 31 * result + limit;
// return result;
// }
// }
| import java.util.concurrent.*;
import static org.assertj.core.api.Assertions.assertThat;
import android.support.annotation.NonNull;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import com.mobilejazz.cacheio.mappers.DefaultQueryMapper;
import com.mobilejazz.cacheio.mappers.PaginatedQueryMapper;
import com.mobilejazz.cacheio.model.TestUser;
import com.mobilejazz.cacheio.query.DefaultQuery;
import com.mobilejazz.cacheio.query.PaginatedQuery;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import rx.Single;
import java.util.*; | /*
* Copyright (C) 2016 Mobile Jazz
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.mobilejazz.cacheio;
@RunWith(AndroidJUnit4.class) public class RxRepositoryTests {
private CacheIO cacheIO;
public static final String FAKE_TEST_USER_ID = "fake.user.id";
public static final String FAKE_TEST_USER_NAME = "fake.test.user.name";
@Before public void setUp() throws Exception {
this.cacheIO = CacheIO.with(InstrumentationRegistry.getContext())
.identifier("test.database")
.executor(Executors.newSingleThreadExecutor()) | // Path: cacheio-repository/src/main/java/com/mobilejazz/cacheio/mappers/DefaultQueryMapper.java
// public class DefaultQueryMapper implements KeyMapper<DefaultQuery> {
//
// @Override public String toString(DefaultQuery model) {
// checkArgument(model, "DefaultQuery == null");
// return model.getId();
// }
//
// @Override public DefaultQuery fromString(String str) {
// checkArgument(str, "DefaultQuery string value == null");
// return new DefaultQuery(str);
// }
// }
//
// Path: cacheio-repository/src/main/java/com/mobilejazz/cacheio/mappers/PaginatedQueryMapper.java
// public class PaginatedQueryMapper implements KeyMapper<PaginatedQuery> {
//
// private final static String DELIMITER = "_";
//
// @Override public String toString(PaginatedQuery model) {
// checkArgument(model, "PaginatedQuery == null");
// return String.valueOf(model.getId() + DELIMITER + model.getOffset())
// + DELIMITER
// + model.getLimit();
// }
//
// @Override public PaginatedQuery fromString(String str) {
// checkArgument(str, "PaginatedQuery string value == null");
// String[] tokens = str.split(DELIMITER);
// String id = tokens[0];
// String offset = tokens[1];
// String limit = tokens[2];
// return new PaginatedQuery(id, Integer.parseInt(offset), Integer.parseInt(limit));
// }
// }
//
// Path: cacheio-repository/src/androidTest/java/com/mobilejazz/cacheio/model/TestUser.java
// public class TestUser implements HasId<String> {
//
// private String id;
// private String name;
//
// public TestUser(String id, String name) {
// this.id = id;
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
//
// @Override public String getId() {
// return this.id;
// }
// }
//
// Path: cacheio-repository/src/main/java/com/mobilejazz/cacheio/query/DefaultQuery.java
// public class DefaultQuery implements Query {
//
// private final String id;
//
// public DefaultQuery(String id) {
// this.id = id;
// }
//
// @Override public String getId() {
// return this.id;
// }
//
// @Override public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// DefaultQuery query = (DefaultQuery) o;
//
// return !(id != null ? !id.equals(query.id) : query.id != null);
//
// }
//
// @Override public int hashCode() {
// return id != null ? id.hashCode() : 0;
// }
// }
//
// Path: cacheio-repository/src/main/java/com/mobilejazz/cacheio/query/PaginatedQuery.java
// public class PaginatedQuery implements Query {
//
// private final String id;
// private final int offset;
// private final int limit;
//
// public PaginatedQuery(String id, int offset, int limit) {
// this.id = id;
// this.offset = offset;
// this.limit = limit;
// }
//
// public int getOffset() {
// return offset;
// }
//
// public int getLimit() {
// return limit;
// }
//
// @Override public String getId() {
// return id;
// }
//
// @Override public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// PaginatedQuery that = (PaginatedQuery) o;
//
// if (offset != that.offset) return false;
// if (limit != that.limit) return false;
// return id.equals(that.id);
//
// }
//
// @Override public int hashCode() {
// int result = id.hashCode();
// result = 31 * result + offset;
// result = 31 * result + limit;
// return result;
// }
// }
// Path: cacheio-repository/src/androidTest/java/com/mobilejazz/cacheio/RxRepositoryTests.java
import java.util.concurrent.*;
import static org.assertj.core.api.Assertions.assertThat;
import android.support.annotation.NonNull;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import com.mobilejazz.cacheio.mappers.DefaultQueryMapper;
import com.mobilejazz.cacheio.mappers.PaginatedQueryMapper;
import com.mobilejazz.cacheio.model.TestUser;
import com.mobilejazz.cacheio.query.DefaultQuery;
import com.mobilejazz.cacheio.query.PaginatedQuery;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import rx.Single;
import java.util.*;
/*
* Copyright (C) 2016 Mobile Jazz
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.mobilejazz.cacheio;
@RunWith(AndroidJUnit4.class) public class RxRepositoryTests {
private CacheIO cacheIO;
public static final String FAKE_TEST_USER_ID = "fake.user.id";
public static final String FAKE_TEST_USER_NAME = "fake.test.user.name";
@Before public void setUp() throws Exception {
this.cacheIO = CacheIO.with(InstrumentationRegistry.getContext())
.identifier("test.database")
.executor(Executors.newSingleThreadExecutor()) | .setKeyMapper(PaginatedQuery.class, new PaginatedQueryMapper()) |
mobilejazz/CacheIO | cacheio-repository/src/androidTest/java/com/mobilejazz/cacheio/RxRepositoryTests.java | // Path: cacheio-repository/src/main/java/com/mobilejazz/cacheio/mappers/DefaultQueryMapper.java
// public class DefaultQueryMapper implements KeyMapper<DefaultQuery> {
//
// @Override public String toString(DefaultQuery model) {
// checkArgument(model, "DefaultQuery == null");
// return model.getId();
// }
//
// @Override public DefaultQuery fromString(String str) {
// checkArgument(str, "DefaultQuery string value == null");
// return new DefaultQuery(str);
// }
// }
//
// Path: cacheio-repository/src/main/java/com/mobilejazz/cacheio/mappers/PaginatedQueryMapper.java
// public class PaginatedQueryMapper implements KeyMapper<PaginatedQuery> {
//
// private final static String DELIMITER = "_";
//
// @Override public String toString(PaginatedQuery model) {
// checkArgument(model, "PaginatedQuery == null");
// return String.valueOf(model.getId() + DELIMITER + model.getOffset())
// + DELIMITER
// + model.getLimit();
// }
//
// @Override public PaginatedQuery fromString(String str) {
// checkArgument(str, "PaginatedQuery string value == null");
// String[] tokens = str.split(DELIMITER);
// String id = tokens[0];
// String offset = tokens[1];
// String limit = tokens[2];
// return new PaginatedQuery(id, Integer.parseInt(offset), Integer.parseInt(limit));
// }
// }
//
// Path: cacheio-repository/src/androidTest/java/com/mobilejazz/cacheio/model/TestUser.java
// public class TestUser implements HasId<String> {
//
// private String id;
// private String name;
//
// public TestUser(String id, String name) {
// this.id = id;
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
//
// @Override public String getId() {
// return this.id;
// }
// }
//
// Path: cacheio-repository/src/main/java/com/mobilejazz/cacheio/query/DefaultQuery.java
// public class DefaultQuery implements Query {
//
// private final String id;
//
// public DefaultQuery(String id) {
// this.id = id;
// }
//
// @Override public String getId() {
// return this.id;
// }
//
// @Override public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// DefaultQuery query = (DefaultQuery) o;
//
// return !(id != null ? !id.equals(query.id) : query.id != null);
//
// }
//
// @Override public int hashCode() {
// return id != null ? id.hashCode() : 0;
// }
// }
//
// Path: cacheio-repository/src/main/java/com/mobilejazz/cacheio/query/PaginatedQuery.java
// public class PaginatedQuery implements Query {
//
// private final String id;
// private final int offset;
// private final int limit;
//
// public PaginatedQuery(String id, int offset, int limit) {
// this.id = id;
// this.offset = offset;
// this.limit = limit;
// }
//
// public int getOffset() {
// return offset;
// }
//
// public int getLimit() {
// return limit;
// }
//
// @Override public String getId() {
// return id;
// }
//
// @Override public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// PaginatedQuery that = (PaginatedQuery) o;
//
// if (offset != that.offset) return false;
// if (limit != that.limit) return false;
// return id.equals(that.id);
//
// }
//
// @Override public int hashCode() {
// int result = id.hashCode();
// result = 31 * result + offset;
// result = 31 * result + limit;
// return result;
// }
// }
| import java.util.concurrent.*;
import static org.assertj.core.api.Assertions.assertThat;
import android.support.annotation.NonNull;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import com.mobilejazz.cacheio.mappers.DefaultQueryMapper;
import com.mobilejazz.cacheio.mappers.PaginatedQueryMapper;
import com.mobilejazz.cacheio.model.TestUser;
import com.mobilejazz.cacheio.query.DefaultQuery;
import com.mobilejazz.cacheio.query.PaginatedQuery;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import rx.Single;
import java.util.*; | /*
* Copyright (C) 2016 Mobile Jazz
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.mobilejazz.cacheio;
@RunWith(AndroidJUnit4.class) public class RxRepositoryTests {
private CacheIO cacheIO;
public static final String FAKE_TEST_USER_ID = "fake.user.id";
public static final String FAKE_TEST_USER_NAME = "fake.test.user.name";
@Before public void setUp() throws Exception {
this.cacheIO = CacheIO.with(InstrumentationRegistry.getContext())
.identifier("test.database")
.executor(Executors.newSingleThreadExecutor())
.setKeyMapper(PaginatedQuery.class, new PaginatedQueryMapper()) | // Path: cacheio-repository/src/main/java/com/mobilejazz/cacheio/mappers/DefaultQueryMapper.java
// public class DefaultQueryMapper implements KeyMapper<DefaultQuery> {
//
// @Override public String toString(DefaultQuery model) {
// checkArgument(model, "DefaultQuery == null");
// return model.getId();
// }
//
// @Override public DefaultQuery fromString(String str) {
// checkArgument(str, "DefaultQuery string value == null");
// return new DefaultQuery(str);
// }
// }
//
// Path: cacheio-repository/src/main/java/com/mobilejazz/cacheio/mappers/PaginatedQueryMapper.java
// public class PaginatedQueryMapper implements KeyMapper<PaginatedQuery> {
//
// private final static String DELIMITER = "_";
//
// @Override public String toString(PaginatedQuery model) {
// checkArgument(model, "PaginatedQuery == null");
// return String.valueOf(model.getId() + DELIMITER + model.getOffset())
// + DELIMITER
// + model.getLimit();
// }
//
// @Override public PaginatedQuery fromString(String str) {
// checkArgument(str, "PaginatedQuery string value == null");
// String[] tokens = str.split(DELIMITER);
// String id = tokens[0];
// String offset = tokens[1];
// String limit = tokens[2];
// return new PaginatedQuery(id, Integer.parseInt(offset), Integer.parseInt(limit));
// }
// }
//
// Path: cacheio-repository/src/androidTest/java/com/mobilejazz/cacheio/model/TestUser.java
// public class TestUser implements HasId<String> {
//
// private String id;
// private String name;
//
// public TestUser(String id, String name) {
// this.id = id;
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
//
// @Override public String getId() {
// return this.id;
// }
// }
//
// Path: cacheio-repository/src/main/java/com/mobilejazz/cacheio/query/DefaultQuery.java
// public class DefaultQuery implements Query {
//
// private final String id;
//
// public DefaultQuery(String id) {
// this.id = id;
// }
//
// @Override public String getId() {
// return this.id;
// }
//
// @Override public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// DefaultQuery query = (DefaultQuery) o;
//
// return !(id != null ? !id.equals(query.id) : query.id != null);
//
// }
//
// @Override public int hashCode() {
// return id != null ? id.hashCode() : 0;
// }
// }
//
// Path: cacheio-repository/src/main/java/com/mobilejazz/cacheio/query/PaginatedQuery.java
// public class PaginatedQuery implements Query {
//
// private final String id;
// private final int offset;
// private final int limit;
//
// public PaginatedQuery(String id, int offset, int limit) {
// this.id = id;
// this.offset = offset;
// this.limit = limit;
// }
//
// public int getOffset() {
// return offset;
// }
//
// public int getLimit() {
// return limit;
// }
//
// @Override public String getId() {
// return id;
// }
//
// @Override public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// PaginatedQuery that = (PaginatedQuery) o;
//
// if (offset != that.offset) return false;
// if (limit != that.limit) return false;
// return id.equals(that.id);
//
// }
//
// @Override public int hashCode() {
// int result = id.hashCode();
// result = 31 * result + offset;
// result = 31 * result + limit;
// return result;
// }
// }
// Path: cacheio-repository/src/androidTest/java/com/mobilejazz/cacheio/RxRepositoryTests.java
import java.util.concurrent.*;
import static org.assertj.core.api.Assertions.assertThat;
import android.support.annotation.NonNull;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import com.mobilejazz.cacheio.mappers.DefaultQueryMapper;
import com.mobilejazz.cacheio.mappers.PaginatedQueryMapper;
import com.mobilejazz.cacheio.model.TestUser;
import com.mobilejazz.cacheio.query.DefaultQuery;
import com.mobilejazz.cacheio.query.PaginatedQuery;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import rx.Single;
import java.util.*;
/*
* Copyright (C) 2016 Mobile Jazz
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.mobilejazz.cacheio;
@RunWith(AndroidJUnit4.class) public class RxRepositoryTests {
private CacheIO cacheIO;
public static final String FAKE_TEST_USER_ID = "fake.user.id";
public static final String FAKE_TEST_USER_NAME = "fake.test.user.name";
@Before public void setUp() throws Exception {
this.cacheIO = CacheIO.with(InstrumentationRegistry.getContext())
.identifier("test.database")
.executor(Executors.newSingleThreadExecutor())
.setKeyMapper(PaginatedQuery.class, new PaginatedQueryMapper()) | .setKeyMapper(DefaultQuery.class, new DefaultQueryMapper()) |
mobilejazz/CacheIO | cacheio-repository/src/androidTest/java/com/mobilejazz/cacheio/RxRepositoryTests.java | // Path: cacheio-repository/src/main/java/com/mobilejazz/cacheio/mappers/DefaultQueryMapper.java
// public class DefaultQueryMapper implements KeyMapper<DefaultQuery> {
//
// @Override public String toString(DefaultQuery model) {
// checkArgument(model, "DefaultQuery == null");
// return model.getId();
// }
//
// @Override public DefaultQuery fromString(String str) {
// checkArgument(str, "DefaultQuery string value == null");
// return new DefaultQuery(str);
// }
// }
//
// Path: cacheio-repository/src/main/java/com/mobilejazz/cacheio/mappers/PaginatedQueryMapper.java
// public class PaginatedQueryMapper implements KeyMapper<PaginatedQuery> {
//
// private final static String DELIMITER = "_";
//
// @Override public String toString(PaginatedQuery model) {
// checkArgument(model, "PaginatedQuery == null");
// return String.valueOf(model.getId() + DELIMITER + model.getOffset())
// + DELIMITER
// + model.getLimit();
// }
//
// @Override public PaginatedQuery fromString(String str) {
// checkArgument(str, "PaginatedQuery string value == null");
// String[] tokens = str.split(DELIMITER);
// String id = tokens[0];
// String offset = tokens[1];
// String limit = tokens[2];
// return new PaginatedQuery(id, Integer.parseInt(offset), Integer.parseInt(limit));
// }
// }
//
// Path: cacheio-repository/src/androidTest/java/com/mobilejazz/cacheio/model/TestUser.java
// public class TestUser implements HasId<String> {
//
// private String id;
// private String name;
//
// public TestUser(String id, String name) {
// this.id = id;
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
//
// @Override public String getId() {
// return this.id;
// }
// }
//
// Path: cacheio-repository/src/main/java/com/mobilejazz/cacheio/query/DefaultQuery.java
// public class DefaultQuery implements Query {
//
// private final String id;
//
// public DefaultQuery(String id) {
// this.id = id;
// }
//
// @Override public String getId() {
// return this.id;
// }
//
// @Override public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// DefaultQuery query = (DefaultQuery) o;
//
// return !(id != null ? !id.equals(query.id) : query.id != null);
//
// }
//
// @Override public int hashCode() {
// return id != null ? id.hashCode() : 0;
// }
// }
//
// Path: cacheio-repository/src/main/java/com/mobilejazz/cacheio/query/PaginatedQuery.java
// public class PaginatedQuery implements Query {
//
// private final String id;
// private final int offset;
// private final int limit;
//
// public PaginatedQuery(String id, int offset, int limit) {
// this.id = id;
// this.offset = offset;
// this.limit = limit;
// }
//
// public int getOffset() {
// return offset;
// }
//
// public int getLimit() {
// return limit;
// }
//
// @Override public String getId() {
// return id;
// }
//
// @Override public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// PaginatedQuery that = (PaginatedQuery) o;
//
// if (offset != that.offset) return false;
// if (limit != that.limit) return false;
// return id.equals(that.id);
//
// }
//
// @Override public int hashCode() {
// int result = id.hashCode();
// result = 31 * result + offset;
// result = 31 * result + limit;
// return result;
// }
// }
| import java.util.concurrent.*;
import static org.assertj.core.api.Assertions.assertThat;
import android.support.annotation.NonNull;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import com.mobilejazz.cacheio.mappers.DefaultQueryMapper;
import com.mobilejazz.cacheio.mappers.PaginatedQueryMapper;
import com.mobilejazz.cacheio.model.TestUser;
import com.mobilejazz.cacheio.query.DefaultQuery;
import com.mobilejazz.cacheio.query.PaginatedQuery;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import rx.Single;
import java.util.*; | /*
* Copyright (C) 2016 Mobile Jazz
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.mobilejazz.cacheio;
@RunWith(AndroidJUnit4.class) public class RxRepositoryTests {
private CacheIO cacheIO;
public static final String FAKE_TEST_USER_ID = "fake.user.id";
public static final String FAKE_TEST_USER_NAME = "fake.test.user.name";
@Before public void setUp() throws Exception {
this.cacheIO = CacheIO.with(InstrumentationRegistry.getContext())
.identifier("test.database")
.executor(Executors.newSingleThreadExecutor())
.setKeyMapper(PaginatedQuery.class, new PaginatedQueryMapper()) | // Path: cacheio-repository/src/main/java/com/mobilejazz/cacheio/mappers/DefaultQueryMapper.java
// public class DefaultQueryMapper implements KeyMapper<DefaultQuery> {
//
// @Override public String toString(DefaultQuery model) {
// checkArgument(model, "DefaultQuery == null");
// return model.getId();
// }
//
// @Override public DefaultQuery fromString(String str) {
// checkArgument(str, "DefaultQuery string value == null");
// return new DefaultQuery(str);
// }
// }
//
// Path: cacheio-repository/src/main/java/com/mobilejazz/cacheio/mappers/PaginatedQueryMapper.java
// public class PaginatedQueryMapper implements KeyMapper<PaginatedQuery> {
//
// private final static String DELIMITER = "_";
//
// @Override public String toString(PaginatedQuery model) {
// checkArgument(model, "PaginatedQuery == null");
// return String.valueOf(model.getId() + DELIMITER + model.getOffset())
// + DELIMITER
// + model.getLimit();
// }
//
// @Override public PaginatedQuery fromString(String str) {
// checkArgument(str, "PaginatedQuery string value == null");
// String[] tokens = str.split(DELIMITER);
// String id = tokens[0];
// String offset = tokens[1];
// String limit = tokens[2];
// return new PaginatedQuery(id, Integer.parseInt(offset), Integer.parseInt(limit));
// }
// }
//
// Path: cacheio-repository/src/androidTest/java/com/mobilejazz/cacheio/model/TestUser.java
// public class TestUser implements HasId<String> {
//
// private String id;
// private String name;
//
// public TestUser(String id, String name) {
// this.id = id;
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
//
// @Override public String getId() {
// return this.id;
// }
// }
//
// Path: cacheio-repository/src/main/java/com/mobilejazz/cacheio/query/DefaultQuery.java
// public class DefaultQuery implements Query {
//
// private final String id;
//
// public DefaultQuery(String id) {
// this.id = id;
// }
//
// @Override public String getId() {
// return this.id;
// }
//
// @Override public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// DefaultQuery query = (DefaultQuery) o;
//
// return !(id != null ? !id.equals(query.id) : query.id != null);
//
// }
//
// @Override public int hashCode() {
// return id != null ? id.hashCode() : 0;
// }
// }
//
// Path: cacheio-repository/src/main/java/com/mobilejazz/cacheio/query/PaginatedQuery.java
// public class PaginatedQuery implements Query {
//
// private final String id;
// private final int offset;
// private final int limit;
//
// public PaginatedQuery(String id, int offset, int limit) {
// this.id = id;
// this.offset = offset;
// this.limit = limit;
// }
//
// public int getOffset() {
// return offset;
// }
//
// public int getLimit() {
// return limit;
// }
//
// @Override public String getId() {
// return id;
// }
//
// @Override public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// PaginatedQuery that = (PaginatedQuery) o;
//
// if (offset != that.offset) return false;
// if (limit != that.limit) return false;
// return id.equals(that.id);
//
// }
//
// @Override public int hashCode() {
// int result = id.hashCode();
// result = 31 * result + offset;
// result = 31 * result + limit;
// return result;
// }
// }
// Path: cacheio-repository/src/androidTest/java/com/mobilejazz/cacheio/RxRepositoryTests.java
import java.util.concurrent.*;
import static org.assertj.core.api.Assertions.assertThat;
import android.support.annotation.NonNull;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import com.mobilejazz.cacheio.mappers.DefaultQueryMapper;
import com.mobilejazz.cacheio.mappers.PaginatedQueryMapper;
import com.mobilejazz.cacheio.model.TestUser;
import com.mobilejazz.cacheio.query.DefaultQuery;
import com.mobilejazz.cacheio.query.PaginatedQuery;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import rx.Single;
import java.util.*;
/*
* Copyright (C) 2016 Mobile Jazz
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.mobilejazz.cacheio;
@RunWith(AndroidJUnit4.class) public class RxRepositoryTests {
private CacheIO cacheIO;
public static final String FAKE_TEST_USER_ID = "fake.user.id";
public static final String FAKE_TEST_USER_NAME = "fake.test.user.name";
@Before public void setUp() throws Exception {
this.cacheIO = CacheIO.with(InstrumentationRegistry.getContext())
.identifier("test.database")
.executor(Executors.newSingleThreadExecutor())
.setKeyMapper(PaginatedQuery.class, new PaginatedQueryMapper()) | .setKeyMapper(DefaultQuery.class, new DefaultQueryMapper()) |
mobilejazz/CacheIO | cacheio-repository/src/androidTest/java/com/mobilejazz/cacheio/RxRepositoryTests.java | // Path: cacheio-repository/src/main/java/com/mobilejazz/cacheio/mappers/DefaultQueryMapper.java
// public class DefaultQueryMapper implements KeyMapper<DefaultQuery> {
//
// @Override public String toString(DefaultQuery model) {
// checkArgument(model, "DefaultQuery == null");
// return model.getId();
// }
//
// @Override public DefaultQuery fromString(String str) {
// checkArgument(str, "DefaultQuery string value == null");
// return new DefaultQuery(str);
// }
// }
//
// Path: cacheio-repository/src/main/java/com/mobilejazz/cacheio/mappers/PaginatedQueryMapper.java
// public class PaginatedQueryMapper implements KeyMapper<PaginatedQuery> {
//
// private final static String DELIMITER = "_";
//
// @Override public String toString(PaginatedQuery model) {
// checkArgument(model, "PaginatedQuery == null");
// return String.valueOf(model.getId() + DELIMITER + model.getOffset())
// + DELIMITER
// + model.getLimit();
// }
//
// @Override public PaginatedQuery fromString(String str) {
// checkArgument(str, "PaginatedQuery string value == null");
// String[] tokens = str.split(DELIMITER);
// String id = tokens[0];
// String offset = tokens[1];
// String limit = tokens[2];
// return new PaginatedQuery(id, Integer.parseInt(offset), Integer.parseInt(limit));
// }
// }
//
// Path: cacheio-repository/src/androidTest/java/com/mobilejazz/cacheio/model/TestUser.java
// public class TestUser implements HasId<String> {
//
// private String id;
// private String name;
//
// public TestUser(String id, String name) {
// this.id = id;
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
//
// @Override public String getId() {
// return this.id;
// }
// }
//
// Path: cacheio-repository/src/main/java/com/mobilejazz/cacheio/query/DefaultQuery.java
// public class DefaultQuery implements Query {
//
// private final String id;
//
// public DefaultQuery(String id) {
// this.id = id;
// }
//
// @Override public String getId() {
// return this.id;
// }
//
// @Override public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// DefaultQuery query = (DefaultQuery) o;
//
// return !(id != null ? !id.equals(query.id) : query.id != null);
//
// }
//
// @Override public int hashCode() {
// return id != null ? id.hashCode() : 0;
// }
// }
//
// Path: cacheio-repository/src/main/java/com/mobilejazz/cacheio/query/PaginatedQuery.java
// public class PaginatedQuery implements Query {
//
// private final String id;
// private final int offset;
// private final int limit;
//
// public PaginatedQuery(String id, int offset, int limit) {
// this.id = id;
// this.offset = offset;
// this.limit = limit;
// }
//
// public int getOffset() {
// return offset;
// }
//
// public int getLimit() {
// return limit;
// }
//
// @Override public String getId() {
// return id;
// }
//
// @Override public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// PaginatedQuery that = (PaginatedQuery) o;
//
// if (offset != that.offset) return false;
// if (limit != that.limit) return false;
// return id.equals(that.id);
//
// }
//
// @Override public int hashCode() {
// int result = id.hashCode();
// result = 31 * result + offset;
// result = 31 * result + limit;
// return result;
// }
// }
| import java.util.concurrent.*;
import static org.assertj.core.api.Assertions.assertThat;
import android.support.annotation.NonNull;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import com.mobilejazz.cacheio.mappers.DefaultQueryMapper;
import com.mobilejazz.cacheio.mappers.PaginatedQueryMapper;
import com.mobilejazz.cacheio.model.TestUser;
import com.mobilejazz.cacheio.query.DefaultQuery;
import com.mobilejazz.cacheio.query.PaginatedQuery;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import rx.Single;
import java.util.*; | /*
* Copyright (C) 2016 Mobile Jazz
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.mobilejazz.cacheio;
@RunWith(AndroidJUnit4.class) public class RxRepositoryTests {
private CacheIO cacheIO;
public static final String FAKE_TEST_USER_ID = "fake.user.id";
public static final String FAKE_TEST_USER_NAME = "fake.test.user.name";
@Before public void setUp() throws Exception {
this.cacheIO = CacheIO.with(InstrumentationRegistry.getContext())
.identifier("test.database")
.executor(Executors.newSingleThreadExecutor())
.setKeyMapper(PaginatedQuery.class, new PaginatedQueryMapper())
.setKeyMapper(DefaultQuery.class, new DefaultQueryMapper())
.build();
}
@Test(expected = IllegalArgumentException.class)
public void shouldThrowAExceptionWhenCacheAndQueryCacheIsNull() throws Exception { | // Path: cacheio-repository/src/main/java/com/mobilejazz/cacheio/mappers/DefaultQueryMapper.java
// public class DefaultQueryMapper implements KeyMapper<DefaultQuery> {
//
// @Override public String toString(DefaultQuery model) {
// checkArgument(model, "DefaultQuery == null");
// return model.getId();
// }
//
// @Override public DefaultQuery fromString(String str) {
// checkArgument(str, "DefaultQuery string value == null");
// return new DefaultQuery(str);
// }
// }
//
// Path: cacheio-repository/src/main/java/com/mobilejazz/cacheio/mappers/PaginatedQueryMapper.java
// public class PaginatedQueryMapper implements KeyMapper<PaginatedQuery> {
//
// private final static String DELIMITER = "_";
//
// @Override public String toString(PaginatedQuery model) {
// checkArgument(model, "PaginatedQuery == null");
// return String.valueOf(model.getId() + DELIMITER + model.getOffset())
// + DELIMITER
// + model.getLimit();
// }
//
// @Override public PaginatedQuery fromString(String str) {
// checkArgument(str, "PaginatedQuery string value == null");
// String[] tokens = str.split(DELIMITER);
// String id = tokens[0];
// String offset = tokens[1];
// String limit = tokens[2];
// return new PaginatedQuery(id, Integer.parseInt(offset), Integer.parseInt(limit));
// }
// }
//
// Path: cacheio-repository/src/androidTest/java/com/mobilejazz/cacheio/model/TestUser.java
// public class TestUser implements HasId<String> {
//
// private String id;
// private String name;
//
// public TestUser(String id, String name) {
// this.id = id;
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
//
// @Override public String getId() {
// return this.id;
// }
// }
//
// Path: cacheio-repository/src/main/java/com/mobilejazz/cacheio/query/DefaultQuery.java
// public class DefaultQuery implements Query {
//
// private final String id;
//
// public DefaultQuery(String id) {
// this.id = id;
// }
//
// @Override public String getId() {
// return this.id;
// }
//
// @Override public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// DefaultQuery query = (DefaultQuery) o;
//
// return !(id != null ? !id.equals(query.id) : query.id != null);
//
// }
//
// @Override public int hashCode() {
// return id != null ? id.hashCode() : 0;
// }
// }
//
// Path: cacheio-repository/src/main/java/com/mobilejazz/cacheio/query/PaginatedQuery.java
// public class PaginatedQuery implements Query {
//
// private final String id;
// private final int offset;
// private final int limit;
//
// public PaginatedQuery(String id, int offset, int limit) {
// this.id = id;
// this.offset = offset;
// this.limit = limit;
// }
//
// public int getOffset() {
// return offset;
// }
//
// public int getLimit() {
// return limit;
// }
//
// @Override public String getId() {
// return id;
// }
//
// @Override public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// PaginatedQuery that = (PaginatedQuery) o;
//
// if (offset != that.offset) return false;
// if (limit != that.limit) return false;
// return id.equals(that.id);
//
// }
//
// @Override public int hashCode() {
// int result = id.hashCode();
// result = 31 * result + offset;
// result = 31 * result + limit;
// return result;
// }
// }
// Path: cacheio-repository/src/androidTest/java/com/mobilejazz/cacheio/RxRepositoryTests.java
import java.util.concurrent.*;
import static org.assertj.core.api.Assertions.assertThat;
import android.support.annotation.NonNull;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import com.mobilejazz.cacheio.mappers.DefaultQueryMapper;
import com.mobilejazz.cacheio.mappers.PaginatedQueryMapper;
import com.mobilejazz.cacheio.model.TestUser;
import com.mobilejazz.cacheio.query.DefaultQuery;
import com.mobilejazz.cacheio.query.PaginatedQuery;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import rx.Single;
import java.util.*;
/*
* Copyright (C) 2016 Mobile Jazz
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.mobilejazz.cacheio;
@RunWith(AndroidJUnit4.class) public class RxRepositoryTests {
private CacheIO cacheIO;
public static final String FAKE_TEST_USER_ID = "fake.user.id";
public static final String FAKE_TEST_USER_NAME = "fake.test.user.name";
@Before public void setUp() throws Exception {
this.cacheIO = CacheIO.with(InstrumentationRegistry.getContext())
.identifier("test.database")
.executor(Executors.newSingleThreadExecutor())
.setKeyMapper(PaginatedQuery.class, new PaginatedQueryMapper())
.setKeyMapper(DefaultQuery.class, new DefaultQueryMapper())
.build();
}
@Test(expected = IllegalArgumentException.class)
public void shouldThrowAExceptionWhenCacheAndQueryCacheIsNull() throws Exception { | new StringKeyedRxRepository.Builder<TestUser, DefaultQuery>().setCache(null) |
mobilejazz/CacheIO | cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/key/DoubleKeyMapper.java | // Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/KeyMapper.java
// public interface KeyMapper<T> {
//
// String toString(T model);
//
// T fromString(String str);
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/helper/Preconditions.java
// public static <T> T checkArgument(T object, String message) {
// if (object == null) {
// throw new IllegalArgumentException(message);
// }
//
// return object;
// }
| import com.mobilejazz.cacheio.mappers.KeyMapper;
import static com.mobilejazz.cacheio.helper.Preconditions.checkArgument; | /*
* Copyright (C) 2016 Mobile Jazz
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.mobilejazz.cacheio.mappers.key;
public class DoubleKeyMapper implements KeyMapper<Double> {
@Override public String toString(Double model) { | // Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/KeyMapper.java
// public interface KeyMapper<T> {
//
// String toString(T model);
//
// T fromString(String str);
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/helper/Preconditions.java
// public static <T> T checkArgument(T object, String message) {
// if (object == null) {
// throw new IllegalArgumentException(message);
// }
//
// return object;
// }
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/key/DoubleKeyMapper.java
import com.mobilejazz.cacheio.mappers.KeyMapper;
import static com.mobilejazz.cacheio.helper.Preconditions.checkArgument;
/*
* Copyright (C) 2016 Mobile Jazz
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.mobilejazz.cacheio.mappers.key;
public class DoubleKeyMapper implements KeyMapper<Double> {
@Override public String toString(Double model) { | checkArgument(model, "key cannot be null"); |
mobilejazz/CacheIO | cacheio-core/src/androidTest/java/com/mobilejazz/cacheio/CacheIOTests.java | // Path: cacheio-core/src/androidTest/java/com/mobilejazz/cacheio/model/DummyUser.java
// public class DummyUser {
//
// private int id;
// private String name;
//
// private DummyUser(int id, String name) {
// this.id = id;
// this.name = name;
// }
//
// public int getId() {
// return id;
// }
//
// public String getName() {
// return name;
// }
//
// public static DummyUser create(int id, String name) {
// return new DummyUser(id, name);
// }
// }
| import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import com.mobilejazz.cacheio.model.DummyUser;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import java.util.*;
import java.util.concurrent.*;
import static org.assertj.core.api.Assertions.assertThat; | /*
* Copyright (C) 2016 Mobile Jazz
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.mobilejazz.cacheio;
@RunWith(AndroidJUnit4.class) public class CacheIOTests {
public static final int FAKE_USER_ID = 1234;
public static final String FAKE_USER_NAME = "Jose Luis";
public static final String FAKE_DUMMY_USER_KEY = "test.dummy";
private CacheIO cacheIO;
@Before public void setUp() throws Exception {
//cacheIO = new CacheIO.Builder(InstrumentationRegistry.getContext())
// .identifier("")
cacheIO = CacheIO.with(InstrumentationRegistry.getContext())
.identifier("cacheio_test")
.executor(Executors.newSingleThreadExecutor())
.build();
}
@Test public void shouldGetAObject() throws Exception { | // Path: cacheio-core/src/androidTest/java/com/mobilejazz/cacheio/model/DummyUser.java
// public class DummyUser {
//
// private int id;
// private String name;
//
// private DummyUser(int id, String name) {
// this.id = id;
// this.name = name;
// }
//
// public int getId() {
// return id;
// }
//
// public String getName() {
// return name;
// }
//
// public static DummyUser create(int id, String name) {
// return new DummyUser(id, name);
// }
// }
// Path: cacheio-core/src/androidTest/java/com/mobilejazz/cacheio/CacheIOTests.java
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import com.mobilejazz.cacheio.model.DummyUser;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import java.util.*;
import java.util.concurrent.*;
import static org.assertj.core.api.Assertions.assertThat;
/*
* Copyright (C) 2016 Mobile Jazz
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.mobilejazz.cacheio;
@RunWith(AndroidJUnit4.class) public class CacheIOTests {
public static final int FAKE_USER_ID = 1234;
public static final String FAKE_USER_NAME = "Jose Luis";
public static final String FAKE_DUMMY_USER_KEY = "test.dummy";
private CacheIO cacheIO;
@Before public void setUp() throws Exception {
//cacheIO = new CacheIO.Builder(InstrumentationRegistry.getContext())
// .identifier("")
cacheIO = CacheIO.with(InstrumentationRegistry.getContext())
.identifier("cacheio_test")
.executor(Executors.newSingleThreadExecutor())
.build();
}
@Test public void shouldGetAObject() throws Exception { | SyncCache<String, DummyUser> syncCache = givenADummyUserSyncCache(); |
mobilejazz/CacheIO | cacheio-core/src/main/java/com/mobilejazz/cacheio/wrappers/SyncCacheWrapper.java | // Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/FutureCache.java
// public interface FutureCache<K, V> {
//
// Future<V> get(K key);
//
// Future<V> put(K key, V value, long expiry, TimeUnit unit);
//
// Future<K> remove(K key);
//
// Future<Map<K, V>> getAll(Collection<K> keys);
//
// Future<Map<K, V>> putAll(Map<K, V> map, long expiry, TimeUnit unit);
//
// Future<Collection<K>> removeAll(Collection<K> keys);
//
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/SyncCache.java
// public interface SyncCache<K, V> {
//
// V get(K key);
//
// V put(K key, V value, long expiry, TimeUnit unit);
//
// K remove(K key);
//
// Map<K, V> getAll(Collection<K> keys);
//
// Map<K, V> putAll(Map<K, V> map, long expiry, TimeUnit unit);
//
// Collection<K> removeAll(Collection<K> keys);
//
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/helper/Preconditions.java
// public static <T> T checkArgument(T object, String message) {
// if (object == null) {
// throw new IllegalArgumentException(message);
// }
//
// return object;
// }
| import com.mobilejazz.cacheio.FutureCache;
import com.mobilejazz.cacheio.SyncCache;
import java.util.*;
import java.util.concurrent.*;
import static com.mobilejazz.cacheio.helper.Preconditions.checkArgument; | @Override public V get(K key) {
return blocking(config.delegate.get(key));
}
@Override public V put(K key, V value, long expiry, TimeUnit unit) {
return blocking(config.delegate.put(key, value, expiry, unit));
}
@Override public K remove(K key) {
return blocking(config.delegate.remove(key));
}
@Override public Map<K, V> getAll(Collection<K> keys) {
return blocking(config.delegate.getAll(keys));
}
@Override public Map<K, V> putAll(Map<K, V> map, long expiry, TimeUnit unit) {
return blocking(config.delegate.putAll(map, expiry, unit));
}
@Override public Collection<K> removeAll(Collection<K> keys) {
return blocking(config.delegate.removeAll(keys));
}
public static <K, V> Builder<K, V> newBuilder(Class<K> keyType, Class<V> valueType) {
return new Builder<K, V>().setKeyType(keyType).setValueType(valueType);
}
public static final class Builder<K, V> {
| // Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/FutureCache.java
// public interface FutureCache<K, V> {
//
// Future<V> get(K key);
//
// Future<V> put(K key, V value, long expiry, TimeUnit unit);
//
// Future<K> remove(K key);
//
// Future<Map<K, V>> getAll(Collection<K> keys);
//
// Future<Map<K, V>> putAll(Map<K, V> map, long expiry, TimeUnit unit);
//
// Future<Collection<K>> removeAll(Collection<K> keys);
//
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/SyncCache.java
// public interface SyncCache<K, V> {
//
// V get(K key);
//
// V put(K key, V value, long expiry, TimeUnit unit);
//
// K remove(K key);
//
// Map<K, V> getAll(Collection<K> keys);
//
// Map<K, V> putAll(Map<K, V> map, long expiry, TimeUnit unit);
//
// Collection<K> removeAll(Collection<K> keys);
//
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/helper/Preconditions.java
// public static <T> T checkArgument(T object, String message) {
// if (object == null) {
// throw new IllegalArgumentException(message);
// }
//
// return object;
// }
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/wrappers/SyncCacheWrapper.java
import com.mobilejazz.cacheio.FutureCache;
import com.mobilejazz.cacheio.SyncCache;
import java.util.*;
import java.util.concurrent.*;
import static com.mobilejazz.cacheio.helper.Preconditions.checkArgument;
@Override public V get(K key) {
return blocking(config.delegate.get(key));
}
@Override public V put(K key, V value, long expiry, TimeUnit unit) {
return blocking(config.delegate.put(key, value, expiry, unit));
}
@Override public K remove(K key) {
return blocking(config.delegate.remove(key));
}
@Override public Map<K, V> getAll(Collection<K> keys) {
return blocking(config.delegate.getAll(keys));
}
@Override public Map<K, V> putAll(Map<K, V> map, long expiry, TimeUnit unit) {
return blocking(config.delegate.putAll(map, expiry, unit));
}
@Override public Collection<K> removeAll(Collection<K> keys) {
return blocking(config.delegate.removeAll(keys));
}
public static <K, V> Builder<K, V> newBuilder(Class<K> keyType, Class<V> valueType) {
return new Builder<K, V>().setKeyType(keyType).setValueType(valueType);
}
public static final class Builder<K, V> {
| private FutureCache<K, V> delegate; |
mobilejazz/CacheIO | cacheio-core/src/main/java/com/mobilejazz/cacheio/wrappers/SyncCacheWrapper.java | // Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/FutureCache.java
// public interface FutureCache<K, V> {
//
// Future<V> get(K key);
//
// Future<V> put(K key, V value, long expiry, TimeUnit unit);
//
// Future<K> remove(K key);
//
// Future<Map<K, V>> getAll(Collection<K> keys);
//
// Future<Map<K, V>> putAll(Map<K, V> map, long expiry, TimeUnit unit);
//
// Future<Collection<K>> removeAll(Collection<K> keys);
//
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/SyncCache.java
// public interface SyncCache<K, V> {
//
// V get(K key);
//
// V put(K key, V value, long expiry, TimeUnit unit);
//
// K remove(K key);
//
// Map<K, V> getAll(Collection<K> keys);
//
// Map<K, V> putAll(Map<K, V> map, long expiry, TimeUnit unit);
//
// Collection<K> removeAll(Collection<K> keys);
//
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/helper/Preconditions.java
// public static <T> T checkArgument(T object, String message) {
// if (object == null) {
// throw new IllegalArgumentException(message);
// }
//
// return object;
// }
| import com.mobilejazz.cacheio.FutureCache;
import com.mobilejazz.cacheio.SyncCache;
import java.util.*;
import java.util.concurrent.*;
import static com.mobilejazz.cacheio.helper.Preconditions.checkArgument; |
private Class<K> keyType;
private Class<V> valueType;
private Builder() {
}
private Builder(Builder<K, V> proto) {
this.delegate = proto.delegate;
this.keyType = proto.keyType;
this.valueType = proto.valueType;
}
public Builder<K, V> setDelegate(FutureCache<K, V> delegate) {
this.delegate = delegate;
return this;
}
protected Builder<K, V> setKeyType(Class<K> keyType) {
this.keyType = keyType;
return this;
}
protected Builder<K, V> setValueType(Class<V> valueType) {
this.valueType = valueType;
return this;
}
public SyncCacheWrapper<K, V> build() {
| // Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/FutureCache.java
// public interface FutureCache<K, V> {
//
// Future<V> get(K key);
//
// Future<V> put(K key, V value, long expiry, TimeUnit unit);
//
// Future<K> remove(K key);
//
// Future<Map<K, V>> getAll(Collection<K> keys);
//
// Future<Map<K, V>> putAll(Map<K, V> map, long expiry, TimeUnit unit);
//
// Future<Collection<K>> removeAll(Collection<K> keys);
//
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/SyncCache.java
// public interface SyncCache<K, V> {
//
// V get(K key);
//
// V put(K key, V value, long expiry, TimeUnit unit);
//
// K remove(K key);
//
// Map<K, V> getAll(Collection<K> keys);
//
// Map<K, V> putAll(Map<K, V> map, long expiry, TimeUnit unit);
//
// Collection<K> removeAll(Collection<K> keys);
//
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/helper/Preconditions.java
// public static <T> T checkArgument(T object, String message) {
// if (object == null) {
// throw new IllegalArgumentException(message);
// }
//
// return object;
// }
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/wrappers/SyncCacheWrapper.java
import com.mobilejazz.cacheio.FutureCache;
import com.mobilejazz.cacheio.SyncCache;
import java.util.*;
import java.util.concurrent.*;
import static com.mobilejazz.cacheio.helper.Preconditions.checkArgument;
private Class<K> keyType;
private Class<V> valueType;
private Builder() {
}
private Builder(Builder<K, V> proto) {
this.delegate = proto.delegate;
this.keyType = proto.keyType;
this.valueType = proto.valueType;
}
public Builder<K, V> setDelegate(FutureCache<K, V> delegate) {
this.delegate = delegate;
return this;
}
protected Builder<K, V> setKeyType(Class<K> keyType) {
this.keyType = keyType;
return this;
}
protected Builder<K, V> setValueType(Class<V> valueType) {
this.valueType = valueType;
return this;
}
public SyncCacheWrapper<K, V> build() {
| checkArgument(keyType, "Key type cannot be null"); |
mobilejazz/CacheIO | cacheio-repository/src/main/java/com/mobilejazz/cacheio/mappers/PaginatedQueryMapper.java | // Path: cacheio-repository/src/main/java/com/mobilejazz/cacheio/query/PaginatedQuery.java
// public class PaginatedQuery implements Query {
//
// private final String id;
// private final int offset;
// private final int limit;
//
// public PaginatedQuery(String id, int offset, int limit) {
// this.id = id;
// this.offset = offset;
// this.limit = limit;
// }
//
// public int getOffset() {
// return offset;
// }
//
// public int getLimit() {
// return limit;
// }
//
// @Override public String getId() {
// return id;
// }
//
// @Override public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// PaginatedQuery that = (PaginatedQuery) o;
//
// if (offset != that.offset) return false;
// if (limit != that.limit) return false;
// return id.equals(that.id);
//
// }
//
// @Override public int hashCode() {
// int result = id.hashCode();
// result = 31 * result + offset;
// result = 31 * result + limit;
// return result;
// }
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/helper/Preconditions.java
// public static <T> T checkArgument(T object, String message) {
// if (object == null) {
// throw new IllegalArgumentException(message);
// }
//
// return object;
// }
| import com.mobilejazz.cacheio.query.PaginatedQuery;
import static com.mobilejazz.cacheio.helper.Preconditions.checkArgument; | /*
* Copyright (C) 2016 Mobile Jazz
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.mobilejazz.cacheio.mappers;
public class PaginatedQueryMapper implements KeyMapper<PaginatedQuery> {
private final static String DELIMITER = "_";
@Override public String toString(PaginatedQuery model) { | // Path: cacheio-repository/src/main/java/com/mobilejazz/cacheio/query/PaginatedQuery.java
// public class PaginatedQuery implements Query {
//
// private final String id;
// private final int offset;
// private final int limit;
//
// public PaginatedQuery(String id, int offset, int limit) {
// this.id = id;
// this.offset = offset;
// this.limit = limit;
// }
//
// public int getOffset() {
// return offset;
// }
//
// public int getLimit() {
// return limit;
// }
//
// @Override public String getId() {
// return id;
// }
//
// @Override public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// PaginatedQuery that = (PaginatedQuery) o;
//
// if (offset != that.offset) return false;
// if (limit != that.limit) return false;
// return id.equals(that.id);
//
// }
//
// @Override public int hashCode() {
// int result = id.hashCode();
// result = 31 * result + offset;
// result = 31 * result + limit;
// return result;
// }
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/helper/Preconditions.java
// public static <T> T checkArgument(T object, String message) {
// if (object == null) {
// throw new IllegalArgumentException(message);
// }
//
// return object;
// }
// Path: cacheio-repository/src/main/java/com/mobilejazz/cacheio/mappers/PaginatedQueryMapper.java
import com.mobilejazz.cacheio.query.PaginatedQuery;
import static com.mobilejazz.cacheio.helper.Preconditions.checkArgument;
/*
* Copyright (C) 2016 Mobile Jazz
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.mobilejazz.cacheio.mappers;
public class PaginatedQueryMapper implements KeyMapper<PaginatedQuery> {
private final static String DELIMITER = "_";
@Override public String toString(PaginatedQuery model) { | checkArgument(model, "PaginatedQuery == null"); |
mobilejazz/CacheIO | cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/key/ShortKeyMapper.java | // Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/KeyMapper.java
// public interface KeyMapper<T> {
//
// String toString(T model);
//
// T fromString(String str);
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/helper/Preconditions.java
// public static <T> T checkArgument(T object, String message) {
// if (object == null) {
// throw new IllegalArgumentException(message);
// }
//
// return object;
// }
| import com.mobilejazz.cacheio.mappers.KeyMapper;
import static com.mobilejazz.cacheio.helper.Preconditions.checkArgument; | /*
* Copyright (C) 2016 Mobile Jazz
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.mobilejazz.cacheio.mappers.key;
public class ShortKeyMapper implements KeyMapper<Short> {
@Override public String toString(Short model) { | // Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/KeyMapper.java
// public interface KeyMapper<T> {
//
// String toString(T model);
//
// T fromString(String str);
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/helper/Preconditions.java
// public static <T> T checkArgument(T object, String message) {
// if (object == null) {
// throw new IllegalArgumentException(message);
// }
//
// return object;
// }
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/mappers/key/ShortKeyMapper.java
import com.mobilejazz.cacheio.mappers.KeyMapper;
import static com.mobilejazz.cacheio.helper.Preconditions.checkArgument;
/*
* Copyright (C) 2016 Mobile Jazz
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.mobilejazz.cacheio.mappers.key;
public class ShortKeyMapper implements KeyMapper<Short> {
@Override public String toString(Short model) { | checkArgument(model, "key cannot be null"); |
mobilejazz/CacheIO | cacheio-repository/src/main/java/com/mobilejazz/cacheio/mappers/DefaultQueryMapper.java | // Path: cacheio-repository/src/main/java/com/mobilejazz/cacheio/query/DefaultQuery.java
// public class DefaultQuery implements Query {
//
// private final String id;
//
// public DefaultQuery(String id) {
// this.id = id;
// }
//
// @Override public String getId() {
// return this.id;
// }
//
// @Override public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// DefaultQuery query = (DefaultQuery) o;
//
// return !(id != null ? !id.equals(query.id) : query.id != null);
//
// }
//
// @Override public int hashCode() {
// return id != null ? id.hashCode() : 0;
// }
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/helper/Preconditions.java
// public static <T> T checkArgument(T object, String message) {
// if (object == null) {
// throw new IllegalArgumentException(message);
// }
//
// return object;
// }
| import com.mobilejazz.cacheio.query.DefaultQuery;
import static com.mobilejazz.cacheio.helper.Preconditions.checkArgument; | /*
* Copyright (C) 2016 Mobile Jazz
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.mobilejazz.cacheio.mappers;
public class DefaultQueryMapper implements KeyMapper<DefaultQuery> {
@Override public String toString(DefaultQuery model) { | // Path: cacheio-repository/src/main/java/com/mobilejazz/cacheio/query/DefaultQuery.java
// public class DefaultQuery implements Query {
//
// private final String id;
//
// public DefaultQuery(String id) {
// this.id = id;
// }
//
// @Override public String getId() {
// return this.id;
// }
//
// @Override public boolean equals(Object o) {
// if (this == o) return true;
// if (o == null || getClass() != o.getClass()) return false;
//
// DefaultQuery query = (DefaultQuery) o;
//
// return !(id != null ? !id.equals(query.id) : query.id != null);
//
// }
//
// @Override public int hashCode() {
// return id != null ? id.hashCode() : 0;
// }
// }
//
// Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/helper/Preconditions.java
// public static <T> T checkArgument(T object, String message) {
// if (object == null) {
// throw new IllegalArgumentException(message);
// }
//
// return object;
// }
// Path: cacheio-repository/src/main/java/com/mobilejazz/cacheio/mappers/DefaultQueryMapper.java
import com.mobilejazz.cacheio.query.DefaultQuery;
import static com.mobilejazz.cacheio.helper.Preconditions.checkArgument;
/*
* Copyright (C) 2016 Mobile Jazz
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.mobilejazz.cacheio.mappers;
public class DefaultQueryMapper implements KeyMapper<DefaultQuery> {
@Override public String toString(DefaultQuery model) { | checkArgument(model, "DefaultQuery == null"); |
mobilejazz/CacheIO | cacheio-core/src/test/java/com/mobilejazz/cacheio/wrappers/SyncCacheWrapperTest.java | // Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/FutureCache.java
// public interface FutureCache<K, V> {
//
// Future<V> get(K key);
//
// Future<V> put(K key, V value, long expiry, TimeUnit unit);
//
// Future<K> remove(K key);
//
// Future<Map<K, V>> getAll(Collection<K> keys);
//
// Future<Map<K, V>> putAll(Map<K, V> map, long expiry, TimeUnit unit);
//
// Future<Collection<K>> removeAll(Collection<K> keys);
//
// }
| import com.mobilejazz.cacheio.FutureCache;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import rx.Single;
import rx.SingleSubscriber;
import java.util.*;
import java.util.concurrent.*;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when; | package com.mobilejazz.cacheio.wrappers;
@SuppressWarnings("unchecked")
@RunWith(MockitoJUnitRunner.class)
public class SyncCacheWrapperTest {
@Mock | // Path: cacheio-core/src/main/java/com/mobilejazz/cacheio/FutureCache.java
// public interface FutureCache<K, V> {
//
// Future<V> get(K key);
//
// Future<V> put(K key, V value, long expiry, TimeUnit unit);
//
// Future<K> remove(K key);
//
// Future<Map<K, V>> getAll(Collection<K> keys);
//
// Future<Map<K, V>> putAll(Map<K, V> map, long expiry, TimeUnit unit);
//
// Future<Collection<K>> removeAll(Collection<K> keys);
//
// }
// Path: cacheio-core/src/test/java/com/mobilejazz/cacheio/wrappers/SyncCacheWrapperTest.java
import com.mobilejazz.cacheio.FutureCache;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import rx.Single;
import rx.SingleSubscriber;
import java.util.*;
import java.util.concurrent.*;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
package com.mobilejazz.cacheio.wrappers;
@SuppressWarnings("unchecked")
@RunWith(MockitoJUnitRunner.class)
public class SyncCacheWrapperTest {
@Mock | private FutureCache<String, String> delegate; |
vanniktech/espresso-utils | espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/TextViewDrawableMatcher.java | // Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static final int INDEX_BOTTOM = 3;
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static final int INDEX_LEFT = 0;
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static final int INDEX_RIGHT = 2;
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static final int INDEX_TOP = 1;
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static final int NO_DRAWABLE = -1;
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static boolean drawableMatches(final View view, final Drawable drawable, @DrawableRes final int expectedId) {
// final boolean isVisible = view.getVisibility() == VISIBLE;
//
// if (expectedId == NO_DRAWABLE) {
// return isVisible && drawable == null;
// }
//
// final Context context = view.getContext();
// return isVisible && checkNotNull(drawable.getConstantState(), "constantState == null").equals(ContextCompat.getDrawable(context, expectedId).getConstantState());
// }
| import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.graphics.drawable.Drawable;
import androidx.annotation.CheckResult;
import androidx.annotation.DrawableRes;
import androidx.test.espresso.matcher.BoundedMatcher;
import android.view.View;
import android.widget.TextView;
import org.hamcrest.Description;
import static android.os.Build.VERSION_CODES.JELLY_BEAN_MR1;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_BOTTOM;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_LEFT;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_RELATIVE_BOTTOM;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_RELATIVE_LEFT;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_RELATIVE_RIGHT;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_RELATIVE_TOP;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_RIGHT;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_TOP;
import static com.vanniktech.espresso.core.utils.Utils.INDEX_BOTTOM;
import static com.vanniktech.espresso.core.utils.Utils.INDEX_LEFT;
import static com.vanniktech.espresso.core.utils.Utils.INDEX_RIGHT;
import static com.vanniktech.espresso.core.utils.Utils.INDEX_TOP;
import static com.vanniktech.espresso.core.utils.Utils.NO_DRAWABLE;
import static com.vanniktech.espresso.core.utils.Utils.drawableMatches; | package com.vanniktech.espresso.core.utils;
public final class TextViewDrawableMatcher extends BoundedMatcher<View, TextView> {
/**
* Matches that the given drawable is displayed as the left drawable.
*
* <p>Example usage:</p>
* <code>onView(withId(R.id.view)).check(matches(withTextViewDrawableLeft(R.color.blue)));</code>
*/
@CheckResult public static TextViewDrawableMatcher withTextViewDrawableLeft(@DrawableRes final int resourceId) {
return new TextViewDrawableMatcher(resourceId, DRAWABLE_LEFT);
}
/**
* Matches that there is no left drawable.
*
* <p>Example usage:</p>
* <code>onView(withId(R.id.view)).check(matches(withNoTextViewDrawableLeft()));</code>
*/
@CheckResult public static TextViewDrawableMatcher withNoTextViewDrawableLeft() { | // Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static final int INDEX_BOTTOM = 3;
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static final int INDEX_LEFT = 0;
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static final int INDEX_RIGHT = 2;
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static final int INDEX_TOP = 1;
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static final int NO_DRAWABLE = -1;
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static boolean drawableMatches(final View view, final Drawable drawable, @DrawableRes final int expectedId) {
// final boolean isVisible = view.getVisibility() == VISIBLE;
//
// if (expectedId == NO_DRAWABLE) {
// return isVisible && drawable == null;
// }
//
// final Context context = view.getContext();
// return isVisible && checkNotNull(drawable.getConstantState(), "constantState == null").equals(ContextCompat.getDrawable(context, expectedId).getConstantState());
// }
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/TextViewDrawableMatcher.java
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.graphics.drawable.Drawable;
import androidx.annotation.CheckResult;
import androidx.annotation.DrawableRes;
import androidx.test.espresso.matcher.BoundedMatcher;
import android.view.View;
import android.widget.TextView;
import org.hamcrest.Description;
import static android.os.Build.VERSION_CODES.JELLY_BEAN_MR1;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_BOTTOM;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_LEFT;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_RELATIVE_BOTTOM;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_RELATIVE_LEFT;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_RELATIVE_RIGHT;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_RELATIVE_TOP;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_RIGHT;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_TOP;
import static com.vanniktech.espresso.core.utils.Utils.INDEX_BOTTOM;
import static com.vanniktech.espresso.core.utils.Utils.INDEX_LEFT;
import static com.vanniktech.espresso.core.utils.Utils.INDEX_RIGHT;
import static com.vanniktech.espresso.core.utils.Utils.INDEX_TOP;
import static com.vanniktech.espresso.core.utils.Utils.NO_DRAWABLE;
import static com.vanniktech.espresso.core.utils.Utils.drawableMatches;
package com.vanniktech.espresso.core.utils;
public final class TextViewDrawableMatcher extends BoundedMatcher<View, TextView> {
/**
* Matches that the given drawable is displayed as the left drawable.
*
* <p>Example usage:</p>
* <code>onView(withId(R.id.view)).check(matches(withTextViewDrawableLeft(R.color.blue)));</code>
*/
@CheckResult public static TextViewDrawableMatcher withTextViewDrawableLeft(@DrawableRes final int resourceId) {
return new TextViewDrawableMatcher(resourceId, DRAWABLE_LEFT);
}
/**
* Matches that there is no left drawable.
*
* <p>Example usage:</p>
* <code>onView(withId(R.id.view)).check(matches(withNoTextViewDrawableLeft()));</code>
*/
@CheckResult public static TextViewDrawableMatcher withNoTextViewDrawableLeft() { | return new TextViewDrawableMatcher(NO_DRAWABLE, DRAWABLE_LEFT); |
vanniktech/espresso-utils | espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/TextViewDrawableMatcher.java | // Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static final int INDEX_BOTTOM = 3;
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static final int INDEX_LEFT = 0;
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static final int INDEX_RIGHT = 2;
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static final int INDEX_TOP = 1;
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static final int NO_DRAWABLE = -1;
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static boolean drawableMatches(final View view, final Drawable drawable, @DrawableRes final int expectedId) {
// final boolean isVisible = view.getVisibility() == VISIBLE;
//
// if (expectedId == NO_DRAWABLE) {
// return isVisible && drawable == null;
// }
//
// final Context context = view.getContext();
// return isVisible && checkNotNull(drawable.getConstantState(), "constantState == null").equals(ContextCompat.getDrawable(context, expectedId).getConstantState());
// }
| import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.graphics.drawable.Drawable;
import androidx.annotation.CheckResult;
import androidx.annotation.DrawableRes;
import androidx.test.espresso.matcher.BoundedMatcher;
import android.view.View;
import android.widget.TextView;
import org.hamcrest.Description;
import static android.os.Build.VERSION_CODES.JELLY_BEAN_MR1;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_BOTTOM;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_LEFT;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_RELATIVE_BOTTOM;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_RELATIVE_LEFT;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_RELATIVE_RIGHT;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_RELATIVE_TOP;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_RIGHT;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_TOP;
import static com.vanniktech.espresso.core.utils.Utils.INDEX_BOTTOM;
import static com.vanniktech.espresso.core.utils.Utils.INDEX_LEFT;
import static com.vanniktech.espresso.core.utils.Utils.INDEX_RIGHT;
import static com.vanniktech.espresso.core.utils.Utils.INDEX_TOP;
import static com.vanniktech.espresso.core.utils.Utils.NO_DRAWABLE;
import static com.vanniktech.espresso.core.utils.Utils.drawableMatches; | * Matches that the given drawable is displayed as the relative bottom drawable.
*
* <p>Example usage:</p>
* <code>onView(withId(R.id.view)).check(matches(withTextViewDrawableRelativeBottom(R.color.blue)));</code>
*/
@CheckResult @TargetApi(JELLY_BEAN_MR1) public static TextViewDrawableMatcher withTextViewDrawableRelativeBottom(@DrawableRes final int resourceId) {
return new TextViewDrawableMatcher(resourceId, DRAWABLE_RELATIVE_BOTTOM);
}
/**
* Matches that there is no relative bottom drawable.
*
* <p>Example usage:</p>
* <code>onView(withId(R.id.view)).check(matches(withNoTextViewDrawableRelativeBottom()));</code>
*/
@CheckResult @TargetApi(JELLY_BEAN_MR1) public static TextViewDrawableMatcher withNoTextViewDrawableRelativeBottom() {
return new TextViewDrawableMatcher(NO_DRAWABLE, DRAWABLE_RELATIVE_BOTTOM);
}
private final int expectedId;
private final Type type;
private TextViewDrawableMatcher(final int expectedId, final Type type) {
super(TextView.class);
this.expectedId = expectedId;
this.type = type;
}
@Override protected boolean matchesSafely(final TextView textView) { | // Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static final int INDEX_BOTTOM = 3;
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static final int INDEX_LEFT = 0;
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static final int INDEX_RIGHT = 2;
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static final int INDEX_TOP = 1;
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static final int NO_DRAWABLE = -1;
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static boolean drawableMatches(final View view, final Drawable drawable, @DrawableRes final int expectedId) {
// final boolean isVisible = view.getVisibility() == VISIBLE;
//
// if (expectedId == NO_DRAWABLE) {
// return isVisible && drawable == null;
// }
//
// final Context context = view.getContext();
// return isVisible && checkNotNull(drawable.getConstantState(), "constantState == null").equals(ContextCompat.getDrawable(context, expectedId).getConstantState());
// }
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/TextViewDrawableMatcher.java
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.graphics.drawable.Drawable;
import androidx.annotation.CheckResult;
import androidx.annotation.DrawableRes;
import androidx.test.espresso.matcher.BoundedMatcher;
import android.view.View;
import android.widget.TextView;
import org.hamcrest.Description;
import static android.os.Build.VERSION_CODES.JELLY_BEAN_MR1;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_BOTTOM;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_LEFT;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_RELATIVE_BOTTOM;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_RELATIVE_LEFT;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_RELATIVE_RIGHT;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_RELATIVE_TOP;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_RIGHT;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_TOP;
import static com.vanniktech.espresso.core.utils.Utils.INDEX_BOTTOM;
import static com.vanniktech.espresso.core.utils.Utils.INDEX_LEFT;
import static com.vanniktech.espresso.core.utils.Utils.INDEX_RIGHT;
import static com.vanniktech.espresso.core.utils.Utils.INDEX_TOP;
import static com.vanniktech.espresso.core.utils.Utils.NO_DRAWABLE;
import static com.vanniktech.espresso.core.utils.Utils.drawableMatches;
* Matches that the given drawable is displayed as the relative bottom drawable.
*
* <p>Example usage:</p>
* <code>onView(withId(R.id.view)).check(matches(withTextViewDrawableRelativeBottom(R.color.blue)));</code>
*/
@CheckResult @TargetApi(JELLY_BEAN_MR1) public static TextViewDrawableMatcher withTextViewDrawableRelativeBottom(@DrawableRes final int resourceId) {
return new TextViewDrawableMatcher(resourceId, DRAWABLE_RELATIVE_BOTTOM);
}
/**
* Matches that there is no relative bottom drawable.
*
* <p>Example usage:</p>
* <code>onView(withId(R.id.view)).check(matches(withNoTextViewDrawableRelativeBottom()));</code>
*/
@CheckResult @TargetApi(JELLY_BEAN_MR1) public static TextViewDrawableMatcher withNoTextViewDrawableRelativeBottom() {
return new TextViewDrawableMatcher(NO_DRAWABLE, DRAWABLE_RELATIVE_BOTTOM);
}
private final int expectedId;
private final Type type;
private TextViewDrawableMatcher(final int expectedId, final Type type) {
super(TextView.class);
this.expectedId = expectedId;
this.type = type;
}
@Override protected boolean matchesSafely(final TextView textView) { | return drawableMatches(textView, type.getDrawable(textView), expectedId); |
vanniktech/espresso-utils | espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/TextViewDrawableMatcher.java | // Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static final int INDEX_BOTTOM = 3;
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static final int INDEX_LEFT = 0;
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static final int INDEX_RIGHT = 2;
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static final int INDEX_TOP = 1;
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static final int NO_DRAWABLE = -1;
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static boolean drawableMatches(final View view, final Drawable drawable, @DrawableRes final int expectedId) {
// final boolean isVisible = view.getVisibility() == VISIBLE;
//
// if (expectedId == NO_DRAWABLE) {
// return isVisible && drawable == null;
// }
//
// final Context context = view.getContext();
// return isVisible && checkNotNull(drawable.getConstantState(), "constantState == null").equals(ContextCompat.getDrawable(context, expectedId).getConstantState());
// }
| import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.graphics.drawable.Drawable;
import androidx.annotation.CheckResult;
import androidx.annotation.DrawableRes;
import androidx.test.espresso.matcher.BoundedMatcher;
import android.view.View;
import android.widget.TextView;
import org.hamcrest.Description;
import static android.os.Build.VERSION_CODES.JELLY_BEAN_MR1;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_BOTTOM;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_LEFT;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_RELATIVE_BOTTOM;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_RELATIVE_LEFT;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_RELATIVE_RIGHT;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_RELATIVE_TOP;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_RIGHT;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_TOP;
import static com.vanniktech.espresso.core.utils.Utils.INDEX_BOTTOM;
import static com.vanniktech.espresso.core.utils.Utils.INDEX_LEFT;
import static com.vanniktech.espresso.core.utils.Utils.INDEX_RIGHT;
import static com.vanniktech.espresso.core.utils.Utils.INDEX_TOP;
import static com.vanniktech.espresso.core.utils.Utils.NO_DRAWABLE;
import static com.vanniktech.espresso.core.utils.Utils.drawableMatches; | }
private final int expectedId;
private final Type type;
private TextViewDrawableMatcher(final int expectedId, final Type type) {
super(TextView.class);
this.expectedId = expectedId;
this.type = type;
}
@Override protected boolean matchesSafely(final TextView textView) {
return drawableMatches(textView, type.getDrawable(textView), expectedId);
}
@Override public void describeTo(final Description description) {
if (expectedId == NO_DRAWABLE) {
description.appendText("with no ")
.appendText(type.string)
.appendText(" drawable");
} else {
description.appendText("with ")
.appendText(type.string)
.appendText(" drawable from resource id: ")
.appendValue(expectedId);
}
}
enum Type { | // Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static final int INDEX_BOTTOM = 3;
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static final int INDEX_LEFT = 0;
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static final int INDEX_RIGHT = 2;
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static final int INDEX_TOP = 1;
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static final int NO_DRAWABLE = -1;
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static boolean drawableMatches(final View view, final Drawable drawable, @DrawableRes final int expectedId) {
// final boolean isVisible = view.getVisibility() == VISIBLE;
//
// if (expectedId == NO_DRAWABLE) {
// return isVisible && drawable == null;
// }
//
// final Context context = view.getContext();
// return isVisible && checkNotNull(drawable.getConstantState(), "constantState == null").equals(ContextCompat.getDrawable(context, expectedId).getConstantState());
// }
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/TextViewDrawableMatcher.java
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.graphics.drawable.Drawable;
import androidx.annotation.CheckResult;
import androidx.annotation.DrawableRes;
import androidx.test.espresso.matcher.BoundedMatcher;
import android.view.View;
import android.widget.TextView;
import org.hamcrest.Description;
import static android.os.Build.VERSION_CODES.JELLY_BEAN_MR1;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_BOTTOM;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_LEFT;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_RELATIVE_BOTTOM;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_RELATIVE_LEFT;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_RELATIVE_RIGHT;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_RELATIVE_TOP;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_RIGHT;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_TOP;
import static com.vanniktech.espresso.core.utils.Utils.INDEX_BOTTOM;
import static com.vanniktech.espresso.core.utils.Utils.INDEX_LEFT;
import static com.vanniktech.espresso.core.utils.Utils.INDEX_RIGHT;
import static com.vanniktech.espresso.core.utils.Utils.INDEX_TOP;
import static com.vanniktech.espresso.core.utils.Utils.NO_DRAWABLE;
import static com.vanniktech.espresso.core.utils.Utils.drawableMatches;
}
private final int expectedId;
private final Type type;
private TextViewDrawableMatcher(final int expectedId, final Type type) {
super(TextView.class);
this.expectedId = expectedId;
this.type = type;
}
@Override protected boolean matchesSafely(final TextView textView) {
return drawableMatches(textView, type.getDrawable(textView), expectedId);
}
@Override public void describeTo(final Description description) {
if (expectedId == NO_DRAWABLE) {
description.appendText("with no ")
.appendText(type.string)
.appendText(" drawable");
} else {
description.appendText("with ")
.appendText(type.string)
.appendText(" drawable from resource id: ")
.appendValue(expectedId);
}
}
enum Type { | DRAWABLE_LEFT(INDEX_LEFT, false, "left"), |
vanniktech/espresso-utils | espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/TextViewDrawableMatcher.java | // Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static final int INDEX_BOTTOM = 3;
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static final int INDEX_LEFT = 0;
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static final int INDEX_RIGHT = 2;
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static final int INDEX_TOP = 1;
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static final int NO_DRAWABLE = -1;
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static boolean drawableMatches(final View view, final Drawable drawable, @DrawableRes final int expectedId) {
// final boolean isVisible = view.getVisibility() == VISIBLE;
//
// if (expectedId == NO_DRAWABLE) {
// return isVisible && drawable == null;
// }
//
// final Context context = view.getContext();
// return isVisible && checkNotNull(drawable.getConstantState(), "constantState == null").equals(ContextCompat.getDrawable(context, expectedId).getConstantState());
// }
| import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.graphics.drawable.Drawable;
import androidx.annotation.CheckResult;
import androidx.annotation.DrawableRes;
import androidx.test.espresso.matcher.BoundedMatcher;
import android.view.View;
import android.widget.TextView;
import org.hamcrest.Description;
import static android.os.Build.VERSION_CODES.JELLY_BEAN_MR1;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_BOTTOM;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_LEFT;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_RELATIVE_BOTTOM;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_RELATIVE_LEFT;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_RELATIVE_RIGHT;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_RELATIVE_TOP;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_RIGHT;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_TOP;
import static com.vanniktech.espresso.core.utils.Utils.INDEX_BOTTOM;
import static com.vanniktech.espresso.core.utils.Utils.INDEX_LEFT;
import static com.vanniktech.espresso.core.utils.Utils.INDEX_RIGHT;
import static com.vanniktech.espresso.core.utils.Utils.INDEX_TOP;
import static com.vanniktech.espresso.core.utils.Utils.NO_DRAWABLE;
import static com.vanniktech.espresso.core.utils.Utils.drawableMatches; | private final int expectedId;
private final Type type;
private TextViewDrawableMatcher(final int expectedId, final Type type) {
super(TextView.class);
this.expectedId = expectedId;
this.type = type;
}
@Override protected boolean matchesSafely(final TextView textView) {
return drawableMatches(textView, type.getDrawable(textView), expectedId);
}
@Override public void describeTo(final Description description) {
if (expectedId == NO_DRAWABLE) {
description.appendText("with no ")
.appendText(type.string)
.appendText(" drawable");
} else {
description.appendText("with ")
.appendText(type.string)
.appendText(" drawable from resource id: ")
.appendValue(expectedId);
}
}
enum Type {
DRAWABLE_LEFT(INDEX_LEFT, false, "left"),
DRAWABLE_RELATIVE_LEFT(INDEX_LEFT, true, "relative left"), | // Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static final int INDEX_BOTTOM = 3;
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static final int INDEX_LEFT = 0;
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static final int INDEX_RIGHT = 2;
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static final int INDEX_TOP = 1;
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static final int NO_DRAWABLE = -1;
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static boolean drawableMatches(final View view, final Drawable drawable, @DrawableRes final int expectedId) {
// final boolean isVisible = view.getVisibility() == VISIBLE;
//
// if (expectedId == NO_DRAWABLE) {
// return isVisible && drawable == null;
// }
//
// final Context context = view.getContext();
// return isVisible && checkNotNull(drawable.getConstantState(), "constantState == null").equals(ContextCompat.getDrawable(context, expectedId).getConstantState());
// }
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/TextViewDrawableMatcher.java
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.graphics.drawable.Drawable;
import androidx.annotation.CheckResult;
import androidx.annotation.DrawableRes;
import androidx.test.espresso.matcher.BoundedMatcher;
import android.view.View;
import android.widget.TextView;
import org.hamcrest.Description;
import static android.os.Build.VERSION_CODES.JELLY_BEAN_MR1;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_BOTTOM;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_LEFT;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_RELATIVE_BOTTOM;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_RELATIVE_LEFT;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_RELATIVE_RIGHT;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_RELATIVE_TOP;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_RIGHT;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_TOP;
import static com.vanniktech.espresso.core.utils.Utils.INDEX_BOTTOM;
import static com.vanniktech.espresso.core.utils.Utils.INDEX_LEFT;
import static com.vanniktech.espresso.core.utils.Utils.INDEX_RIGHT;
import static com.vanniktech.espresso.core.utils.Utils.INDEX_TOP;
import static com.vanniktech.espresso.core.utils.Utils.NO_DRAWABLE;
import static com.vanniktech.espresso.core.utils.Utils.drawableMatches;
private final int expectedId;
private final Type type;
private TextViewDrawableMatcher(final int expectedId, final Type type) {
super(TextView.class);
this.expectedId = expectedId;
this.type = type;
}
@Override protected boolean matchesSafely(final TextView textView) {
return drawableMatches(textView, type.getDrawable(textView), expectedId);
}
@Override public void describeTo(final Description description) {
if (expectedId == NO_DRAWABLE) {
description.appendText("with no ")
.appendText(type.string)
.appendText(" drawable");
} else {
description.appendText("with ")
.appendText(type.string)
.appendText(" drawable from resource id: ")
.appendValue(expectedId);
}
}
enum Type {
DRAWABLE_LEFT(INDEX_LEFT, false, "left"),
DRAWABLE_RELATIVE_LEFT(INDEX_LEFT, true, "relative left"), | DRAWABLE_TOP(INDEX_TOP, false, "top"), |
vanniktech/espresso-utils | espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/TextViewDrawableMatcher.java | // Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static final int INDEX_BOTTOM = 3;
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static final int INDEX_LEFT = 0;
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static final int INDEX_RIGHT = 2;
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static final int INDEX_TOP = 1;
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static final int NO_DRAWABLE = -1;
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static boolean drawableMatches(final View view, final Drawable drawable, @DrawableRes final int expectedId) {
// final boolean isVisible = view.getVisibility() == VISIBLE;
//
// if (expectedId == NO_DRAWABLE) {
// return isVisible && drawable == null;
// }
//
// final Context context = view.getContext();
// return isVisible && checkNotNull(drawable.getConstantState(), "constantState == null").equals(ContextCompat.getDrawable(context, expectedId).getConstantState());
// }
| import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.graphics.drawable.Drawable;
import androidx.annotation.CheckResult;
import androidx.annotation.DrawableRes;
import androidx.test.espresso.matcher.BoundedMatcher;
import android.view.View;
import android.widget.TextView;
import org.hamcrest.Description;
import static android.os.Build.VERSION_CODES.JELLY_BEAN_MR1;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_BOTTOM;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_LEFT;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_RELATIVE_BOTTOM;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_RELATIVE_LEFT;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_RELATIVE_RIGHT;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_RELATIVE_TOP;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_RIGHT;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_TOP;
import static com.vanniktech.espresso.core.utils.Utils.INDEX_BOTTOM;
import static com.vanniktech.espresso.core.utils.Utils.INDEX_LEFT;
import static com.vanniktech.espresso.core.utils.Utils.INDEX_RIGHT;
import static com.vanniktech.espresso.core.utils.Utils.INDEX_TOP;
import static com.vanniktech.espresso.core.utils.Utils.NO_DRAWABLE;
import static com.vanniktech.espresso.core.utils.Utils.drawableMatches; |
private TextViewDrawableMatcher(final int expectedId, final Type type) {
super(TextView.class);
this.expectedId = expectedId;
this.type = type;
}
@Override protected boolean matchesSafely(final TextView textView) {
return drawableMatches(textView, type.getDrawable(textView), expectedId);
}
@Override public void describeTo(final Description description) {
if (expectedId == NO_DRAWABLE) {
description.appendText("with no ")
.appendText(type.string)
.appendText(" drawable");
} else {
description.appendText("with ")
.appendText(type.string)
.appendText(" drawable from resource id: ")
.appendValue(expectedId);
}
}
enum Type {
DRAWABLE_LEFT(INDEX_LEFT, false, "left"),
DRAWABLE_RELATIVE_LEFT(INDEX_LEFT, true, "relative left"),
DRAWABLE_TOP(INDEX_TOP, false, "top"),
DRAWABLE_RELATIVE_TOP(INDEX_TOP, true, "relative top"), | // Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static final int INDEX_BOTTOM = 3;
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static final int INDEX_LEFT = 0;
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static final int INDEX_RIGHT = 2;
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static final int INDEX_TOP = 1;
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static final int NO_DRAWABLE = -1;
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static boolean drawableMatches(final View view, final Drawable drawable, @DrawableRes final int expectedId) {
// final boolean isVisible = view.getVisibility() == VISIBLE;
//
// if (expectedId == NO_DRAWABLE) {
// return isVisible && drawable == null;
// }
//
// final Context context = view.getContext();
// return isVisible && checkNotNull(drawable.getConstantState(), "constantState == null").equals(ContextCompat.getDrawable(context, expectedId).getConstantState());
// }
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/TextViewDrawableMatcher.java
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.graphics.drawable.Drawable;
import androidx.annotation.CheckResult;
import androidx.annotation.DrawableRes;
import androidx.test.espresso.matcher.BoundedMatcher;
import android.view.View;
import android.widget.TextView;
import org.hamcrest.Description;
import static android.os.Build.VERSION_CODES.JELLY_BEAN_MR1;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_BOTTOM;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_LEFT;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_RELATIVE_BOTTOM;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_RELATIVE_LEFT;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_RELATIVE_RIGHT;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_RELATIVE_TOP;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_RIGHT;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_TOP;
import static com.vanniktech.espresso.core.utils.Utils.INDEX_BOTTOM;
import static com.vanniktech.espresso.core.utils.Utils.INDEX_LEFT;
import static com.vanniktech.espresso.core.utils.Utils.INDEX_RIGHT;
import static com.vanniktech.espresso.core.utils.Utils.INDEX_TOP;
import static com.vanniktech.espresso.core.utils.Utils.NO_DRAWABLE;
import static com.vanniktech.espresso.core.utils.Utils.drawableMatches;
private TextViewDrawableMatcher(final int expectedId, final Type type) {
super(TextView.class);
this.expectedId = expectedId;
this.type = type;
}
@Override protected boolean matchesSafely(final TextView textView) {
return drawableMatches(textView, type.getDrawable(textView), expectedId);
}
@Override public void describeTo(final Description description) {
if (expectedId == NO_DRAWABLE) {
description.appendText("with no ")
.appendText(type.string)
.appendText(" drawable");
} else {
description.appendText("with ")
.appendText(type.string)
.appendText(" drawable from resource id: ")
.appendValue(expectedId);
}
}
enum Type {
DRAWABLE_LEFT(INDEX_LEFT, false, "left"),
DRAWABLE_RELATIVE_LEFT(INDEX_LEFT, true, "relative left"),
DRAWABLE_TOP(INDEX_TOP, false, "top"),
DRAWABLE_RELATIVE_TOP(INDEX_TOP, true, "relative top"), | DRAWABLE_RIGHT(INDEX_RIGHT, false, "right"), |
vanniktech/espresso-utils | espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/TextViewDrawableMatcher.java | // Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static final int INDEX_BOTTOM = 3;
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static final int INDEX_LEFT = 0;
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static final int INDEX_RIGHT = 2;
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static final int INDEX_TOP = 1;
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static final int NO_DRAWABLE = -1;
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static boolean drawableMatches(final View view, final Drawable drawable, @DrawableRes final int expectedId) {
// final boolean isVisible = view.getVisibility() == VISIBLE;
//
// if (expectedId == NO_DRAWABLE) {
// return isVisible && drawable == null;
// }
//
// final Context context = view.getContext();
// return isVisible && checkNotNull(drawable.getConstantState(), "constantState == null").equals(ContextCompat.getDrawable(context, expectedId).getConstantState());
// }
| import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.graphics.drawable.Drawable;
import androidx.annotation.CheckResult;
import androidx.annotation.DrawableRes;
import androidx.test.espresso.matcher.BoundedMatcher;
import android.view.View;
import android.widget.TextView;
import org.hamcrest.Description;
import static android.os.Build.VERSION_CODES.JELLY_BEAN_MR1;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_BOTTOM;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_LEFT;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_RELATIVE_BOTTOM;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_RELATIVE_LEFT;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_RELATIVE_RIGHT;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_RELATIVE_TOP;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_RIGHT;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_TOP;
import static com.vanniktech.espresso.core.utils.Utils.INDEX_BOTTOM;
import static com.vanniktech.espresso.core.utils.Utils.INDEX_LEFT;
import static com.vanniktech.espresso.core.utils.Utils.INDEX_RIGHT;
import static com.vanniktech.espresso.core.utils.Utils.INDEX_TOP;
import static com.vanniktech.espresso.core.utils.Utils.NO_DRAWABLE;
import static com.vanniktech.espresso.core.utils.Utils.drawableMatches; | super(TextView.class);
this.expectedId = expectedId;
this.type = type;
}
@Override protected boolean matchesSafely(final TextView textView) {
return drawableMatches(textView, type.getDrawable(textView), expectedId);
}
@Override public void describeTo(final Description description) {
if (expectedId == NO_DRAWABLE) {
description.appendText("with no ")
.appendText(type.string)
.appendText(" drawable");
} else {
description.appendText("with ")
.appendText(type.string)
.appendText(" drawable from resource id: ")
.appendValue(expectedId);
}
}
enum Type {
DRAWABLE_LEFT(INDEX_LEFT, false, "left"),
DRAWABLE_RELATIVE_LEFT(INDEX_LEFT, true, "relative left"),
DRAWABLE_TOP(INDEX_TOP, false, "top"),
DRAWABLE_RELATIVE_TOP(INDEX_TOP, true, "relative top"),
DRAWABLE_RIGHT(INDEX_RIGHT, false, "right"),
DRAWABLE_RELATIVE_RIGHT(INDEX_RIGHT, true, "relative right"), | // Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static final int INDEX_BOTTOM = 3;
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static final int INDEX_LEFT = 0;
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static final int INDEX_RIGHT = 2;
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static final int INDEX_TOP = 1;
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static final int NO_DRAWABLE = -1;
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static boolean drawableMatches(final View view, final Drawable drawable, @DrawableRes final int expectedId) {
// final boolean isVisible = view.getVisibility() == VISIBLE;
//
// if (expectedId == NO_DRAWABLE) {
// return isVisible && drawable == null;
// }
//
// final Context context = view.getContext();
// return isVisible && checkNotNull(drawable.getConstantState(), "constantState == null").equals(ContextCompat.getDrawable(context, expectedId).getConstantState());
// }
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/TextViewDrawableMatcher.java
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.graphics.drawable.Drawable;
import androidx.annotation.CheckResult;
import androidx.annotation.DrawableRes;
import androidx.test.espresso.matcher.BoundedMatcher;
import android.view.View;
import android.widget.TextView;
import org.hamcrest.Description;
import static android.os.Build.VERSION_CODES.JELLY_BEAN_MR1;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_BOTTOM;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_LEFT;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_RELATIVE_BOTTOM;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_RELATIVE_LEFT;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_RELATIVE_RIGHT;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_RELATIVE_TOP;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_RIGHT;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_TOP;
import static com.vanniktech.espresso.core.utils.Utils.INDEX_BOTTOM;
import static com.vanniktech.espresso.core.utils.Utils.INDEX_LEFT;
import static com.vanniktech.espresso.core.utils.Utils.INDEX_RIGHT;
import static com.vanniktech.espresso.core.utils.Utils.INDEX_TOP;
import static com.vanniktech.espresso.core.utils.Utils.NO_DRAWABLE;
import static com.vanniktech.espresso.core.utils.Utils.drawableMatches;
super(TextView.class);
this.expectedId = expectedId;
this.type = type;
}
@Override protected boolean matchesSafely(final TextView textView) {
return drawableMatches(textView, type.getDrawable(textView), expectedId);
}
@Override public void describeTo(final Description description) {
if (expectedId == NO_DRAWABLE) {
description.appendText("with no ")
.appendText(type.string)
.appendText(" drawable");
} else {
description.appendText("with ")
.appendText(type.string)
.appendText(" drawable from resource id: ")
.appendValue(expectedId);
}
}
enum Type {
DRAWABLE_LEFT(INDEX_LEFT, false, "left"),
DRAWABLE_RELATIVE_LEFT(INDEX_LEFT, true, "relative left"),
DRAWABLE_TOP(INDEX_TOP, false, "top"),
DRAWABLE_RELATIVE_TOP(INDEX_TOP, true, "relative top"),
DRAWABLE_RIGHT(INDEX_RIGHT, false, "right"),
DRAWABLE_RELATIVE_RIGHT(INDEX_RIGHT, true, "relative right"), | DRAWABLE_BOTTOM(INDEX_BOTTOM, false, "bottom"), |
vanniktech/espresso-utils | espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/ViewIndexMatcherTest.java | // Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/ViewIndexMatcher.java
// @CheckResult public static Matcher<View> withIndex(final Matcher<View> matcher, final int index) {
// return new ViewIndexMatcher(matcher, index);
// }
| import androidx.test.espresso.NoMatchingViewException;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.rule.ActivityTestRule;
import org.hamcrest.Matchers;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.withTagValue;
import static androidx.test.espresso.matcher.ViewMatchers.withText;
import static com.vanniktech.espresso.core.utils.ViewIndexMatcher.withIndex;
import static org.assertj.core.api.Java6Assertions.assertThat;
import static org.junit.Assert.fail; | package com.vanniktech.espresso.core.utils;
@RunWith(AndroidJUnit4.class) public final class ViewIndexMatcherTest {
@Rule public final ActivityTestRule<ViewIndexMatcherActivity> activityTestRule = new ActivityTestRule<>(ViewIndexMatcherActivity.class);
@Test public void index() { | // Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/ViewIndexMatcher.java
// @CheckResult public static Matcher<View> withIndex(final Matcher<View> matcher, final int index) {
// return new ViewIndexMatcher(matcher, index);
// }
// Path: espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/ViewIndexMatcherTest.java
import androidx.test.espresso.NoMatchingViewException;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.rule.ActivityTestRule;
import org.hamcrest.Matchers;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.withTagValue;
import static androidx.test.espresso.matcher.ViewMatchers.withText;
import static com.vanniktech.espresso.core.utils.ViewIndexMatcher.withIndex;
import static org.assertj.core.api.Java6Assertions.assertThat;
import static org.junit.Assert.fail;
package com.vanniktech.espresso.core.utils;
@RunWith(AndroidJUnit4.class) public final class ViewIndexMatcherTest {
@Rule public final ActivityTestRule<ViewIndexMatcherActivity> activityTestRule = new ActivityTestRule<>(ViewIndexMatcherActivity.class);
@Test public void index() { | onView(withIndex(withText("Test"), 0)).check(matches(withTagValue(Matchers.<Object>equalTo(1)))); |
vanniktech/espresso-utils | espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/DrawableMatcherTest.java | // Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/DrawableMatcher.java
// @CheckResult public static DrawableMatcher withDrawable(@DrawableRes final int resourceId) {
// return new DrawableMatcher(resourceId);
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/DrawableMatcher.java
// @CheckResult public static DrawableMatcher withNoDrawable() {
// return new DrawableMatcher(NO_DRAWABLE);
// }
//
// Path: espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/DrawableMatcherActivity.java
// static final int VIEW_ID = 1234;
| import androidx.annotation.DrawableRes;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.rule.ActivityTestRule;
import com.vanniktech.espresso.core.utils.test.R;
import junit.framework.AssertionFailedError;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import static android.view.View.GONE;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static com.vanniktech.espresso.core.utils.DrawableMatcher.withDrawable;
import static com.vanniktech.espresso.core.utils.DrawableMatcher.withNoDrawable;
import static com.vanniktech.espresso.core.utils.DrawableMatcherActivity.VIEW_ID; | package com.vanniktech.espresso.core.utils;
@RunWith(AndroidJUnit4.class) public final class DrawableMatcherTest {
@Rule public final ExpectedException expectedException = ExpectedException.none();
@Rule public final ActivityTestRule<DrawableMatcherActivity> activityTestRule = new ActivityTestRule<>(DrawableMatcherActivity.class);
@Test public void withNoDrawableMatches() { | // Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/DrawableMatcher.java
// @CheckResult public static DrawableMatcher withDrawable(@DrawableRes final int resourceId) {
// return new DrawableMatcher(resourceId);
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/DrawableMatcher.java
// @CheckResult public static DrawableMatcher withNoDrawable() {
// return new DrawableMatcher(NO_DRAWABLE);
// }
//
// Path: espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/DrawableMatcherActivity.java
// static final int VIEW_ID = 1234;
// Path: espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/DrawableMatcherTest.java
import androidx.annotation.DrawableRes;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.rule.ActivityTestRule;
import com.vanniktech.espresso.core.utils.test.R;
import junit.framework.AssertionFailedError;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import static android.view.View.GONE;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static com.vanniktech.espresso.core.utils.DrawableMatcher.withDrawable;
import static com.vanniktech.espresso.core.utils.DrawableMatcher.withNoDrawable;
import static com.vanniktech.espresso.core.utils.DrawableMatcherActivity.VIEW_ID;
package com.vanniktech.espresso.core.utils;
@RunWith(AndroidJUnit4.class) public final class DrawableMatcherTest {
@Rule public final ExpectedException expectedException = ExpectedException.none();
@Rule public final ActivityTestRule<DrawableMatcherActivity> activityTestRule = new ActivityTestRule<>(DrawableMatcherActivity.class);
@Test public void withNoDrawableMatches() { | onView(withId(VIEW_ID)).check(matches(withNoDrawable())); |
vanniktech/espresso-utils | espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/DrawableMatcherTest.java | // Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/DrawableMatcher.java
// @CheckResult public static DrawableMatcher withDrawable(@DrawableRes final int resourceId) {
// return new DrawableMatcher(resourceId);
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/DrawableMatcher.java
// @CheckResult public static DrawableMatcher withNoDrawable() {
// return new DrawableMatcher(NO_DRAWABLE);
// }
//
// Path: espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/DrawableMatcherActivity.java
// static final int VIEW_ID = 1234;
| import androidx.annotation.DrawableRes;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.rule.ActivityTestRule;
import com.vanniktech.espresso.core.utils.test.R;
import junit.framework.AssertionFailedError;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import static android.view.View.GONE;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static com.vanniktech.espresso.core.utils.DrawableMatcher.withDrawable;
import static com.vanniktech.espresso.core.utils.DrawableMatcher.withNoDrawable;
import static com.vanniktech.espresso.core.utils.DrawableMatcherActivity.VIEW_ID; | package com.vanniktech.espresso.core.utils;
@RunWith(AndroidJUnit4.class) public final class DrawableMatcherTest {
@Rule public final ExpectedException expectedException = ExpectedException.none();
@Rule public final ActivityTestRule<DrawableMatcherActivity> activityTestRule = new ActivityTestRule<>(DrawableMatcherActivity.class);
@Test public void withNoDrawableMatches() { | // Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/DrawableMatcher.java
// @CheckResult public static DrawableMatcher withDrawable(@DrawableRes final int resourceId) {
// return new DrawableMatcher(resourceId);
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/DrawableMatcher.java
// @CheckResult public static DrawableMatcher withNoDrawable() {
// return new DrawableMatcher(NO_DRAWABLE);
// }
//
// Path: espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/DrawableMatcherActivity.java
// static final int VIEW_ID = 1234;
// Path: espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/DrawableMatcherTest.java
import androidx.annotation.DrawableRes;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.rule.ActivityTestRule;
import com.vanniktech.espresso.core.utils.test.R;
import junit.framework.AssertionFailedError;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import static android.view.View.GONE;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static com.vanniktech.espresso.core.utils.DrawableMatcher.withDrawable;
import static com.vanniktech.espresso.core.utils.DrawableMatcher.withNoDrawable;
import static com.vanniktech.espresso.core.utils.DrawableMatcherActivity.VIEW_ID;
package com.vanniktech.espresso.core.utils;
@RunWith(AndroidJUnit4.class) public final class DrawableMatcherTest {
@Rule public final ExpectedException expectedException = ExpectedException.none();
@Rule public final ActivityTestRule<DrawableMatcherActivity> activityTestRule = new ActivityTestRule<>(DrawableMatcherActivity.class);
@Test public void withNoDrawableMatches() { | onView(withId(VIEW_ID)).check(matches(withNoDrawable())); |
vanniktech/espresso-utils | espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/DrawableMatcherTest.java | // Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/DrawableMatcher.java
// @CheckResult public static DrawableMatcher withDrawable(@DrawableRes final int resourceId) {
// return new DrawableMatcher(resourceId);
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/DrawableMatcher.java
// @CheckResult public static DrawableMatcher withNoDrawable() {
// return new DrawableMatcher(NO_DRAWABLE);
// }
//
// Path: espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/DrawableMatcherActivity.java
// static final int VIEW_ID = 1234;
| import androidx.annotation.DrawableRes;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.rule.ActivityTestRule;
import com.vanniktech.espresso.core.utils.test.R;
import junit.framework.AssertionFailedError;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import static android.view.View.GONE;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static com.vanniktech.espresso.core.utils.DrawableMatcher.withDrawable;
import static com.vanniktech.espresso.core.utils.DrawableMatcher.withNoDrawable;
import static com.vanniktech.espresso.core.utils.DrawableMatcherActivity.VIEW_ID; | package com.vanniktech.espresso.core.utils;
@RunWith(AndroidJUnit4.class) public final class DrawableMatcherTest {
@Rule public final ExpectedException expectedException = ExpectedException.none();
@Rule public final ActivityTestRule<DrawableMatcherActivity> activityTestRule = new ActivityTestRule<>(DrawableMatcherActivity.class);
@Test public void withNoDrawableMatches() {
onView(withId(VIEW_ID)).check(matches(withNoDrawable()));
}
@Test public void withDrawableMatches() throws Throwable {
setDrawable(R.drawable.android);
| // Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/DrawableMatcher.java
// @CheckResult public static DrawableMatcher withDrawable(@DrawableRes final int resourceId) {
// return new DrawableMatcher(resourceId);
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/DrawableMatcher.java
// @CheckResult public static DrawableMatcher withNoDrawable() {
// return new DrawableMatcher(NO_DRAWABLE);
// }
//
// Path: espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/DrawableMatcherActivity.java
// static final int VIEW_ID = 1234;
// Path: espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/DrawableMatcherTest.java
import androidx.annotation.DrawableRes;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.rule.ActivityTestRule;
import com.vanniktech.espresso.core.utils.test.R;
import junit.framework.AssertionFailedError;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import static android.view.View.GONE;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static com.vanniktech.espresso.core.utils.DrawableMatcher.withDrawable;
import static com.vanniktech.espresso.core.utils.DrawableMatcher.withNoDrawable;
import static com.vanniktech.espresso.core.utils.DrawableMatcherActivity.VIEW_ID;
package com.vanniktech.espresso.core.utils;
@RunWith(AndroidJUnit4.class) public final class DrawableMatcherTest {
@Rule public final ExpectedException expectedException = ExpectedException.none();
@Rule public final ActivityTestRule<DrawableMatcherActivity> activityTestRule = new ActivityTestRule<>(DrawableMatcherActivity.class);
@Test public void withNoDrawableMatches() {
onView(withId(VIEW_ID)).check(matches(withNoDrawable()));
}
@Test public void withDrawableMatches() throws Throwable {
setDrawable(R.drawable.android);
| onView(withId(VIEW_ID)).check(matches(withDrawable(R.drawable.android))); |
vanniktech/espresso-utils | espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/TextColorMatcherTest.java | // Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/TextColorMatcher.java
// @CheckResult public static TextColorMatcher withTextColor(@ColorInt final int color) {
// return new TextColorMatcher(ColorChecker.from(color));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/TextColorMatcher.java
// @CheckResult public static TextColorMatcher withTextColorRes(@ColorRes final int colorRes) {
// return new TextColorMatcher(ColorChecker.fromRes(colorRes));
// }
//
// Path: espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/TextColorMatcherActivity.java
// static final int VIEW_ID = 1234;
| import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.rule.ActivityTestRule;
import com.vanniktech.espresso.core.utils.test.R;
import junit.framework.AssertionFailedError;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import static android.graphics.Color.GREEN;
import static android.graphics.Color.RED;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static com.vanniktech.espresso.core.utils.TextColorMatcher.withTextColor;
import static com.vanniktech.espresso.core.utils.TextColorMatcher.withTextColorRes;
import static com.vanniktech.espresso.core.utils.TextColorMatcherActivity.VIEW_ID; | package com.vanniktech.espresso.core.utils;
@RunWith(AndroidJUnit4.class) public final class TextColorMatcherTest {
@Rule public final ExpectedException expectedException = ExpectedException.none();
@Rule public final ActivityTestRule<TextColorMatcherActivity> activityTestRule = new ActivityTestRule<>(TextColorMatcherActivity.class);
@Test public void withTextColorResMatches() { | // Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/TextColorMatcher.java
// @CheckResult public static TextColorMatcher withTextColor(@ColorInt final int color) {
// return new TextColorMatcher(ColorChecker.from(color));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/TextColorMatcher.java
// @CheckResult public static TextColorMatcher withTextColorRes(@ColorRes final int colorRes) {
// return new TextColorMatcher(ColorChecker.fromRes(colorRes));
// }
//
// Path: espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/TextColorMatcherActivity.java
// static final int VIEW_ID = 1234;
// Path: espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/TextColorMatcherTest.java
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.rule.ActivityTestRule;
import com.vanniktech.espresso.core.utils.test.R;
import junit.framework.AssertionFailedError;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import static android.graphics.Color.GREEN;
import static android.graphics.Color.RED;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static com.vanniktech.espresso.core.utils.TextColorMatcher.withTextColor;
import static com.vanniktech.espresso.core.utils.TextColorMatcher.withTextColorRes;
import static com.vanniktech.espresso.core.utils.TextColorMatcherActivity.VIEW_ID;
package com.vanniktech.espresso.core.utils;
@RunWith(AndroidJUnit4.class) public final class TextColorMatcherTest {
@Rule public final ExpectedException expectedException = ExpectedException.none();
@Rule public final ActivityTestRule<TextColorMatcherActivity> activityTestRule = new ActivityTestRule<>(TextColorMatcherActivity.class);
@Test public void withTextColorResMatches() { | onView(withId(VIEW_ID)).check(matches(withTextColorRes(R.color.red))); |
vanniktech/espresso-utils | espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/TextColorMatcherTest.java | // Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/TextColorMatcher.java
// @CheckResult public static TextColorMatcher withTextColor(@ColorInt final int color) {
// return new TextColorMatcher(ColorChecker.from(color));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/TextColorMatcher.java
// @CheckResult public static TextColorMatcher withTextColorRes(@ColorRes final int colorRes) {
// return new TextColorMatcher(ColorChecker.fromRes(colorRes));
// }
//
// Path: espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/TextColorMatcherActivity.java
// static final int VIEW_ID = 1234;
| import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.rule.ActivityTestRule;
import com.vanniktech.espresso.core.utils.test.R;
import junit.framework.AssertionFailedError;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import static android.graphics.Color.GREEN;
import static android.graphics.Color.RED;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static com.vanniktech.espresso.core.utils.TextColorMatcher.withTextColor;
import static com.vanniktech.espresso.core.utils.TextColorMatcher.withTextColorRes;
import static com.vanniktech.espresso.core.utils.TextColorMatcherActivity.VIEW_ID; | package com.vanniktech.espresso.core.utils;
@RunWith(AndroidJUnit4.class) public final class TextColorMatcherTest {
@Rule public final ExpectedException expectedException = ExpectedException.none();
@Rule public final ActivityTestRule<TextColorMatcherActivity> activityTestRule = new ActivityTestRule<>(TextColorMatcherActivity.class);
@Test public void withTextColorResMatches() { | // Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/TextColorMatcher.java
// @CheckResult public static TextColorMatcher withTextColor(@ColorInt final int color) {
// return new TextColorMatcher(ColorChecker.from(color));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/TextColorMatcher.java
// @CheckResult public static TextColorMatcher withTextColorRes(@ColorRes final int colorRes) {
// return new TextColorMatcher(ColorChecker.fromRes(colorRes));
// }
//
// Path: espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/TextColorMatcherActivity.java
// static final int VIEW_ID = 1234;
// Path: espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/TextColorMatcherTest.java
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.rule.ActivityTestRule;
import com.vanniktech.espresso.core.utils.test.R;
import junit.framework.AssertionFailedError;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import static android.graphics.Color.GREEN;
import static android.graphics.Color.RED;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static com.vanniktech.espresso.core.utils.TextColorMatcher.withTextColor;
import static com.vanniktech.espresso.core.utils.TextColorMatcher.withTextColorRes;
import static com.vanniktech.espresso.core.utils.TextColorMatcherActivity.VIEW_ID;
package com.vanniktech.espresso.core.utils;
@RunWith(AndroidJUnit4.class) public final class TextColorMatcherTest {
@Rule public final ExpectedException expectedException = ExpectedException.none();
@Rule public final ActivityTestRule<TextColorMatcherActivity> activityTestRule = new ActivityTestRule<>(TextColorMatcherActivity.class);
@Test public void withTextColorResMatches() { | onView(withId(VIEW_ID)).check(matches(withTextColorRes(R.color.red))); |
vanniktech/espresso-utils | espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/TextColorMatcherTest.java | // Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/TextColorMatcher.java
// @CheckResult public static TextColorMatcher withTextColor(@ColorInt final int color) {
// return new TextColorMatcher(ColorChecker.from(color));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/TextColorMatcher.java
// @CheckResult public static TextColorMatcher withTextColorRes(@ColorRes final int colorRes) {
// return new TextColorMatcher(ColorChecker.fromRes(colorRes));
// }
//
// Path: espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/TextColorMatcherActivity.java
// static final int VIEW_ID = 1234;
| import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.rule.ActivityTestRule;
import com.vanniktech.espresso.core.utils.test.R;
import junit.framework.AssertionFailedError;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import static android.graphics.Color.GREEN;
import static android.graphics.Color.RED;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static com.vanniktech.espresso.core.utils.TextColorMatcher.withTextColor;
import static com.vanniktech.espresso.core.utils.TextColorMatcher.withTextColorRes;
import static com.vanniktech.espresso.core.utils.TextColorMatcherActivity.VIEW_ID; | package com.vanniktech.espresso.core.utils;
@RunWith(AndroidJUnit4.class) public final class TextColorMatcherTest {
@Rule public final ExpectedException expectedException = ExpectedException.none();
@Rule public final ActivityTestRule<TextColorMatcherActivity> activityTestRule = new ActivityTestRule<>(TextColorMatcherActivity.class);
@Test public void withTextColorResMatches() {
onView(withId(VIEW_ID)).check(matches(withTextColorRes(R.color.red)));
}
@Test public void withTextColorMatches() { | // Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/TextColorMatcher.java
// @CheckResult public static TextColorMatcher withTextColor(@ColorInt final int color) {
// return new TextColorMatcher(ColorChecker.from(color));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/TextColorMatcher.java
// @CheckResult public static TextColorMatcher withTextColorRes(@ColorRes final int colorRes) {
// return new TextColorMatcher(ColorChecker.fromRes(colorRes));
// }
//
// Path: espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/TextColorMatcherActivity.java
// static final int VIEW_ID = 1234;
// Path: espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/TextColorMatcherTest.java
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.rule.ActivityTestRule;
import com.vanniktech.espresso.core.utils.test.R;
import junit.framework.AssertionFailedError;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import static android.graphics.Color.GREEN;
import static android.graphics.Color.RED;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static com.vanniktech.espresso.core.utils.TextColorMatcher.withTextColor;
import static com.vanniktech.espresso.core.utils.TextColorMatcher.withTextColorRes;
import static com.vanniktech.espresso.core.utils.TextColorMatcherActivity.VIEW_ID;
package com.vanniktech.espresso.core.utils;
@RunWith(AndroidJUnit4.class) public final class TextColorMatcherTest {
@Rule public final ExpectedException expectedException = ExpectedException.none();
@Rule public final ActivityTestRule<TextColorMatcherActivity> activityTestRule = new ActivityTestRule<>(TextColorMatcherActivity.class);
@Test public void withTextColorResMatches() {
onView(withId(VIEW_ID)).check(matches(withTextColorRes(R.color.red)));
}
@Test public void withTextColorMatches() { | onView(withId(VIEW_ID)).check(matches(withTextColor(RED))); |
vanniktech/espresso-utils | espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/CurrentItemMatcherTest.java | // Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/CurrentItemMatcher.java
// @CheckResult public static CurrentItemMatcher withCurrentItem(final int currentItem) {
// return new CurrentItemMatcher(currentItem);
// }
//
// Path: espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/TextColorMatcherActivity.java
// static final int VIEW_ID = 1234;
| import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.rule.ActivityTestRule;
import junit.framework.AssertionFailedError;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static com.vanniktech.espresso.core.utils.CurrentItemMatcher.withCurrentItem;
import static com.vanniktech.espresso.core.utils.TextColorMatcherActivity.VIEW_ID; | package com.vanniktech.espresso.core.utils;
@RunWith(AndroidJUnit4.class) public final class CurrentItemMatcherTest {
@Rule public final ExpectedException expectedException = ExpectedException.none();
@Rule public final ActivityTestRule<CurrentItemMatcherActivity> activityTestRule = new ActivityTestRule<>(CurrentItemMatcherActivity.class);
@Test public void withCurrentItemMatches() { | // Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/CurrentItemMatcher.java
// @CheckResult public static CurrentItemMatcher withCurrentItem(final int currentItem) {
// return new CurrentItemMatcher(currentItem);
// }
//
// Path: espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/TextColorMatcherActivity.java
// static final int VIEW_ID = 1234;
// Path: espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/CurrentItemMatcherTest.java
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.rule.ActivityTestRule;
import junit.framework.AssertionFailedError;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static com.vanniktech.espresso.core.utils.CurrentItemMatcher.withCurrentItem;
import static com.vanniktech.espresso.core.utils.TextColorMatcherActivity.VIEW_ID;
package com.vanniktech.espresso.core.utils;
@RunWith(AndroidJUnit4.class) public final class CurrentItemMatcherTest {
@Rule public final ExpectedException expectedException = ExpectedException.none();
@Rule public final ActivityTestRule<CurrentItemMatcherActivity> activityTestRule = new ActivityTestRule<>(CurrentItemMatcherActivity.class);
@Test public void withCurrentItemMatches() { | onView(withId(VIEW_ID)).check(matches(withCurrentItem(0))); |
vanniktech/espresso-utils | espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/CurrentItemMatcherTest.java | // Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/CurrentItemMatcher.java
// @CheckResult public static CurrentItemMatcher withCurrentItem(final int currentItem) {
// return new CurrentItemMatcher(currentItem);
// }
//
// Path: espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/TextColorMatcherActivity.java
// static final int VIEW_ID = 1234;
| import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.rule.ActivityTestRule;
import junit.framework.AssertionFailedError;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static com.vanniktech.espresso.core.utils.CurrentItemMatcher.withCurrentItem;
import static com.vanniktech.espresso.core.utils.TextColorMatcherActivity.VIEW_ID; | package com.vanniktech.espresso.core.utils;
@RunWith(AndroidJUnit4.class) public final class CurrentItemMatcherTest {
@Rule public final ExpectedException expectedException = ExpectedException.none();
@Rule public final ActivityTestRule<CurrentItemMatcherActivity> activityTestRule = new ActivityTestRule<>(CurrentItemMatcherActivity.class);
@Test public void withCurrentItemMatches() { | // Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/CurrentItemMatcher.java
// @CheckResult public static CurrentItemMatcher withCurrentItem(final int currentItem) {
// return new CurrentItemMatcher(currentItem);
// }
//
// Path: espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/TextColorMatcherActivity.java
// static final int VIEW_ID = 1234;
// Path: espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/CurrentItemMatcherTest.java
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.rule.ActivityTestRule;
import junit.framework.AssertionFailedError;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static com.vanniktech.espresso.core.utils.CurrentItemMatcher.withCurrentItem;
import static com.vanniktech.espresso.core.utils.TextColorMatcherActivity.VIEW_ID;
package com.vanniktech.espresso.core.utils;
@RunWith(AndroidJUnit4.class) public final class CurrentItemMatcherTest {
@Rule public final ExpectedException expectedException = ExpectedException.none();
@Rule public final ActivityTestRule<CurrentItemMatcherActivity> activityTestRule = new ActivityTestRule<>(CurrentItemMatcherActivity.class);
@Test public void withCurrentItemMatches() { | onView(withId(VIEW_ID)).check(matches(withCurrentItem(0))); |
vanniktech/espresso-utils | espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/HintTextColorMatcherTest.java | // Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/HintTextColorMatcher.java
// @CheckResult public static HintTextColorMatcher withHintTextColor(@ColorInt final int color) {
// return new HintTextColorMatcher(ColorChecker.from(color));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/HintTextColorMatcher.java
// @CheckResult public static HintTextColorMatcher withHintTextColorRes(@ColorRes final int colorRes) {
// return new HintTextColorMatcher(ColorChecker.fromRes(colorRes));
// }
//
// Path: espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/HintTextColorMatcherActivity.java
// static final int VIEW_ID = 1234;
| import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.rule.ActivityTestRule;
import com.vanniktech.espresso.core.utils.test.R;
import junit.framework.AssertionFailedError;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import static android.graphics.Color.GREEN;
import static android.graphics.Color.RED;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static com.vanniktech.espresso.core.utils.HintTextColorMatcher.withHintTextColor;
import static com.vanniktech.espresso.core.utils.HintTextColorMatcher.withHintTextColorRes;
import static com.vanniktech.espresso.core.utils.HintTextColorMatcherActivity.VIEW_ID; | package com.vanniktech.espresso.core.utils;
@RunWith(AndroidJUnit4.class) public final class HintTextColorMatcherTest {
@Rule public final ExpectedException expectedException = ExpectedException.none();
@Rule public final ActivityTestRule<HintTextColorMatcherActivity> activityTestRule = new ActivityTestRule<>(HintTextColorMatcherActivity.class);
@Test public void withHintTextColorResMatches() { | // Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/HintTextColorMatcher.java
// @CheckResult public static HintTextColorMatcher withHintTextColor(@ColorInt final int color) {
// return new HintTextColorMatcher(ColorChecker.from(color));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/HintTextColorMatcher.java
// @CheckResult public static HintTextColorMatcher withHintTextColorRes(@ColorRes final int colorRes) {
// return new HintTextColorMatcher(ColorChecker.fromRes(colorRes));
// }
//
// Path: espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/HintTextColorMatcherActivity.java
// static final int VIEW_ID = 1234;
// Path: espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/HintTextColorMatcherTest.java
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.rule.ActivityTestRule;
import com.vanniktech.espresso.core.utils.test.R;
import junit.framework.AssertionFailedError;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import static android.graphics.Color.GREEN;
import static android.graphics.Color.RED;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static com.vanniktech.espresso.core.utils.HintTextColorMatcher.withHintTextColor;
import static com.vanniktech.espresso.core.utils.HintTextColorMatcher.withHintTextColorRes;
import static com.vanniktech.espresso.core.utils.HintTextColorMatcherActivity.VIEW_ID;
package com.vanniktech.espresso.core.utils;
@RunWith(AndroidJUnit4.class) public final class HintTextColorMatcherTest {
@Rule public final ExpectedException expectedException = ExpectedException.none();
@Rule public final ActivityTestRule<HintTextColorMatcherActivity> activityTestRule = new ActivityTestRule<>(HintTextColorMatcherActivity.class);
@Test public void withHintTextColorResMatches() { | onView(withId(VIEW_ID)).check(matches(withHintTextColorRes(R.color.red))); |
vanniktech/espresso-utils | espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/HintTextColorMatcherTest.java | // Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/HintTextColorMatcher.java
// @CheckResult public static HintTextColorMatcher withHintTextColor(@ColorInt final int color) {
// return new HintTextColorMatcher(ColorChecker.from(color));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/HintTextColorMatcher.java
// @CheckResult public static HintTextColorMatcher withHintTextColorRes(@ColorRes final int colorRes) {
// return new HintTextColorMatcher(ColorChecker.fromRes(colorRes));
// }
//
// Path: espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/HintTextColorMatcherActivity.java
// static final int VIEW_ID = 1234;
| import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.rule.ActivityTestRule;
import com.vanniktech.espresso.core.utils.test.R;
import junit.framework.AssertionFailedError;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import static android.graphics.Color.GREEN;
import static android.graphics.Color.RED;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static com.vanniktech.espresso.core.utils.HintTextColorMatcher.withHintTextColor;
import static com.vanniktech.espresso.core.utils.HintTextColorMatcher.withHintTextColorRes;
import static com.vanniktech.espresso.core.utils.HintTextColorMatcherActivity.VIEW_ID; | package com.vanniktech.espresso.core.utils;
@RunWith(AndroidJUnit4.class) public final class HintTextColorMatcherTest {
@Rule public final ExpectedException expectedException = ExpectedException.none();
@Rule public final ActivityTestRule<HintTextColorMatcherActivity> activityTestRule = new ActivityTestRule<>(HintTextColorMatcherActivity.class);
@Test public void withHintTextColorResMatches() { | // Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/HintTextColorMatcher.java
// @CheckResult public static HintTextColorMatcher withHintTextColor(@ColorInt final int color) {
// return new HintTextColorMatcher(ColorChecker.from(color));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/HintTextColorMatcher.java
// @CheckResult public static HintTextColorMatcher withHintTextColorRes(@ColorRes final int colorRes) {
// return new HintTextColorMatcher(ColorChecker.fromRes(colorRes));
// }
//
// Path: espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/HintTextColorMatcherActivity.java
// static final int VIEW_ID = 1234;
// Path: espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/HintTextColorMatcherTest.java
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.rule.ActivityTestRule;
import com.vanniktech.espresso.core.utils.test.R;
import junit.framework.AssertionFailedError;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import static android.graphics.Color.GREEN;
import static android.graphics.Color.RED;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static com.vanniktech.espresso.core.utils.HintTextColorMatcher.withHintTextColor;
import static com.vanniktech.espresso.core.utils.HintTextColorMatcher.withHintTextColorRes;
import static com.vanniktech.espresso.core.utils.HintTextColorMatcherActivity.VIEW_ID;
package com.vanniktech.espresso.core.utils;
@RunWith(AndroidJUnit4.class) public final class HintTextColorMatcherTest {
@Rule public final ExpectedException expectedException = ExpectedException.none();
@Rule public final ActivityTestRule<HintTextColorMatcherActivity> activityTestRule = new ActivityTestRule<>(HintTextColorMatcherActivity.class);
@Test public void withHintTextColorResMatches() { | onView(withId(VIEW_ID)).check(matches(withHintTextColorRes(R.color.red))); |
vanniktech/espresso-utils | espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/HintTextColorMatcherTest.java | // Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/HintTextColorMatcher.java
// @CheckResult public static HintTextColorMatcher withHintTextColor(@ColorInt final int color) {
// return new HintTextColorMatcher(ColorChecker.from(color));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/HintTextColorMatcher.java
// @CheckResult public static HintTextColorMatcher withHintTextColorRes(@ColorRes final int colorRes) {
// return new HintTextColorMatcher(ColorChecker.fromRes(colorRes));
// }
//
// Path: espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/HintTextColorMatcherActivity.java
// static final int VIEW_ID = 1234;
| import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.rule.ActivityTestRule;
import com.vanniktech.espresso.core.utils.test.R;
import junit.framework.AssertionFailedError;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import static android.graphics.Color.GREEN;
import static android.graphics.Color.RED;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static com.vanniktech.espresso.core.utils.HintTextColorMatcher.withHintTextColor;
import static com.vanniktech.espresso.core.utils.HintTextColorMatcher.withHintTextColorRes;
import static com.vanniktech.espresso.core.utils.HintTextColorMatcherActivity.VIEW_ID; | package com.vanniktech.espresso.core.utils;
@RunWith(AndroidJUnit4.class) public final class HintTextColorMatcherTest {
@Rule public final ExpectedException expectedException = ExpectedException.none();
@Rule public final ActivityTestRule<HintTextColorMatcherActivity> activityTestRule = new ActivityTestRule<>(HintTextColorMatcherActivity.class);
@Test public void withHintTextColorResMatches() {
onView(withId(VIEW_ID)).check(matches(withHintTextColorRes(R.color.red)));
}
@Test public void withHintTextColorMatches() { | // Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/HintTextColorMatcher.java
// @CheckResult public static HintTextColorMatcher withHintTextColor(@ColorInt final int color) {
// return new HintTextColorMatcher(ColorChecker.from(color));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/HintTextColorMatcher.java
// @CheckResult public static HintTextColorMatcher withHintTextColorRes(@ColorRes final int colorRes) {
// return new HintTextColorMatcher(ColorChecker.fromRes(colorRes));
// }
//
// Path: espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/HintTextColorMatcherActivity.java
// static final int VIEW_ID = 1234;
// Path: espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/HintTextColorMatcherTest.java
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.rule.ActivityTestRule;
import com.vanniktech.espresso.core.utils.test.R;
import junit.framework.AssertionFailedError;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import static android.graphics.Color.GREEN;
import static android.graphics.Color.RED;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static com.vanniktech.espresso.core.utils.HintTextColorMatcher.withHintTextColor;
import static com.vanniktech.espresso.core.utils.HintTextColorMatcher.withHintTextColorRes;
import static com.vanniktech.espresso.core.utils.HintTextColorMatcherActivity.VIEW_ID;
package com.vanniktech.espresso.core.utils;
@RunWith(AndroidJUnit4.class) public final class HintTextColorMatcherTest {
@Rule public final ExpectedException expectedException = ExpectedException.none();
@Rule public final ActivityTestRule<HintTextColorMatcherActivity> activityTestRule = new ActivityTestRule<>(HintTextColorMatcherActivity.class);
@Test public void withHintTextColorResMatches() {
onView(withId(VIEW_ID)).check(matches(withHintTextColorRes(R.color.red)));
}
@Test public void withHintTextColorMatches() { | onView(withId(VIEW_ID)).check(matches(withHintTextColor(RED))); |
vanniktech/espresso-utils | espresso-core-utils/src/test/java/com/vanniktech/espresso/core/utils/UtilsTest.java | // Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// @NonNull static <T> T checkNotNull(@Nullable final T reference, final String message) {
// if (reference == null) {
// throw new IllegalArgumentException(message);
// }
//
// return reference;
// }
| import com.pushtorefresh.private_constructor_checker.PrivateConstructorChecker;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import static com.vanniktech.espresso.core.utils.Utils.checkNotNull;
import static org.assertj.core.api.Java6Assertions.assertThat; | package com.vanniktech.espresso.core.utils;
public final class UtilsTest {
@Rule public final ExpectedException expectedException = ExpectedException.none();
@Test public void constructorShouldBePrivate() {
PrivateConstructorChecker.forClass(Utils.class)
.expectedTypeOfException(AssertionError.class)
.expectedExceptionMessage("No instances.")
.check();
}
@Test public void checkNotNullNoNull() { | // Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// @NonNull static <T> T checkNotNull(@Nullable final T reference, final String message) {
// if (reference == null) {
// throw new IllegalArgumentException(message);
// }
//
// return reference;
// }
// Path: espresso-core-utils/src/test/java/com/vanniktech/espresso/core/utils/UtilsTest.java
import com.pushtorefresh.private_constructor_checker.PrivateConstructorChecker;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import static com.vanniktech.espresso.core.utils.Utils.checkNotNull;
import static org.assertj.core.api.Java6Assertions.assertThat;
package com.vanniktech.espresso.core.utils;
public final class UtilsTest {
@Rule public final ExpectedException expectedException = ExpectedException.none();
@Test public void constructorShouldBePrivate() {
PrivateConstructorChecker.forClass(Utils.class)
.expectedTypeOfException(AssertionError.class)
.expectedExceptionMessage("No instances.")
.check();
}
@Test public void checkNotNullNoNull() { | assertThat(checkNotNull(5, "should never be")).isEqualTo(5); |
vanniktech/espresso-utils | espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/ProgressMatcherTest.java | // Path: espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/ProgressBarActivity.java
// static final int VIEW_ID = 1234;
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/ProgressMatcher.java
// @CheckResult public static ProgressMatcher withProgress(final int progress) {
// return new ProgressMatcher(progress);
// }
| import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.rule.ActivityTestRule;
import junit.framework.AssertionFailedError;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static com.vanniktech.espresso.core.utils.ProgressBarActivity.VIEW_ID;
import static com.vanniktech.espresso.core.utils.ProgressMatcher.withProgress; | package com.vanniktech.espresso.core.utils;
@RunWith(AndroidJUnit4.class) public final class ProgressMatcherTest {
@Rule public final ExpectedException expectedException = ExpectedException.none();
@Rule public final ActivityTestRule<ProgressBarActivity> activityTestRule = new ActivityTestRule<>(ProgressBarActivity.class);
@Test public void withProgressMatches() { | // Path: espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/ProgressBarActivity.java
// static final int VIEW_ID = 1234;
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/ProgressMatcher.java
// @CheckResult public static ProgressMatcher withProgress(final int progress) {
// return new ProgressMatcher(progress);
// }
// Path: espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/ProgressMatcherTest.java
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.rule.ActivityTestRule;
import junit.framework.AssertionFailedError;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static com.vanniktech.espresso.core.utils.ProgressBarActivity.VIEW_ID;
import static com.vanniktech.espresso.core.utils.ProgressMatcher.withProgress;
package com.vanniktech.espresso.core.utils;
@RunWith(AndroidJUnit4.class) public final class ProgressMatcherTest {
@Rule public final ExpectedException expectedException = ExpectedException.none();
@Rule public final ActivityTestRule<ProgressBarActivity> activityTestRule = new ActivityTestRule<>(ProgressBarActivity.class);
@Test public void withProgressMatches() { | onView(withId(VIEW_ID)).check(matches(withProgress(1))); |
vanniktech/espresso-utils | espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/ProgressMatcherTest.java | // Path: espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/ProgressBarActivity.java
// static final int VIEW_ID = 1234;
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/ProgressMatcher.java
// @CheckResult public static ProgressMatcher withProgress(final int progress) {
// return new ProgressMatcher(progress);
// }
| import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.rule.ActivityTestRule;
import junit.framework.AssertionFailedError;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static com.vanniktech.espresso.core.utils.ProgressBarActivity.VIEW_ID;
import static com.vanniktech.espresso.core.utils.ProgressMatcher.withProgress; | package com.vanniktech.espresso.core.utils;
@RunWith(AndroidJUnit4.class) public final class ProgressMatcherTest {
@Rule public final ExpectedException expectedException = ExpectedException.none();
@Rule public final ActivityTestRule<ProgressBarActivity> activityTestRule = new ActivityTestRule<>(ProgressBarActivity.class);
@Test public void withProgressMatches() { | // Path: espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/ProgressBarActivity.java
// static final int VIEW_ID = 1234;
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/ProgressMatcher.java
// @CheckResult public static ProgressMatcher withProgress(final int progress) {
// return new ProgressMatcher(progress);
// }
// Path: espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/ProgressMatcherTest.java
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.rule.ActivityTestRule;
import junit.framework.AssertionFailedError;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static com.vanniktech.espresso.core.utils.ProgressBarActivity.VIEW_ID;
import static com.vanniktech.espresso.core.utils.ProgressMatcher.withProgress;
package com.vanniktech.espresso.core.utils;
@RunWith(AndroidJUnit4.class) public final class ProgressMatcherTest {
@Rule public final ExpectedException expectedException = ExpectedException.none();
@Rule public final ActivityTestRule<ProgressBarActivity> activityTestRule = new ActivityTestRule<>(ProgressBarActivity.class);
@Test public void withProgressMatches() { | onView(withId(VIEW_ID)).check(matches(withProgress(1))); |
vanniktech/espresso-utils | espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/AppendTextActionTest.java | // Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AppendTextAction.java
// @CheckResult public static ViewAction appendText(final String text) {
// return actionWithAssertions(new AppendTextAction(text));
// }
//
// Path: espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/ProgressBarActivity.java
// static final int VIEW_ID = 1234;
| import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.rule.ActivityTestRule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static androidx.test.espresso.matcher.ViewMatchers.withText;
import static com.vanniktech.espresso.core.utils.AppendTextAction.appendText;
import static com.vanniktech.espresso.core.utils.ProgressBarActivity.VIEW_ID; | package com.vanniktech.espresso.core.utils;
@RunWith(AndroidJUnit4.class) public final class AppendTextActionTest {
@Rule public final ActivityTestRule<AppendTextActionActivity> activityTestRule = new ActivityTestRule<>(AppendTextActionActivity.class);
@Test public void appendingText() { | // Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AppendTextAction.java
// @CheckResult public static ViewAction appendText(final String text) {
// return actionWithAssertions(new AppendTextAction(text));
// }
//
// Path: espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/ProgressBarActivity.java
// static final int VIEW_ID = 1234;
// Path: espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/AppendTextActionTest.java
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.rule.ActivityTestRule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static androidx.test.espresso.matcher.ViewMatchers.withText;
import static com.vanniktech.espresso.core.utils.AppendTextAction.appendText;
import static com.vanniktech.espresso.core.utils.ProgressBarActivity.VIEW_ID;
package com.vanniktech.espresso.core.utils;
@RunWith(AndroidJUnit4.class) public final class AppendTextActionTest {
@Rule public final ActivityTestRule<AppendTextActionActivity> activityTestRule = new ActivityTestRule<>(AppendTextActionActivity.class);
@Test public void appendingText() { | onView(withId(VIEW_ID)).check(matches(withText("Test"))); |
vanniktech/espresso-utils | espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/AppendTextActionTest.java | // Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AppendTextAction.java
// @CheckResult public static ViewAction appendText(final String text) {
// return actionWithAssertions(new AppendTextAction(text));
// }
//
// Path: espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/ProgressBarActivity.java
// static final int VIEW_ID = 1234;
| import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.rule.ActivityTestRule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static androidx.test.espresso.matcher.ViewMatchers.withText;
import static com.vanniktech.espresso.core.utils.AppendTextAction.appendText;
import static com.vanniktech.espresso.core.utils.ProgressBarActivity.VIEW_ID; | package com.vanniktech.espresso.core.utils;
@RunWith(AndroidJUnit4.class) public final class AppendTextActionTest {
@Rule public final ActivityTestRule<AppendTextActionActivity> activityTestRule = new ActivityTestRule<>(AppendTextActionActivity.class);
@Test public void appendingText() {
onView(withId(VIEW_ID)).check(matches(withText("Test"))); | // Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AppendTextAction.java
// @CheckResult public static ViewAction appendText(final String text) {
// return actionWithAssertions(new AppendTextAction(text));
// }
//
// Path: espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/ProgressBarActivity.java
// static final int VIEW_ID = 1234;
// Path: espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/AppendTextActionTest.java
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.rule.ActivityTestRule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static androidx.test.espresso.matcher.ViewMatchers.withText;
import static com.vanniktech.espresso.core.utils.AppendTextAction.appendText;
import static com.vanniktech.espresso.core.utils.ProgressBarActivity.VIEW_ID;
package com.vanniktech.espresso.core.utils;
@RunWith(AndroidJUnit4.class) public final class AppendTextActionTest {
@Rule public final ActivityTestRule<AppendTextActionActivity> activityTestRule = new ActivityTestRule<>(AppendTextActionActivity.class);
@Test public void appendingText() {
onView(withId(VIEW_ID)).check(matches(withText("Test"))); | onView(withId(VIEW_ID)).perform(appendText("Something")); |
vanniktech/espresso-utils | espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/SetProgressActionTest.java | // Path: espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/ProgressBarActivity.java
// static final int VIEW_ID = 1234;
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/ProgressMatcher.java
// @CheckResult public static ProgressMatcher withProgress(final int progress) {
// return new ProgressMatcher(progress);
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/SetProgressAction.java
// @CheckResult public static ViewAction setProgress(final int progress) {
// return actionWithAssertions(new SetProgressAction(progress));
// }
| import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.rule.ActivityTestRule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static com.vanniktech.espresso.core.utils.ProgressBarActivity.VIEW_ID;
import static com.vanniktech.espresso.core.utils.ProgressMatcher.withProgress;
import static com.vanniktech.espresso.core.utils.SetProgressAction.setProgress; | package com.vanniktech.espresso.core.utils;
@RunWith(AndroidJUnit4.class) public final class SetProgressActionTest {
@Rule public final ActivityTestRule<ProgressBarActivity> activityTestRule = new ActivityTestRule<>(ProgressBarActivity.class);
@Test public void settingProgress() { | // Path: espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/ProgressBarActivity.java
// static final int VIEW_ID = 1234;
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/ProgressMatcher.java
// @CheckResult public static ProgressMatcher withProgress(final int progress) {
// return new ProgressMatcher(progress);
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/SetProgressAction.java
// @CheckResult public static ViewAction setProgress(final int progress) {
// return actionWithAssertions(new SetProgressAction(progress));
// }
// Path: espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/SetProgressActionTest.java
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.rule.ActivityTestRule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static com.vanniktech.espresso.core.utils.ProgressBarActivity.VIEW_ID;
import static com.vanniktech.espresso.core.utils.ProgressMatcher.withProgress;
import static com.vanniktech.espresso.core.utils.SetProgressAction.setProgress;
package com.vanniktech.espresso.core.utils;
@RunWith(AndroidJUnit4.class) public final class SetProgressActionTest {
@Rule public final ActivityTestRule<ProgressBarActivity> activityTestRule = new ActivityTestRule<>(ProgressBarActivity.class);
@Test public void settingProgress() { | onView(withId(VIEW_ID)).check(matches(withProgress(1))); |
vanniktech/espresso-utils | espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/SetProgressActionTest.java | // Path: espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/ProgressBarActivity.java
// static final int VIEW_ID = 1234;
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/ProgressMatcher.java
// @CheckResult public static ProgressMatcher withProgress(final int progress) {
// return new ProgressMatcher(progress);
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/SetProgressAction.java
// @CheckResult public static ViewAction setProgress(final int progress) {
// return actionWithAssertions(new SetProgressAction(progress));
// }
| import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.rule.ActivityTestRule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static com.vanniktech.espresso.core.utils.ProgressBarActivity.VIEW_ID;
import static com.vanniktech.espresso.core.utils.ProgressMatcher.withProgress;
import static com.vanniktech.espresso.core.utils.SetProgressAction.setProgress; | package com.vanniktech.espresso.core.utils;
@RunWith(AndroidJUnit4.class) public final class SetProgressActionTest {
@Rule public final ActivityTestRule<ProgressBarActivity> activityTestRule = new ActivityTestRule<>(ProgressBarActivity.class);
@Test public void settingProgress() { | // Path: espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/ProgressBarActivity.java
// static final int VIEW_ID = 1234;
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/ProgressMatcher.java
// @CheckResult public static ProgressMatcher withProgress(final int progress) {
// return new ProgressMatcher(progress);
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/SetProgressAction.java
// @CheckResult public static ViewAction setProgress(final int progress) {
// return actionWithAssertions(new SetProgressAction(progress));
// }
// Path: espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/SetProgressActionTest.java
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.rule.ActivityTestRule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static com.vanniktech.espresso.core.utils.ProgressBarActivity.VIEW_ID;
import static com.vanniktech.espresso.core.utils.ProgressMatcher.withProgress;
import static com.vanniktech.espresso.core.utils.SetProgressAction.setProgress;
package com.vanniktech.espresso.core.utils;
@RunWith(AndroidJUnit4.class) public final class SetProgressActionTest {
@Rule public final ActivityTestRule<ProgressBarActivity> activityTestRule = new ActivityTestRule<>(ProgressBarActivity.class);
@Test public void settingProgress() { | onView(withId(VIEW_ID)).check(matches(withProgress(1))); |
vanniktech/espresso-utils | espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/SetProgressActionTest.java | // Path: espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/ProgressBarActivity.java
// static final int VIEW_ID = 1234;
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/ProgressMatcher.java
// @CheckResult public static ProgressMatcher withProgress(final int progress) {
// return new ProgressMatcher(progress);
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/SetProgressAction.java
// @CheckResult public static ViewAction setProgress(final int progress) {
// return actionWithAssertions(new SetProgressAction(progress));
// }
| import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.rule.ActivityTestRule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static com.vanniktech.espresso.core.utils.ProgressBarActivity.VIEW_ID;
import static com.vanniktech.espresso.core.utils.ProgressMatcher.withProgress;
import static com.vanniktech.espresso.core.utils.SetProgressAction.setProgress; | package com.vanniktech.espresso.core.utils;
@RunWith(AndroidJUnit4.class) public final class SetProgressActionTest {
@Rule public final ActivityTestRule<ProgressBarActivity> activityTestRule = new ActivityTestRule<>(ProgressBarActivity.class);
@Test public void settingProgress() {
onView(withId(VIEW_ID)).check(matches(withProgress(1))); | // Path: espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/ProgressBarActivity.java
// static final int VIEW_ID = 1234;
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/ProgressMatcher.java
// @CheckResult public static ProgressMatcher withProgress(final int progress) {
// return new ProgressMatcher(progress);
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/SetProgressAction.java
// @CheckResult public static ViewAction setProgress(final int progress) {
// return actionWithAssertions(new SetProgressAction(progress));
// }
// Path: espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/SetProgressActionTest.java
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.rule.ActivityTestRule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static com.vanniktech.espresso.core.utils.ProgressBarActivity.VIEW_ID;
import static com.vanniktech.espresso.core.utils.ProgressMatcher.withProgress;
import static com.vanniktech.espresso.core.utils.SetProgressAction.setProgress;
package com.vanniktech.espresso.core.utils;
@RunWith(AndroidJUnit4.class) public final class SetProgressActionTest {
@Rule public final ActivityTestRule<ProgressBarActivity> activityTestRule = new ActivityTestRule<>(ProgressBarActivity.class);
@Test public void settingProgress() {
onView(withId(VIEW_ID)).check(matches(withProgress(1))); | onView(withId(VIEW_ID)).perform(setProgress(95)); |
vanniktech/espresso-utils | espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/DrawableMatcher.java | // Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static final int NO_DRAWABLE = -1;
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static boolean drawableMatches(final View view, final Drawable drawable, @DrawableRes final int expectedId) {
// final boolean isVisible = view.getVisibility() == VISIBLE;
//
// if (expectedId == NO_DRAWABLE) {
// return isVisible && drawable == null;
// }
//
// final Context context = view.getContext();
// return isVisible && checkNotNull(drawable.getConstantState(), "constantState == null").equals(ContextCompat.getDrawable(context, expectedId).getConstantState());
// }
| import android.graphics.drawable.Drawable;
import androidx.annotation.CheckResult;
import androidx.annotation.DrawableRes;
import androidx.test.espresso.matcher.BoundedMatcher;
import android.view.View;
import android.widget.ImageView;
import org.hamcrest.Description;
import static com.vanniktech.espresso.core.utils.Utils.NO_DRAWABLE;
import static com.vanniktech.espresso.core.utils.Utils.drawableMatches; | package com.vanniktech.espresso.core.utils;
public final class DrawableMatcher extends BoundedMatcher<View, ImageView> {
/**
* Matches that the given view has the expected drawable.
*
* <p>Example usage:</p>
* <code>onView(withId(R.id.view)).check(matches(withDrawable(R.drawable.android)));</code>
*/
@CheckResult public static DrawableMatcher withDrawable(@DrawableRes final int resourceId) {
return new DrawableMatcher(resourceId);
}
/**
* Matches that the given view has no drawable.
*
* <p>Example usage:</p>
* <code>onView(withId(R.id.view)).check(matches(withNoDrawable()));</code>
*/
@CheckResult public static DrawableMatcher withNoDrawable() { | // Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static final int NO_DRAWABLE = -1;
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static boolean drawableMatches(final View view, final Drawable drawable, @DrawableRes final int expectedId) {
// final boolean isVisible = view.getVisibility() == VISIBLE;
//
// if (expectedId == NO_DRAWABLE) {
// return isVisible && drawable == null;
// }
//
// final Context context = view.getContext();
// return isVisible && checkNotNull(drawable.getConstantState(), "constantState == null").equals(ContextCompat.getDrawable(context, expectedId).getConstantState());
// }
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/DrawableMatcher.java
import android.graphics.drawable.Drawable;
import androidx.annotation.CheckResult;
import androidx.annotation.DrawableRes;
import androidx.test.espresso.matcher.BoundedMatcher;
import android.view.View;
import android.widget.ImageView;
import org.hamcrest.Description;
import static com.vanniktech.espresso.core.utils.Utils.NO_DRAWABLE;
import static com.vanniktech.espresso.core.utils.Utils.drawableMatches;
package com.vanniktech.espresso.core.utils;
public final class DrawableMatcher extends BoundedMatcher<View, ImageView> {
/**
* Matches that the given view has the expected drawable.
*
* <p>Example usage:</p>
* <code>onView(withId(R.id.view)).check(matches(withDrawable(R.drawable.android)));</code>
*/
@CheckResult public static DrawableMatcher withDrawable(@DrawableRes final int resourceId) {
return new DrawableMatcher(resourceId);
}
/**
* Matches that the given view has no drawable.
*
* <p>Example usage:</p>
* <code>onView(withId(R.id.view)).check(matches(withNoDrawable()));</code>
*/
@CheckResult public static DrawableMatcher withNoDrawable() { | return new DrawableMatcher(NO_DRAWABLE); |
vanniktech/espresso-utils | espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/DrawableMatcher.java | // Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static final int NO_DRAWABLE = -1;
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static boolean drawableMatches(final View view, final Drawable drawable, @DrawableRes final int expectedId) {
// final boolean isVisible = view.getVisibility() == VISIBLE;
//
// if (expectedId == NO_DRAWABLE) {
// return isVisible && drawable == null;
// }
//
// final Context context = view.getContext();
// return isVisible && checkNotNull(drawable.getConstantState(), "constantState == null").equals(ContextCompat.getDrawable(context, expectedId).getConstantState());
// }
| import android.graphics.drawable.Drawable;
import androidx.annotation.CheckResult;
import androidx.annotation.DrawableRes;
import androidx.test.espresso.matcher.BoundedMatcher;
import android.view.View;
import android.widget.ImageView;
import org.hamcrest.Description;
import static com.vanniktech.espresso.core.utils.Utils.NO_DRAWABLE;
import static com.vanniktech.espresso.core.utils.Utils.drawableMatches; | package com.vanniktech.espresso.core.utils;
public final class DrawableMatcher extends BoundedMatcher<View, ImageView> {
/**
* Matches that the given view has the expected drawable.
*
* <p>Example usage:</p>
* <code>onView(withId(R.id.view)).check(matches(withDrawable(R.drawable.android)));</code>
*/
@CheckResult public static DrawableMatcher withDrawable(@DrawableRes final int resourceId) {
return new DrawableMatcher(resourceId);
}
/**
* Matches that the given view has no drawable.
*
* <p>Example usage:</p>
* <code>onView(withId(R.id.view)).check(matches(withNoDrawable()));</code>
*/
@CheckResult public static DrawableMatcher withNoDrawable() {
return new DrawableMatcher(NO_DRAWABLE);
}
private final int expectedId;
private DrawableMatcher(final int expectedId) {
super(ImageView.class);
this.expectedId = expectedId;
}
@Override protected boolean matchesSafely(final ImageView imageView) {
final Drawable drawable = imageView.getDrawable(); | // Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static final int NO_DRAWABLE = -1;
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static boolean drawableMatches(final View view, final Drawable drawable, @DrawableRes final int expectedId) {
// final boolean isVisible = view.getVisibility() == VISIBLE;
//
// if (expectedId == NO_DRAWABLE) {
// return isVisible && drawable == null;
// }
//
// final Context context = view.getContext();
// return isVisible && checkNotNull(drawable.getConstantState(), "constantState == null").equals(ContextCompat.getDrawable(context, expectedId).getConstantState());
// }
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/DrawableMatcher.java
import android.graphics.drawable.Drawable;
import androidx.annotation.CheckResult;
import androidx.annotation.DrawableRes;
import androidx.test.espresso.matcher.BoundedMatcher;
import android.view.View;
import android.widget.ImageView;
import org.hamcrest.Description;
import static com.vanniktech.espresso.core.utils.Utils.NO_DRAWABLE;
import static com.vanniktech.espresso.core.utils.Utils.drawableMatches;
package com.vanniktech.espresso.core.utils;
public final class DrawableMatcher extends BoundedMatcher<View, ImageView> {
/**
* Matches that the given view has the expected drawable.
*
* <p>Example usage:</p>
* <code>onView(withId(R.id.view)).check(matches(withDrawable(R.drawable.android)));</code>
*/
@CheckResult public static DrawableMatcher withDrawable(@DrawableRes final int resourceId) {
return new DrawableMatcher(resourceId);
}
/**
* Matches that the given view has no drawable.
*
* <p>Example usage:</p>
* <code>onView(withId(R.id.view)).check(matches(withNoDrawable()));</code>
*/
@CheckResult public static DrawableMatcher withNoDrawable() {
return new DrawableMatcher(NO_DRAWABLE);
}
private final int expectedId;
private DrawableMatcher(final int expectedId) {
super(ImageView.class);
this.expectedId = expectedId;
}
@Override protected boolean matchesSafely(final ImageView imageView) {
final Drawable drawable = imageView.getDrawable(); | return drawableMatches(imageView, drawable, expectedId); |
vanniktech/espresso-utils | espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/ColorChecker.java | // Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// @NonNull static <T> T checkNotNull(@Nullable final T reference, final String message) {
// if (reference == null) {
// throw new IllegalArgumentException(message);
// }
//
// return reference;
// }
| import android.content.Context;
import androidx.annotation.CheckResult;
import androidx.annotation.ColorInt;
import androidx.annotation.ColorRes;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import static com.vanniktech.espresso.core.utils.Utils.checkNotNull; | package com.vanniktech.espresso.core.utils;
final class ColorChecker {
@CheckResult static ColorChecker fromRes(@ColorRes final int colorRes) {
final ColorChecker matcher = new ColorChecker();
matcher.colorRes = colorRes;
return matcher;
}
@CheckResult static ColorChecker from(@ColorInt final int color) {
final ColorChecker matcher = new ColorChecker();
matcher.colorInt = color;
return matcher;
}
@Nullable @ColorRes private Integer colorRes;
@Nullable @ColorInt private Integer colorInt;
private ColorChecker() {
}
boolean matches(final int color, final Context context) {
if (colorInt != null) {
return color == colorInt;
}
| // Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// @NonNull static <T> T checkNotNull(@Nullable final T reference, final String message) {
// if (reference == null) {
// throw new IllegalArgumentException(message);
// }
//
// return reference;
// }
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/ColorChecker.java
import android.content.Context;
import androidx.annotation.CheckResult;
import androidx.annotation.ColorInt;
import androidx.annotation.ColorRes;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import static com.vanniktech.espresso.core.utils.Utils.checkNotNull;
package com.vanniktech.espresso.core.utils;
final class ColorChecker {
@CheckResult static ColorChecker fromRes(@ColorRes final int colorRes) {
final ColorChecker matcher = new ColorChecker();
matcher.colorRes = colorRes;
return matcher;
}
@CheckResult static ColorChecker from(@ColorInt final int color) {
final ColorChecker matcher = new ColorChecker();
matcher.colorInt = color;
return matcher;
}
@Nullable @ColorRes private Integer colorRes;
@Nullable @ColorInt private Integer colorInt;
private ColorChecker() {
}
boolean matches(final int color, final Context context) {
if (colorInt != null) {
return color == colorInt;
}
| return color == ContextCompat.getColor(context, checkNotNull(colorRes, "colorRes == null")); |
vanniktech/espresso-utils | espresso-core-utils/src/test/java/com/vanniktech/espresso/core/utils/TextViewDrawableMatcherTypeTest.java | // Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/TextViewDrawableMatcher.java
// enum Type {
// DRAWABLE_LEFT(INDEX_LEFT, false, "left"),
// DRAWABLE_RELATIVE_LEFT(INDEX_LEFT, true, "relative left"),
// DRAWABLE_TOP(INDEX_TOP, false, "top"),
// DRAWABLE_RELATIVE_TOP(INDEX_TOP, true, "relative top"),
// DRAWABLE_RIGHT(INDEX_RIGHT, false, "right"),
// DRAWABLE_RELATIVE_RIGHT(INDEX_RIGHT, true, "relative right"),
// DRAWABLE_BOTTOM(INDEX_BOTTOM, false, "bottom"),
// DRAWABLE_RELATIVE_BOTTOM(INDEX_BOTTOM, true, "relative bottom");
//
// private final int index;
// private final boolean isRelative;
// final String string;
//
// Type(final int index, final boolean isRelative, final String string) {
// this.index = index;
// this.isRelative = isRelative;
// this.string = string;
// }
//
// @SuppressLint("NewApi") public Drawable getDrawable(final TextView textView) {
// final Drawable[] drawables = isRelative ? textView.getCompoundDrawablesRelative() : textView.getCompoundDrawables();
// return drawables[index];
// }
// }
| import com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type;
import org.junit.Test;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_BOTTOM;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_LEFT;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_RELATIVE_BOTTOM;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_RELATIVE_LEFT;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_RELATIVE_RIGHT;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_RELATIVE_TOP;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_RIGHT;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_TOP;
import static org.assertj.core.api.Java6Assertions.assertThat; | package com.vanniktech.espresso.core.utils;
public final class TextViewDrawableMatcherTypeTest {
@Test public void entries() { | // Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/TextViewDrawableMatcher.java
// enum Type {
// DRAWABLE_LEFT(INDEX_LEFT, false, "left"),
// DRAWABLE_RELATIVE_LEFT(INDEX_LEFT, true, "relative left"),
// DRAWABLE_TOP(INDEX_TOP, false, "top"),
// DRAWABLE_RELATIVE_TOP(INDEX_TOP, true, "relative top"),
// DRAWABLE_RIGHT(INDEX_RIGHT, false, "right"),
// DRAWABLE_RELATIVE_RIGHT(INDEX_RIGHT, true, "relative right"),
// DRAWABLE_BOTTOM(INDEX_BOTTOM, false, "bottom"),
// DRAWABLE_RELATIVE_BOTTOM(INDEX_BOTTOM, true, "relative bottom");
//
// private final int index;
// private final boolean isRelative;
// final String string;
//
// Type(final int index, final boolean isRelative, final String string) {
// this.index = index;
// this.isRelative = isRelative;
// this.string = string;
// }
//
// @SuppressLint("NewApi") public Drawable getDrawable(final TextView textView) {
// final Drawable[] drawables = isRelative ? textView.getCompoundDrawablesRelative() : textView.getCompoundDrawables();
// return drawables[index];
// }
// }
// Path: espresso-core-utils/src/test/java/com/vanniktech/espresso/core/utils/TextViewDrawableMatcherTypeTest.java
import com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type;
import org.junit.Test;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_BOTTOM;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_LEFT;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_RELATIVE_BOTTOM;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_RELATIVE_LEFT;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_RELATIVE_RIGHT;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_RELATIVE_TOP;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_RIGHT;
import static com.vanniktech.espresso.core.utils.TextViewDrawableMatcher.Type.DRAWABLE_TOP;
import static org.assertj.core.api.Java6Assertions.assertThat;
package com.vanniktech.espresso.core.utils;
public final class TextViewDrawableMatcherTypeTest {
@Test public void entries() { | assertThat(Type.values()).containsExactly( |
vanniktech/espresso-utils | espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java | // Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static int resolveAttribute(final View view, @AttrRes final int attr) {
// final TypedValue value = new TypedValue();
// view.getContext().getTheme().resolveAttribute(attr, value, true);
// return value.data;
// }
| import android.graphics.Color;
import androidx.annotation.AttrRes;
import androidx.annotation.CheckResult;
import androidx.annotation.ColorInt;
import androidx.annotation.ColorRes;
import androidx.annotation.Nullable;
import androidx.test.espresso.matcher.BoundedMatcher;
import android.view.View;
import android.widget.TextView;
import org.hamcrest.Description;
import static com.vanniktech.espresso.core.utils.Utils.resolveAttribute; | * <p>Example usage:</p>
* <code>onView(withId(R.id.view)).check(matches(withColorButtonNormal(RED)));</code>
*/
@CheckResult public static AttributeMatcher withColorButtonNormal(@ColorInt final int color) {
return new AttributeMatcher(R.attr.colorButtonNormal, "colorButtonNormal", ColorChecker.from(color));
}
/**
* Matches that the button color has the expected color.
*
* <p>Example usage:</p>
* <code>onView(withId(R.id.view)).check(matches(withColorButtonNormal("#ff0000")));</code>
*/
@CheckResult public static AttributeMatcher withColorButtonNormal(final String color) {
return withColorButtonNormal(Color.parseColor(color));
}
@AttrRes private final int attr;
@Nullable private final String name;
private final ColorChecker colorChecker;
private AttributeMatcher(final int attr, @Nullable final String name, final ColorChecker colorChecker) {
super(TextView.class);
this.name = name;
this.colorChecker = colorChecker;
this.attr = attr;
}
@Override protected boolean matchesSafely(final TextView item) { | // Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/Utils.java
// static int resolveAttribute(final View view, @AttrRes final int attr) {
// final TypedValue value = new TypedValue();
// view.getContext().getTheme().resolveAttribute(attr, value, true);
// return value.data;
// }
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
import android.graphics.Color;
import androidx.annotation.AttrRes;
import androidx.annotation.CheckResult;
import androidx.annotation.ColorInt;
import androidx.annotation.ColorRes;
import androidx.annotation.Nullable;
import androidx.test.espresso.matcher.BoundedMatcher;
import android.view.View;
import android.widget.TextView;
import org.hamcrest.Description;
import static com.vanniktech.espresso.core.utils.Utils.resolveAttribute;
* <p>Example usage:</p>
* <code>onView(withId(R.id.view)).check(matches(withColorButtonNormal(RED)));</code>
*/
@CheckResult public static AttributeMatcher withColorButtonNormal(@ColorInt final int color) {
return new AttributeMatcher(R.attr.colorButtonNormal, "colorButtonNormal", ColorChecker.from(color));
}
/**
* Matches that the button color has the expected color.
*
* <p>Example usage:</p>
* <code>onView(withId(R.id.view)).check(matches(withColorButtonNormal("#ff0000")));</code>
*/
@CheckResult public static AttributeMatcher withColorButtonNormal(final String color) {
return withColorButtonNormal(Color.parseColor(color));
}
@AttrRes private final int attr;
@Nullable private final String name;
private final ColorChecker colorChecker;
private AttributeMatcher(final int attr, @Nullable final String name, final ColorChecker colorChecker) {
super(TextView.class);
this.name = name;
this.colorChecker = colorChecker;
this.attr = attr;
}
@Override protected boolean matchesSafely(final TextView item) { | final int color = resolveAttribute(item, attr); |
vanniktech/espresso-utils | espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/AttributeMatcherTest.java | // Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withAttr(@AttrRes final int attr, @ColorInt final int color) {
// return new AttributeMatcher(attr, null, ColorChecker.from(color));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withAttrRes(@AttrRes final int attr, @ColorRes final int colorRes) {
// return new AttributeMatcher(attr, null, ColorChecker.fromRes(colorRes));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withColorAccent(@ColorInt final int color) {
// return new AttributeMatcher(R.attr.colorAccent, "colorAccent", ColorChecker.from(color));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withColorAccentRes(@ColorRes final int colorRes) {
// return new AttributeMatcher(R.attr.colorAccent, "colorAccent", ColorChecker.fromRes(colorRes));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withColorButtonNormal(@ColorInt final int color) {
// return new AttributeMatcher(R.attr.colorButtonNormal, "colorButtonNormal", ColorChecker.from(color));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withColorButtonNormalRes(@ColorRes final int colorRes) {
// return new AttributeMatcher(R.attr.colorButtonNormal, "colorButtonNormal", ColorChecker.fromRes(colorRes));
// }
//
// Path: espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/AttributeMatcherActivity.java
// static final int VIEW_ID = 1234;
| import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.rule.ActivityTestRule;
import com.vanniktech.espresso.core.utils.test.R;
import junit.framework.AssertionFailedError;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import static android.graphics.Color.BLUE;
import static android.graphics.Color.GREEN;
import static android.graphics.Color.RED;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withAttr;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withAttrRes;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withColorAccent;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withColorAccentRes;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withColorButtonNormal;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withColorButtonNormalRes;
import static com.vanniktech.espresso.core.utils.AttributeMatcherActivity.VIEW_ID; | package com.vanniktech.espresso.core.utils;
@RunWith(AndroidJUnit4.class) public final class AttributeMatcherTest {
@Rule public final ExpectedException expectedException = ExpectedException.none();
@Rule public final ActivityTestRule<AttributeMatcherActivity> activityTestRule = new ActivityTestRule<>(AttributeMatcherActivity.class);
@Test public void withAttrResMatches() { | // Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withAttr(@AttrRes final int attr, @ColorInt final int color) {
// return new AttributeMatcher(attr, null, ColorChecker.from(color));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withAttrRes(@AttrRes final int attr, @ColorRes final int colorRes) {
// return new AttributeMatcher(attr, null, ColorChecker.fromRes(colorRes));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withColorAccent(@ColorInt final int color) {
// return new AttributeMatcher(R.attr.colorAccent, "colorAccent", ColorChecker.from(color));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withColorAccentRes(@ColorRes final int colorRes) {
// return new AttributeMatcher(R.attr.colorAccent, "colorAccent", ColorChecker.fromRes(colorRes));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withColorButtonNormal(@ColorInt final int color) {
// return new AttributeMatcher(R.attr.colorButtonNormal, "colorButtonNormal", ColorChecker.from(color));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withColorButtonNormalRes(@ColorRes final int colorRes) {
// return new AttributeMatcher(R.attr.colorButtonNormal, "colorButtonNormal", ColorChecker.fromRes(colorRes));
// }
//
// Path: espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/AttributeMatcherActivity.java
// static final int VIEW_ID = 1234;
// Path: espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/AttributeMatcherTest.java
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.rule.ActivityTestRule;
import com.vanniktech.espresso.core.utils.test.R;
import junit.framework.AssertionFailedError;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import static android.graphics.Color.BLUE;
import static android.graphics.Color.GREEN;
import static android.graphics.Color.RED;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withAttr;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withAttrRes;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withColorAccent;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withColorAccentRes;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withColorButtonNormal;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withColorButtonNormalRes;
import static com.vanniktech.espresso.core.utils.AttributeMatcherActivity.VIEW_ID;
package com.vanniktech.espresso.core.utils;
@RunWith(AndroidJUnit4.class) public final class AttributeMatcherTest {
@Rule public final ExpectedException expectedException = ExpectedException.none();
@Rule public final ActivityTestRule<AttributeMatcherActivity> activityTestRule = new ActivityTestRule<>(AttributeMatcherActivity.class);
@Test public void withAttrResMatches() { | onView(withId(VIEW_ID)).check(matches(withAttrRes(R.attr.colorError, R.color.blue))); |
vanniktech/espresso-utils | espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/AttributeMatcherTest.java | // Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withAttr(@AttrRes final int attr, @ColorInt final int color) {
// return new AttributeMatcher(attr, null, ColorChecker.from(color));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withAttrRes(@AttrRes final int attr, @ColorRes final int colorRes) {
// return new AttributeMatcher(attr, null, ColorChecker.fromRes(colorRes));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withColorAccent(@ColorInt final int color) {
// return new AttributeMatcher(R.attr.colorAccent, "colorAccent", ColorChecker.from(color));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withColorAccentRes(@ColorRes final int colorRes) {
// return new AttributeMatcher(R.attr.colorAccent, "colorAccent", ColorChecker.fromRes(colorRes));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withColorButtonNormal(@ColorInt final int color) {
// return new AttributeMatcher(R.attr.colorButtonNormal, "colorButtonNormal", ColorChecker.from(color));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withColorButtonNormalRes(@ColorRes final int colorRes) {
// return new AttributeMatcher(R.attr.colorButtonNormal, "colorButtonNormal", ColorChecker.fromRes(colorRes));
// }
//
// Path: espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/AttributeMatcherActivity.java
// static final int VIEW_ID = 1234;
| import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.rule.ActivityTestRule;
import com.vanniktech.espresso.core.utils.test.R;
import junit.framework.AssertionFailedError;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import static android.graphics.Color.BLUE;
import static android.graphics.Color.GREEN;
import static android.graphics.Color.RED;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withAttr;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withAttrRes;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withColorAccent;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withColorAccentRes;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withColorButtonNormal;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withColorButtonNormalRes;
import static com.vanniktech.espresso.core.utils.AttributeMatcherActivity.VIEW_ID; | package com.vanniktech.espresso.core.utils;
@RunWith(AndroidJUnit4.class) public final class AttributeMatcherTest {
@Rule public final ExpectedException expectedException = ExpectedException.none();
@Rule public final ActivityTestRule<AttributeMatcherActivity> activityTestRule = new ActivityTestRule<>(AttributeMatcherActivity.class);
@Test public void withAttrResMatches() { | // Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withAttr(@AttrRes final int attr, @ColorInt final int color) {
// return new AttributeMatcher(attr, null, ColorChecker.from(color));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withAttrRes(@AttrRes final int attr, @ColorRes final int colorRes) {
// return new AttributeMatcher(attr, null, ColorChecker.fromRes(colorRes));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withColorAccent(@ColorInt final int color) {
// return new AttributeMatcher(R.attr.colorAccent, "colorAccent", ColorChecker.from(color));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withColorAccentRes(@ColorRes final int colorRes) {
// return new AttributeMatcher(R.attr.colorAccent, "colorAccent", ColorChecker.fromRes(colorRes));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withColorButtonNormal(@ColorInt final int color) {
// return new AttributeMatcher(R.attr.colorButtonNormal, "colorButtonNormal", ColorChecker.from(color));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withColorButtonNormalRes(@ColorRes final int colorRes) {
// return new AttributeMatcher(R.attr.colorButtonNormal, "colorButtonNormal", ColorChecker.fromRes(colorRes));
// }
//
// Path: espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/AttributeMatcherActivity.java
// static final int VIEW_ID = 1234;
// Path: espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/AttributeMatcherTest.java
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.rule.ActivityTestRule;
import com.vanniktech.espresso.core.utils.test.R;
import junit.framework.AssertionFailedError;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import static android.graphics.Color.BLUE;
import static android.graphics.Color.GREEN;
import static android.graphics.Color.RED;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withAttr;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withAttrRes;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withColorAccent;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withColorAccentRes;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withColorButtonNormal;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withColorButtonNormalRes;
import static com.vanniktech.espresso.core.utils.AttributeMatcherActivity.VIEW_ID;
package com.vanniktech.espresso.core.utils;
@RunWith(AndroidJUnit4.class) public final class AttributeMatcherTest {
@Rule public final ExpectedException expectedException = ExpectedException.none();
@Rule public final ActivityTestRule<AttributeMatcherActivity> activityTestRule = new ActivityTestRule<>(AttributeMatcherActivity.class);
@Test public void withAttrResMatches() { | onView(withId(VIEW_ID)).check(matches(withAttrRes(R.attr.colorError, R.color.blue))); |
vanniktech/espresso-utils | espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/AttributeMatcherTest.java | // Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withAttr(@AttrRes final int attr, @ColorInt final int color) {
// return new AttributeMatcher(attr, null, ColorChecker.from(color));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withAttrRes(@AttrRes final int attr, @ColorRes final int colorRes) {
// return new AttributeMatcher(attr, null, ColorChecker.fromRes(colorRes));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withColorAccent(@ColorInt final int color) {
// return new AttributeMatcher(R.attr.colorAccent, "colorAccent", ColorChecker.from(color));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withColorAccentRes(@ColorRes final int colorRes) {
// return new AttributeMatcher(R.attr.colorAccent, "colorAccent", ColorChecker.fromRes(colorRes));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withColorButtonNormal(@ColorInt final int color) {
// return new AttributeMatcher(R.attr.colorButtonNormal, "colorButtonNormal", ColorChecker.from(color));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withColorButtonNormalRes(@ColorRes final int colorRes) {
// return new AttributeMatcher(R.attr.colorButtonNormal, "colorButtonNormal", ColorChecker.fromRes(colorRes));
// }
//
// Path: espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/AttributeMatcherActivity.java
// static final int VIEW_ID = 1234;
| import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.rule.ActivityTestRule;
import com.vanniktech.espresso.core.utils.test.R;
import junit.framework.AssertionFailedError;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import static android.graphics.Color.BLUE;
import static android.graphics.Color.GREEN;
import static android.graphics.Color.RED;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withAttr;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withAttrRes;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withColorAccent;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withColorAccentRes;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withColorButtonNormal;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withColorButtonNormalRes;
import static com.vanniktech.espresso.core.utils.AttributeMatcherActivity.VIEW_ID; | package com.vanniktech.espresso.core.utils;
@RunWith(AndroidJUnit4.class) public final class AttributeMatcherTest {
@Rule public final ExpectedException expectedException = ExpectedException.none();
@Rule public final ActivityTestRule<AttributeMatcherActivity> activityTestRule = new ActivityTestRule<>(AttributeMatcherActivity.class);
@Test public void withAttrResMatches() {
onView(withId(VIEW_ID)).check(matches(withAttrRes(R.attr.colorError, R.color.blue)));
}
@Test public void withAttrMatches() { | // Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withAttr(@AttrRes final int attr, @ColorInt final int color) {
// return new AttributeMatcher(attr, null, ColorChecker.from(color));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withAttrRes(@AttrRes final int attr, @ColorRes final int colorRes) {
// return new AttributeMatcher(attr, null, ColorChecker.fromRes(colorRes));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withColorAccent(@ColorInt final int color) {
// return new AttributeMatcher(R.attr.colorAccent, "colorAccent", ColorChecker.from(color));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withColorAccentRes(@ColorRes final int colorRes) {
// return new AttributeMatcher(R.attr.colorAccent, "colorAccent", ColorChecker.fromRes(colorRes));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withColorButtonNormal(@ColorInt final int color) {
// return new AttributeMatcher(R.attr.colorButtonNormal, "colorButtonNormal", ColorChecker.from(color));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withColorButtonNormalRes(@ColorRes final int colorRes) {
// return new AttributeMatcher(R.attr.colorButtonNormal, "colorButtonNormal", ColorChecker.fromRes(colorRes));
// }
//
// Path: espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/AttributeMatcherActivity.java
// static final int VIEW_ID = 1234;
// Path: espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/AttributeMatcherTest.java
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.rule.ActivityTestRule;
import com.vanniktech.espresso.core.utils.test.R;
import junit.framework.AssertionFailedError;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import static android.graphics.Color.BLUE;
import static android.graphics.Color.GREEN;
import static android.graphics.Color.RED;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withAttr;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withAttrRes;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withColorAccent;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withColorAccentRes;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withColorButtonNormal;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withColorButtonNormalRes;
import static com.vanniktech.espresso.core.utils.AttributeMatcherActivity.VIEW_ID;
package com.vanniktech.espresso.core.utils;
@RunWith(AndroidJUnit4.class) public final class AttributeMatcherTest {
@Rule public final ExpectedException expectedException = ExpectedException.none();
@Rule public final ActivityTestRule<AttributeMatcherActivity> activityTestRule = new ActivityTestRule<>(AttributeMatcherActivity.class);
@Test public void withAttrResMatches() {
onView(withId(VIEW_ID)).check(matches(withAttrRes(R.attr.colorError, R.color.blue)));
}
@Test public void withAttrMatches() { | onView(withId(VIEW_ID)).check(matches(withAttr(R.attr.colorError, BLUE))); |
vanniktech/espresso-utils | espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/AttributeMatcherTest.java | // Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withAttr(@AttrRes final int attr, @ColorInt final int color) {
// return new AttributeMatcher(attr, null, ColorChecker.from(color));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withAttrRes(@AttrRes final int attr, @ColorRes final int colorRes) {
// return new AttributeMatcher(attr, null, ColorChecker.fromRes(colorRes));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withColorAccent(@ColorInt final int color) {
// return new AttributeMatcher(R.attr.colorAccent, "colorAccent", ColorChecker.from(color));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withColorAccentRes(@ColorRes final int colorRes) {
// return new AttributeMatcher(R.attr.colorAccent, "colorAccent", ColorChecker.fromRes(colorRes));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withColorButtonNormal(@ColorInt final int color) {
// return new AttributeMatcher(R.attr.colorButtonNormal, "colorButtonNormal", ColorChecker.from(color));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withColorButtonNormalRes(@ColorRes final int colorRes) {
// return new AttributeMatcher(R.attr.colorButtonNormal, "colorButtonNormal", ColorChecker.fromRes(colorRes));
// }
//
// Path: espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/AttributeMatcherActivity.java
// static final int VIEW_ID = 1234;
| import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.rule.ActivityTestRule;
import com.vanniktech.espresso.core.utils.test.R;
import junit.framework.AssertionFailedError;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import static android.graphics.Color.BLUE;
import static android.graphics.Color.GREEN;
import static android.graphics.Color.RED;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withAttr;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withAttrRes;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withColorAccent;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withColorAccentRes;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withColorButtonNormal;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withColorButtonNormalRes;
import static com.vanniktech.espresso.core.utils.AttributeMatcherActivity.VIEW_ID; | package com.vanniktech.espresso.core.utils;
@RunWith(AndroidJUnit4.class) public final class AttributeMatcherTest {
@Rule public final ExpectedException expectedException = ExpectedException.none();
@Rule public final ActivityTestRule<AttributeMatcherActivity> activityTestRule = new ActivityTestRule<>(AttributeMatcherActivity.class);
@Test public void withAttrResMatches() {
onView(withId(VIEW_ID)).check(matches(withAttrRes(R.attr.colorError, R.color.blue)));
}
@Test public void withAttrMatches() {
onView(withId(VIEW_ID)).check(matches(withAttr(R.attr.colorError, BLUE)));
}
@Test public void withAttrStringMatches() {
onView(withId(VIEW_ID)).check(matches(withAttr(R.attr.colorError, "#0000ff")));
}
@Test public void withAttrResDoesNotMatch() {
expectedException.expect(AssertionFailedError.class);
expectedException.expectMessage("'with " + R.attr.colorError + ": ' doesn't match the selected view.");
onView(withId(VIEW_ID)).check(matches(withAttrRes(R.attr.colorError, R.color.red)));
}
@Test public void withAttrDoesNotMatch() {
expectedException.expect(AssertionFailedError.class);
expectedException.expectMessage("'with " + R.attr.colorError + ": ' doesn't match the selected view.");
onView(withId(VIEW_ID)).check(matches(withAttr(R.attr.colorError, RED)));
}
@Test public void withAttrStringDoesNotMatch() {
expectedException.expect(AssertionFailedError.class);
expectedException.expectMessage("'with " + R.attr.colorError + ": ' doesn't match the selected view.");
onView(withId(VIEW_ID)).check(matches(withAttr(R.attr.colorError, "#ff0000")));
}
@Test public void withColorButtonNormalResMatches() { | // Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withAttr(@AttrRes final int attr, @ColorInt final int color) {
// return new AttributeMatcher(attr, null, ColorChecker.from(color));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withAttrRes(@AttrRes final int attr, @ColorRes final int colorRes) {
// return new AttributeMatcher(attr, null, ColorChecker.fromRes(colorRes));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withColorAccent(@ColorInt final int color) {
// return new AttributeMatcher(R.attr.colorAccent, "colorAccent", ColorChecker.from(color));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withColorAccentRes(@ColorRes final int colorRes) {
// return new AttributeMatcher(R.attr.colorAccent, "colorAccent", ColorChecker.fromRes(colorRes));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withColorButtonNormal(@ColorInt final int color) {
// return new AttributeMatcher(R.attr.colorButtonNormal, "colorButtonNormal", ColorChecker.from(color));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withColorButtonNormalRes(@ColorRes final int colorRes) {
// return new AttributeMatcher(R.attr.colorButtonNormal, "colorButtonNormal", ColorChecker.fromRes(colorRes));
// }
//
// Path: espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/AttributeMatcherActivity.java
// static final int VIEW_ID = 1234;
// Path: espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/AttributeMatcherTest.java
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.rule.ActivityTestRule;
import com.vanniktech.espresso.core.utils.test.R;
import junit.framework.AssertionFailedError;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import static android.graphics.Color.BLUE;
import static android.graphics.Color.GREEN;
import static android.graphics.Color.RED;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withAttr;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withAttrRes;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withColorAccent;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withColorAccentRes;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withColorButtonNormal;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withColorButtonNormalRes;
import static com.vanniktech.espresso.core.utils.AttributeMatcherActivity.VIEW_ID;
package com.vanniktech.espresso.core.utils;
@RunWith(AndroidJUnit4.class) public final class AttributeMatcherTest {
@Rule public final ExpectedException expectedException = ExpectedException.none();
@Rule public final ActivityTestRule<AttributeMatcherActivity> activityTestRule = new ActivityTestRule<>(AttributeMatcherActivity.class);
@Test public void withAttrResMatches() {
onView(withId(VIEW_ID)).check(matches(withAttrRes(R.attr.colorError, R.color.blue)));
}
@Test public void withAttrMatches() {
onView(withId(VIEW_ID)).check(matches(withAttr(R.attr.colorError, BLUE)));
}
@Test public void withAttrStringMatches() {
onView(withId(VIEW_ID)).check(matches(withAttr(R.attr.colorError, "#0000ff")));
}
@Test public void withAttrResDoesNotMatch() {
expectedException.expect(AssertionFailedError.class);
expectedException.expectMessage("'with " + R.attr.colorError + ": ' doesn't match the selected view.");
onView(withId(VIEW_ID)).check(matches(withAttrRes(R.attr.colorError, R.color.red)));
}
@Test public void withAttrDoesNotMatch() {
expectedException.expect(AssertionFailedError.class);
expectedException.expectMessage("'with " + R.attr.colorError + ": ' doesn't match the selected view.");
onView(withId(VIEW_ID)).check(matches(withAttr(R.attr.colorError, RED)));
}
@Test public void withAttrStringDoesNotMatch() {
expectedException.expect(AssertionFailedError.class);
expectedException.expectMessage("'with " + R.attr.colorError + ": ' doesn't match the selected view.");
onView(withId(VIEW_ID)).check(matches(withAttr(R.attr.colorError, "#ff0000")));
}
@Test public void withColorButtonNormalResMatches() { | onView(withId(VIEW_ID)).check(matches(withColorButtonNormalRes(R.color.red))); |
vanniktech/espresso-utils | espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/AttributeMatcherTest.java | // Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withAttr(@AttrRes final int attr, @ColorInt final int color) {
// return new AttributeMatcher(attr, null, ColorChecker.from(color));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withAttrRes(@AttrRes final int attr, @ColorRes final int colorRes) {
// return new AttributeMatcher(attr, null, ColorChecker.fromRes(colorRes));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withColorAccent(@ColorInt final int color) {
// return new AttributeMatcher(R.attr.colorAccent, "colorAccent", ColorChecker.from(color));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withColorAccentRes(@ColorRes final int colorRes) {
// return new AttributeMatcher(R.attr.colorAccent, "colorAccent", ColorChecker.fromRes(colorRes));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withColorButtonNormal(@ColorInt final int color) {
// return new AttributeMatcher(R.attr.colorButtonNormal, "colorButtonNormal", ColorChecker.from(color));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withColorButtonNormalRes(@ColorRes final int colorRes) {
// return new AttributeMatcher(R.attr.colorButtonNormal, "colorButtonNormal", ColorChecker.fromRes(colorRes));
// }
//
// Path: espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/AttributeMatcherActivity.java
// static final int VIEW_ID = 1234;
| import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.rule.ActivityTestRule;
import com.vanniktech.espresso.core.utils.test.R;
import junit.framework.AssertionFailedError;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import static android.graphics.Color.BLUE;
import static android.graphics.Color.GREEN;
import static android.graphics.Color.RED;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withAttr;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withAttrRes;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withColorAccent;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withColorAccentRes;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withColorButtonNormal;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withColorButtonNormalRes;
import static com.vanniktech.espresso.core.utils.AttributeMatcherActivity.VIEW_ID; | onView(withId(VIEW_ID)).check(matches(withAttr(R.attr.colorError, BLUE)));
}
@Test public void withAttrStringMatches() {
onView(withId(VIEW_ID)).check(matches(withAttr(R.attr.colorError, "#0000ff")));
}
@Test public void withAttrResDoesNotMatch() {
expectedException.expect(AssertionFailedError.class);
expectedException.expectMessage("'with " + R.attr.colorError + ": ' doesn't match the selected view.");
onView(withId(VIEW_ID)).check(matches(withAttrRes(R.attr.colorError, R.color.red)));
}
@Test public void withAttrDoesNotMatch() {
expectedException.expect(AssertionFailedError.class);
expectedException.expectMessage("'with " + R.attr.colorError + ": ' doesn't match the selected view.");
onView(withId(VIEW_ID)).check(matches(withAttr(R.attr.colorError, RED)));
}
@Test public void withAttrStringDoesNotMatch() {
expectedException.expect(AssertionFailedError.class);
expectedException.expectMessage("'with " + R.attr.colorError + ": ' doesn't match the selected view.");
onView(withId(VIEW_ID)).check(matches(withAttr(R.attr.colorError, "#ff0000")));
}
@Test public void withColorButtonNormalResMatches() {
onView(withId(VIEW_ID)).check(matches(withColorButtonNormalRes(R.color.red)));
}
@Test public void withColorButtonNormalMatches() { | // Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withAttr(@AttrRes final int attr, @ColorInt final int color) {
// return new AttributeMatcher(attr, null, ColorChecker.from(color));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withAttrRes(@AttrRes final int attr, @ColorRes final int colorRes) {
// return new AttributeMatcher(attr, null, ColorChecker.fromRes(colorRes));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withColorAccent(@ColorInt final int color) {
// return new AttributeMatcher(R.attr.colorAccent, "colorAccent", ColorChecker.from(color));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withColorAccentRes(@ColorRes final int colorRes) {
// return new AttributeMatcher(R.attr.colorAccent, "colorAccent", ColorChecker.fromRes(colorRes));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withColorButtonNormal(@ColorInt final int color) {
// return new AttributeMatcher(R.attr.colorButtonNormal, "colorButtonNormal", ColorChecker.from(color));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withColorButtonNormalRes(@ColorRes final int colorRes) {
// return new AttributeMatcher(R.attr.colorButtonNormal, "colorButtonNormal", ColorChecker.fromRes(colorRes));
// }
//
// Path: espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/AttributeMatcherActivity.java
// static final int VIEW_ID = 1234;
// Path: espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/AttributeMatcherTest.java
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.rule.ActivityTestRule;
import com.vanniktech.espresso.core.utils.test.R;
import junit.framework.AssertionFailedError;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import static android.graphics.Color.BLUE;
import static android.graphics.Color.GREEN;
import static android.graphics.Color.RED;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withAttr;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withAttrRes;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withColorAccent;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withColorAccentRes;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withColorButtonNormal;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withColorButtonNormalRes;
import static com.vanniktech.espresso.core.utils.AttributeMatcherActivity.VIEW_ID;
onView(withId(VIEW_ID)).check(matches(withAttr(R.attr.colorError, BLUE)));
}
@Test public void withAttrStringMatches() {
onView(withId(VIEW_ID)).check(matches(withAttr(R.attr.colorError, "#0000ff")));
}
@Test public void withAttrResDoesNotMatch() {
expectedException.expect(AssertionFailedError.class);
expectedException.expectMessage("'with " + R.attr.colorError + ": ' doesn't match the selected view.");
onView(withId(VIEW_ID)).check(matches(withAttrRes(R.attr.colorError, R.color.red)));
}
@Test public void withAttrDoesNotMatch() {
expectedException.expect(AssertionFailedError.class);
expectedException.expectMessage("'with " + R.attr.colorError + ": ' doesn't match the selected view.");
onView(withId(VIEW_ID)).check(matches(withAttr(R.attr.colorError, RED)));
}
@Test public void withAttrStringDoesNotMatch() {
expectedException.expect(AssertionFailedError.class);
expectedException.expectMessage("'with " + R.attr.colorError + ": ' doesn't match the selected view.");
onView(withId(VIEW_ID)).check(matches(withAttr(R.attr.colorError, "#ff0000")));
}
@Test public void withColorButtonNormalResMatches() {
onView(withId(VIEW_ID)).check(matches(withColorButtonNormalRes(R.color.red)));
}
@Test public void withColorButtonNormalMatches() { | onView(withId(VIEW_ID)).check(matches(withColorButtonNormal(RED))); |
vanniktech/espresso-utils | espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/AttributeMatcherTest.java | // Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withAttr(@AttrRes final int attr, @ColorInt final int color) {
// return new AttributeMatcher(attr, null, ColorChecker.from(color));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withAttrRes(@AttrRes final int attr, @ColorRes final int colorRes) {
// return new AttributeMatcher(attr, null, ColorChecker.fromRes(colorRes));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withColorAccent(@ColorInt final int color) {
// return new AttributeMatcher(R.attr.colorAccent, "colorAccent", ColorChecker.from(color));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withColorAccentRes(@ColorRes final int colorRes) {
// return new AttributeMatcher(R.attr.colorAccent, "colorAccent", ColorChecker.fromRes(colorRes));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withColorButtonNormal(@ColorInt final int color) {
// return new AttributeMatcher(R.attr.colorButtonNormal, "colorButtonNormal", ColorChecker.from(color));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withColorButtonNormalRes(@ColorRes final int colorRes) {
// return new AttributeMatcher(R.attr.colorButtonNormal, "colorButtonNormal", ColorChecker.fromRes(colorRes));
// }
//
// Path: espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/AttributeMatcherActivity.java
// static final int VIEW_ID = 1234;
| import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.rule.ActivityTestRule;
import com.vanniktech.espresso.core.utils.test.R;
import junit.framework.AssertionFailedError;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import static android.graphics.Color.BLUE;
import static android.graphics.Color.GREEN;
import static android.graphics.Color.RED;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withAttr;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withAttrRes;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withColorAccent;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withColorAccentRes;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withColorButtonNormal;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withColorButtonNormalRes;
import static com.vanniktech.espresso.core.utils.AttributeMatcherActivity.VIEW_ID; | onView(withId(VIEW_ID)).check(matches(withColorButtonNormalRes(R.color.red)));
}
@Test public void withColorButtonNormalMatches() {
onView(withId(VIEW_ID)).check(matches(withColorButtonNormal(RED)));
}
@Test public void withColorButtonNormalStringMatches() {
onView(withId(VIEW_ID)).check(matches(withColorButtonNormal("#ff0000")));
}
@Test public void withColorButtonNormalResDoesNotMatch() {
expectedException.expect(AssertionFailedError.class);
expectedException.expectMessage("'with colorButtonNormal: ' doesn't match the selected view.");
onView(withId(VIEW_ID)).check(matches(withColorButtonNormalRes(R.color.green)));
}
@Test public void withColorButtonNormalDoesNotMatch() {
expectedException.expect(AssertionFailedError.class);
expectedException.expectMessage("'with colorButtonNormal: ' doesn't match the selected view.");
onView(withId(VIEW_ID)).check(matches(withColorButtonNormal(GREEN)));
}
@Test public void withColorButtonNormalStringDoesNotMatch() {
expectedException.expect(AssertionFailedError.class);
expectedException.expectMessage("'with colorButtonNormal: ' doesn't match the selected view.");
onView(withId(VIEW_ID)).check(matches(withColorButtonNormal("#00ff00")));
}
@Test public void withColorAccentResMatches() { | // Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withAttr(@AttrRes final int attr, @ColorInt final int color) {
// return new AttributeMatcher(attr, null, ColorChecker.from(color));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withAttrRes(@AttrRes final int attr, @ColorRes final int colorRes) {
// return new AttributeMatcher(attr, null, ColorChecker.fromRes(colorRes));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withColorAccent(@ColorInt final int color) {
// return new AttributeMatcher(R.attr.colorAccent, "colorAccent", ColorChecker.from(color));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withColorAccentRes(@ColorRes final int colorRes) {
// return new AttributeMatcher(R.attr.colorAccent, "colorAccent", ColorChecker.fromRes(colorRes));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withColorButtonNormal(@ColorInt final int color) {
// return new AttributeMatcher(R.attr.colorButtonNormal, "colorButtonNormal", ColorChecker.from(color));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withColorButtonNormalRes(@ColorRes final int colorRes) {
// return new AttributeMatcher(R.attr.colorButtonNormal, "colorButtonNormal", ColorChecker.fromRes(colorRes));
// }
//
// Path: espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/AttributeMatcherActivity.java
// static final int VIEW_ID = 1234;
// Path: espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/AttributeMatcherTest.java
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.rule.ActivityTestRule;
import com.vanniktech.espresso.core.utils.test.R;
import junit.framework.AssertionFailedError;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import static android.graphics.Color.BLUE;
import static android.graphics.Color.GREEN;
import static android.graphics.Color.RED;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withAttr;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withAttrRes;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withColorAccent;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withColorAccentRes;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withColorButtonNormal;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withColorButtonNormalRes;
import static com.vanniktech.espresso.core.utils.AttributeMatcherActivity.VIEW_ID;
onView(withId(VIEW_ID)).check(matches(withColorButtonNormalRes(R.color.red)));
}
@Test public void withColorButtonNormalMatches() {
onView(withId(VIEW_ID)).check(matches(withColorButtonNormal(RED)));
}
@Test public void withColorButtonNormalStringMatches() {
onView(withId(VIEW_ID)).check(matches(withColorButtonNormal("#ff0000")));
}
@Test public void withColorButtonNormalResDoesNotMatch() {
expectedException.expect(AssertionFailedError.class);
expectedException.expectMessage("'with colorButtonNormal: ' doesn't match the selected view.");
onView(withId(VIEW_ID)).check(matches(withColorButtonNormalRes(R.color.green)));
}
@Test public void withColorButtonNormalDoesNotMatch() {
expectedException.expect(AssertionFailedError.class);
expectedException.expectMessage("'with colorButtonNormal: ' doesn't match the selected view.");
onView(withId(VIEW_ID)).check(matches(withColorButtonNormal(GREEN)));
}
@Test public void withColorButtonNormalStringDoesNotMatch() {
expectedException.expect(AssertionFailedError.class);
expectedException.expectMessage("'with colorButtonNormal: ' doesn't match the selected view.");
onView(withId(VIEW_ID)).check(matches(withColorButtonNormal("#00ff00")));
}
@Test public void withColorAccentResMatches() { | onView(withId(VIEW_ID)).check(matches(withColorAccentRes(R.color.green))); |
vanniktech/espresso-utils | espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/AttributeMatcherTest.java | // Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withAttr(@AttrRes final int attr, @ColorInt final int color) {
// return new AttributeMatcher(attr, null, ColorChecker.from(color));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withAttrRes(@AttrRes final int attr, @ColorRes final int colorRes) {
// return new AttributeMatcher(attr, null, ColorChecker.fromRes(colorRes));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withColorAccent(@ColorInt final int color) {
// return new AttributeMatcher(R.attr.colorAccent, "colorAccent", ColorChecker.from(color));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withColorAccentRes(@ColorRes final int colorRes) {
// return new AttributeMatcher(R.attr.colorAccent, "colorAccent", ColorChecker.fromRes(colorRes));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withColorButtonNormal(@ColorInt final int color) {
// return new AttributeMatcher(R.attr.colorButtonNormal, "colorButtonNormal", ColorChecker.from(color));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withColorButtonNormalRes(@ColorRes final int colorRes) {
// return new AttributeMatcher(R.attr.colorButtonNormal, "colorButtonNormal", ColorChecker.fromRes(colorRes));
// }
//
// Path: espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/AttributeMatcherActivity.java
// static final int VIEW_ID = 1234;
| import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.rule.ActivityTestRule;
import com.vanniktech.espresso.core.utils.test.R;
import junit.framework.AssertionFailedError;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import static android.graphics.Color.BLUE;
import static android.graphics.Color.GREEN;
import static android.graphics.Color.RED;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withAttr;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withAttrRes;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withColorAccent;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withColorAccentRes;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withColorButtonNormal;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withColorButtonNormalRes;
import static com.vanniktech.espresso.core.utils.AttributeMatcherActivity.VIEW_ID; | onView(withId(VIEW_ID)).check(matches(withColorButtonNormal(RED)));
}
@Test public void withColorButtonNormalStringMatches() {
onView(withId(VIEW_ID)).check(matches(withColorButtonNormal("#ff0000")));
}
@Test public void withColorButtonNormalResDoesNotMatch() {
expectedException.expect(AssertionFailedError.class);
expectedException.expectMessage("'with colorButtonNormal: ' doesn't match the selected view.");
onView(withId(VIEW_ID)).check(matches(withColorButtonNormalRes(R.color.green)));
}
@Test public void withColorButtonNormalDoesNotMatch() {
expectedException.expect(AssertionFailedError.class);
expectedException.expectMessage("'with colorButtonNormal: ' doesn't match the selected view.");
onView(withId(VIEW_ID)).check(matches(withColorButtonNormal(GREEN)));
}
@Test public void withColorButtonNormalStringDoesNotMatch() {
expectedException.expect(AssertionFailedError.class);
expectedException.expectMessage("'with colorButtonNormal: ' doesn't match the selected view.");
onView(withId(VIEW_ID)).check(matches(withColorButtonNormal("#00ff00")));
}
@Test public void withColorAccentResMatches() {
onView(withId(VIEW_ID)).check(matches(withColorAccentRes(R.color.green)));
}
@Test public void withColorAccentMatches() { | // Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withAttr(@AttrRes final int attr, @ColorInt final int color) {
// return new AttributeMatcher(attr, null, ColorChecker.from(color));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withAttrRes(@AttrRes final int attr, @ColorRes final int colorRes) {
// return new AttributeMatcher(attr, null, ColorChecker.fromRes(colorRes));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withColorAccent(@ColorInt final int color) {
// return new AttributeMatcher(R.attr.colorAccent, "colorAccent", ColorChecker.from(color));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withColorAccentRes(@ColorRes final int colorRes) {
// return new AttributeMatcher(R.attr.colorAccent, "colorAccent", ColorChecker.fromRes(colorRes));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withColorButtonNormal(@ColorInt final int color) {
// return new AttributeMatcher(R.attr.colorButtonNormal, "colorButtonNormal", ColorChecker.from(color));
// }
//
// Path: espresso-core-utils/src/main/java/com/vanniktech/espresso/core/utils/AttributeMatcher.java
// @CheckResult public static AttributeMatcher withColorButtonNormalRes(@ColorRes final int colorRes) {
// return new AttributeMatcher(R.attr.colorButtonNormal, "colorButtonNormal", ColorChecker.fromRes(colorRes));
// }
//
// Path: espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/AttributeMatcherActivity.java
// static final int VIEW_ID = 1234;
// Path: espresso-core-utils/src/androidTest/java/com/vanniktech/espresso/core/utils/AttributeMatcherTest.java
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.rule.ActivityTestRule;
import com.vanniktech.espresso.core.utils.test.R;
import junit.framework.AssertionFailedError;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import static android.graphics.Color.BLUE;
import static android.graphics.Color.GREEN;
import static android.graphics.Color.RED;
import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.assertion.ViewAssertions.matches;
import static androidx.test.espresso.matcher.ViewMatchers.withId;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withAttr;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withAttrRes;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withColorAccent;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withColorAccentRes;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withColorButtonNormal;
import static com.vanniktech.espresso.core.utils.AttributeMatcher.withColorButtonNormalRes;
import static com.vanniktech.espresso.core.utils.AttributeMatcherActivity.VIEW_ID;
onView(withId(VIEW_ID)).check(matches(withColorButtonNormal(RED)));
}
@Test public void withColorButtonNormalStringMatches() {
onView(withId(VIEW_ID)).check(matches(withColorButtonNormal("#ff0000")));
}
@Test public void withColorButtonNormalResDoesNotMatch() {
expectedException.expect(AssertionFailedError.class);
expectedException.expectMessage("'with colorButtonNormal: ' doesn't match the selected view.");
onView(withId(VIEW_ID)).check(matches(withColorButtonNormalRes(R.color.green)));
}
@Test public void withColorButtonNormalDoesNotMatch() {
expectedException.expect(AssertionFailedError.class);
expectedException.expectMessage("'with colorButtonNormal: ' doesn't match the selected view.");
onView(withId(VIEW_ID)).check(matches(withColorButtonNormal(GREEN)));
}
@Test public void withColorButtonNormalStringDoesNotMatch() {
expectedException.expect(AssertionFailedError.class);
expectedException.expectMessage("'with colorButtonNormal: ' doesn't match the selected view.");
onView(withId(VIEW_ID)).check(matches(withColorButtonNormal("#00ff00")));
}
@Test public void withColorAccentResMatches() {
onView(withId(VIEW_ID)).check(matches(withColorAccentRes(R.color.green)));
}
@Test public void withColorAccentMatches() { | onView(withId(VIEW_ID)).check(matches(withColorAccent(GREEN))); |
frankjoshua/openjira | src/org/openjira/jira/ServerList.java | // Path: src/org/openjira/jira/model/JiraServer.java
// public class JiraServer {
//
// private int _id;
// private String name;
// private String url;
// private String user;
// private String password;
//
// public JiraServer(int _id, String name, String url, String user, String password) {
// super();
// this._id = _id;
// this.name = name;
// this.url = url;
// this.user = user;
// this.password = password;
// }
//
// public JiraServer(String name, String url, String user, String password) {
// super();
// this.name = name;
// this.url = url;
// this.user = user;
// this.password = password;
// }
//
// public int get_id() {
// return _id;
// }
//
// public void set_id(Integer id) {
// _id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getUrl() {
// return url;
// }
//
// public void setUrl(String url) {
// this.url = url;
// }
//
// public String getUser() {
// return user;
// }
//
// public void setUser(String user) {
// this.user = user;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// }
| import android.widget.ListView;
import java.util.ArrayList;
import org.openjira.jira.model.JiraServer;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter; | /*******************************************************************************
* Copyright 2012 Alexandre d'Alton
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/
package org.openjira.jira;
public class ServerList extends OJActivity implements OnItemClickListener {
// ****************** Main menu ID's ****************** //
private static final int MENU_NEW = 101;
private static final int MENU_PREFERENCES = 102;
// ****************** Context menu ID's ****************** //
private static final int CONTEXTMENU_DELETEITEM = ContextMenu.FIRST;
private static final int CONTEXTMENU_EDITITEM = ContextMenu.FIRST + 2;
// ****************** Activity return values ****************** //
private static final int ACTIVITY_ADD = 0;
private static final int ACTIVITY_EDIT = 1;
ListView lst; | // Path: src/org/openjira/jira/model/JiraServer.java
// public class JiraServer {
//
// private int _id;
// private String name;
// private String url;
// private String user;
// private String password;
//
// public JiraServer(int _id, String name, String url, String user, String password) {
// super();
// this._id = _id;
// this.name = name;
// this.url = url;
// this.user = user;
// this.password = password;
// }
//
// public JiraServer(String name, String url, String user, String password) {
// super();
// this.name = name;
// this.url = url;
// this.user = user;
// this.password = password;
// }
//
// public int get_id() {
// return _id;
// }
//
// public void set_id(Integer id) {
// _id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getUrl() {
// return url;
// }
//
// public void setUrl(String url) {
// this.url = url;
// }
//
// public String getUser() {
// return user;
// }
//
// public void setUser(String user) {
// this.user = user;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// }
// Path: src/org/openjira/jira/ServerList.java
import android.widget.ListView;
import java.util.ArrayList;
import org.openjira.jira.model.JiraServer;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
/*******************************************************************************
* Copyright 2012 Alexandre d'Alton
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/
package org.openjira.jira;
public class ServerList extends OJActivity implements OnItemClickListener {
// ****************** Main menu ID's ****************** //
private static final int MENU_NEW = 101;
private static final int MENU_PREFERENCES = 102;
// ****************** Context menu ID's ****************** //
private static final int CONTEXTMENU_DELETEITEM = ContextMenu.FIRST;
private static final int CONTEXTMENU_EDITITEM = ContextMenu.FIRST + 2;
// ****************** Activity return values ****************** //
private static final int ACTIVITY_ADD = 0;
private static final int ACTIVITY_EDIT = 1;
ListView lst; | ArrayList<JiraServer> servers; |
frankjoshua/openjira | src/org/openjira/jira/About.java | // Path: src/org/openjira/jira/model/JiraServerInfo.java
// public class JiraServerInfo {
// private String baseUrl;
// private String edition;
// private String buildNumber;
// private String buildDate;
// private String version;
//
// public static JiraServerInfo fromMap(Map<String, Object> map) {
// JiraServerInfo info = new JiraServerInfo();
// info.setBaseUrl((String) map.get("baseUrl"));
// info.setEdition((String) map.get("edition"));
// info.setBuildNumber((String) map.get("buildNumber"));
// info.setBuildDate((String) map.get("buildDate"));
// info.setVersion((String) map.get("version"));
// return info;
// }
//
// public String getBaseUrl() {
// return baseUrl;
// }
//
// public void setBaseUrl(String baseUrl) {
// this.baseUrl = baseUrl;
// }
//
// public String getEdition() {
// return edition;
// }
//
// public void setEdition(String edition) {
// this.edition = edition;
// }
//
// public String getBuildNumber() {
// return buildNumber;
// }
//
// public void setBuildNumber(String buildNumber) {
// this.buildNumber = buildNumber;
// }
//
// public String getBuildDate() {
// return buildDate;
// }
//
// public void setBuildDate(String buildDate) {
// this.buildDate = buildDate;
// }
//
// public String getVersion() {
// return version;
// }
//
// public void setVersion(String version) {
// this.version = version;
// }
//
// }
| import org.openjira.jira.model.JiraServerInfo;
import android.app.Activity;
import android.content.ComponentName;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Bundle;
import android.view.Window;
import android.widget.TextView; | /*******************************************************************************
* Copyright 2012 Alexandre d'Alton
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/
package org.openjira.jira;
public class About extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.about);
ComponentName comp = new ComponentName(this, this.getClass());
PackageInfo pinfo = null;
try {
pinfo = getPackageManager().getPackageInfo(comp.getPackageName(), 0);
} catch (NameNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
TextView tv = (TextView) findViewById(R.id.appversion);
tv.setText(getResources().getString(R.string.app_name) + " version " + (pinfo != null ? pinfo.versionName : ""));
| // Path: src/org/openjira/jira/model/JiraServerInfo.java
// public class JiraServerInfo {
// private String baseUrl;
// private String edition;
// private String buildNumber;
// private String buildDate;
// private String version;
//
// public static JiraServerInfo fromMap(Map<String, Object> map) {
// JiraServerInfo info = new JiraServerInfo();
// info.setBaseUrl((String) map.get("baseUrl"));
// info.setEdition((String) map.get("edition"));
// info.setBuildNumber((String) map.get("buildNumber"));
// info.setBuildDate((String) map.get("buildDate"));
// info.setVersion((String) map.get("version"));
// return info;
// }
//
// public String getBaseUrl() {
// return baseUrl;
// }
//
// public void setBaseUrl(String baseUrl) {
// this.baseUrl = baseUrl;
// }
//
// public String getEdition() {
// return edition;
// }
//
// public void setEdition(String edition) {
// this.edition = edition;
// }
//
// public String getBuildNumber() {
// return buildNumber;
// }
//
// public void setBuildNumber(String buildNumber) {
// this.buildNumber = buildNumber;
// }
//
// public String getBuildDate() {
// return buildDate;
// }
//
// public void setBuildDate(String buildDate) {
// this.buildDate = buildDate;
// }
//
// public String getVersion() {
// return version;
// }
//
// public void setVersion(String version) {
// this.version = version;
// }
//
// }
// Path: src/org/openjira/jira/About.java
import org.openjira.jira.model.JiraServerInfo;
import android.app.Activity;
import android.content.ComponentName;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;
import android.os.Bundle;
import android.view.Window;
import android.widget.TextView;
/*******************************************************************************
* Copyright 2012 Alexandre d'Alton
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/
package org.openjira.jira;
public class About extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.about);
ComponentName comp = new ComponentName(this, this.getClass());
PackageInfo pinfo = null;
try {
pinfo = getPackageManager().getPackageInfo(comp.getPackageName(), 0);
} catch (NameNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
TextView tv = (TextView) findViewById(R.id.appversion);
tv.setText(getResources().getString(R.string.app_name) + " version " + (pinfo != null ? pinfo.versionName : ""));
| JiraServerInfo info = JiraApp.get().getCurrentConnection().serverInfo; |
frankjoshua/openjira | src/org/xmlrpc/android/XMLRPCClient.java | // Path: src/org/openjira/jira/utils/ConnectionClient.java
// public class ConnectionClient extends DefaultHttpClient {
// public ConnectionClient(Credentials cred) {
// super();
// if (cred != null)
// setCredentials(cred);
// HttpConnectionParams.setConnectionTimeout(this.getParams(), 15000);
// }
//
// public ConnectionClient(Credentials cred, int port) throws KeyManagementException, NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException {
// super();
// if (JiraApp.get().allowAllSSL)
// registerTrustAllScheme(port);
// if (cred != null)
// setCredentials(cred);
// }
//
// private void registerTrustAllScheme(int port) throws KeyManagementException, NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException {
// TrustAllSSLSocketFactory tasslf = new TrustAllSSLSocketFactory();
// Scheme sch = new Scheme("https", tasslf, port);
// getConnectionManager().getSchemeRegistry().register(sch);
// }
//
// private void setCredentials(Credentials cred) {
// BasicCredentialsProvider cP = new BasicCredentialsProvider();
// cP.setCredentials(AuthScope.ANY, cred);
// setCredentialsProvider(cP);
// }
// }
| import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.StringWriter;
import java.net.URI;
import java.net.URL;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.util.Map;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.params.HttpParams;
import org.apache.http.params.HttpProtocolParams;
import org.openjira.jira.utils.ConnectionClient;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserFactory; | package org.xmlrpc.android;
/**
* XMLRPCClient allows to call remote XMLRPC method.
*
* <p>
* The following table shows how XML-RPC types are mapped to java call parameters/response values.
* </p>
*
* <p>
* <table border="2" align="center" cellpadding="5">
* <thead><tr><th>XML-RPC Type</th><th>Call Parameters</th><th>Call Response</th></tr></thead>
*
* <tbody>
* <td>int, i4</td><td>byte<br />Byte<br />short<br />Short<br />int<br />Integer</td><td>int<br />Integer</td>
* </tr>
* <tr>
* <td>i8</td><td>long<br />Long</td><td>long<br />Long</td>
* </tr>
* <tr>
* <td>double</td><td>float<br />Float<br />double<br />Double</td><td>double<br />Double</td>
* </tr>
* <tr>
* <td>string</td><td>String</td><td>String</td>
* </tr>
* <tr>
* <td>boolean</td><td>boolean<br />Boolean</td><td>boolean<br />Boolean</td>
* </tr>
* <tr>
* <td>dateTime.iso8601</td><td>java.util.Date<br />java.util.Calendar</td><td>java.util.Date</td>
* </tr>
* <tr>
* <td>base64</td><td>byte[]</td><td>byte[]</td>
* </tr>
* <tr>
* <td>array</td><td>java.util.List<Object><br />Object[]</td><td>Object[]</td>
* </tr>
* <tr>
* <td>struct</td><td>java.util.Map<String, Object></td><td>java.util.Map<String, Object></td>
* </tr>
* </tbody>
* </table>
* </p>
* <p>
* You can also pass as a parameter any object implementing XMLRPCSerializable interface. In this
* case your object overrides getSerializable() telling how to serialize to XMLRPC protocol
* </p>
*/
public class XMLRPCClient extends XMLRPCCommon {
private HttpClient client = null;
private final HttpPost postMethod;
private final HttpParams httpParams;
/**
* XMLRPCClient constructor. Creates new instance based on server URI
* @param XMLRPC server URI
*/
public XMLRPCClient(URI uri) {
postMethod = new HttpPost(uri);
postMethod.addHeader("Content-Type", "text/xml");
// WARNING
// I had to disable "Expect: 100-Continue" header since I had
// two second delay between sending http POST request and POST body
httpParams = postMethod.getParams();
HttpProtocolParams.setUseExpectContinue(httpParams, false);
try { | // Path: src/org/openjira/jira/utils/ConnectionClient.java
// public class ConnectionClient extends DefaultHttpClient {
// public ConnectionClient(Credentials cred) {
// super();
// if (cred != null)
// setCredentials(cred);
// HttpConnectionParams.setConnectionTimeout(this.getParams(), 15000);
// }
//
// public ConnectionClient(Credentials cred, int port) throws KeyManagementException, NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException {
// super();
// if (JiraApp.get().allowAllSSL)
// registerTrustAllScheme(port);
// if (cred != null)
// setCredentials(cred);
// }
//
// private void registerTrustAllScheme(int port) throws KeyManagementException, NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException {
// TrustAllSSLSocketFactory tasslf = new TrustAllSSLSocketFactory();
// Scheme sch = new Scheme("https", tasslf, port);
// getConnectionManager().getSchemeRegistry().register(sch);
// }
//
// private void setCredentials(Credentials cred) {
// BasicCredentialsProvider cP = new BasicCredentialsProvider();
// cP.setCredentials(AuthScope.ANY, cred);
// setCredentialsProvider(cP);
// }
// }
// Path: src/org/xmlrpc/android/XMLRPCClient.java
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.StringWriter;
import java.net.URI;
import java.net.URL;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.util.Map;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.params.HttpParams;
import org.apache.http.params.HttpProtocolParams;
import org.openjira.jira.utils.ConnectionClient;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserFactory;
package org.xmlrpc.android;
/**
* XMLRPCClient allows to call remote XMLRPC method.
*
* <p>
* The following table shows how XML-RPC types are mapped to java call parameters/response values.
* </p>
*
* <p>
* <table border="2" align="center" cellpadding="5">
* <thead><tr><th>XML-RPC Type</th><th>Call Parameters</th><th>Call Response</th></tr></thead>
*
* <tbody>
* <td>int, i4</td><td>byte<br />Byte<br />short<br />Short<br />int<br />Integer</td><td>int<br />Integer</td>
* </tr>
* <tr>
* <td>i8</td><td>long<br />Long</td><td>long<br />Long</td>
* </tr>
* <tr>
* <td>double</td><td>float<br />Float<br />double<br />Double</td><td>double<br />Double</td>
* </tr>
* <tr>
* <td>string</td><td>String</td><td>String</td>
* </tr>
* <tr>
* <td>boolean</td><td>boolean<br />Boolean</td><td>boolean<br />Boolean</td>
* </tr>
* <tr>
* <td>dateTime.iso8601</td><td>java.util.Date<br />java.util.Calendar</td><td>java.util.Date</td>
* </tr>
* <tr>
* <td>base64</td><td>byte[]</td><td>byte[]</td>
* </tr>
* <tr>
* <td>array</td><td>java.util.List<Object><br />Object[]</td><td>Object[]</td>
* </tr>
* <tr>
* <td>struct</td><td>java.util.Map<String, Object></td><td>java.util.Map<String, Object></td>
* </tr>
* </tbody>
* </table>
* </p>
* <p>
* You can also pass as a parameter any object implementing XMLRPCSerializable interface. In this
* case your object overrides getSerializable() telling how to serialize to XMLRPC protocol
* </p>
*/
public class XMLRPCClient extends XMLRPCCommon {
private HttpClient client = null;
private final HttpPost postMethod;
private final HttpParams httpParams;
/**
* XMLRPCClient constructor. Creates new instance based on server URI
* @param XMLRPC server URI
*/
public XMLRPCClient(URI uri) {
postMethod = new HttpPost(uri);
postMethod.addHeader("Content-Type", "text/xml");
// WARNING
// I had to disable "Expect: 100-Continue" header since I had
// two second delay between sending http POST request and POST body
httpParams = postMethod.getParams();
HttpProtocolParams.setUseExpectContinue(httpParams, false);
try { | client = new ConnectionClient(null, 443); |
frankjoshua/openjira | src/org/openjira/jira/CreateIssue.java | // Path: src/org/openjira/jira/model/JiraVersion.java
// public class JiraVersion {
// private String name;
// private String releaseDate;
// private int sequence;
// private boolean released;
// private int id;
// private boolean archived;
//
// public JiraVersion() {
// super();
// }
//
// public JiraVersion(int id, String name, String releaseDate, int sequence, boolean released, boolean archived) {
// super();
// this.name = name;
// this.releaseDate = releaseDate;
// this.sequence = sequence;
// this.released = released;
// this.id = id;
// this.archived = archived;
// }
//
// public static JiraVersion fromMap(HashMap<String, Object> map) {
// JiraVersion version = new JiraVersion();
// version.setId(Integer.parseInt((String) map.get("id")));
// version.setName((String) map.get("name"));
// version.setReleaseDate((String) map.get("releaseDate"));
// if (map.containsKey("sequence"))
// version.setSequence(Integer.parseInt((String) map.get("sequence")));
//
// version.setArchived(((String) map.get("archived")).equals("true") ? true : false);
// version.setReleased(((String) map.get("released")).equals("true") ? true : false);
// return version;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getReleaseDate() {
// return releaseDate;
// }
//
// public void setReleaseDate(String releaseDate) {
// this.releaseDate = releaseDate;
// }
//
// public int getSequence() {
// return sequence;
// }
//
// public void setSequence(int sequence) {
// this.sequence = sequence;
// }
//
// public boolean isReleased() {
// return released;
// }
//
// public void setReleased(boolean released) {
// this.released = released;
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public boolean isArchived() {
// return archived;
// }
//
// public void setArchived(boolean archived) {
// this.archived = archived;
// }
//
// }
| import android.widget.TextView;
import android.widget.Toast;
import java.util.ArrayList;
import org.openjira.jira.model.JiraVersion;
import org.xmlrpc.android.XMLRPCException;
import android.app.Activity;
import android.app.ProgressDialog;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.Spinner; | /*******************************************************************************
* Copyright 2012 Alexandre d'Alton
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/
package org.openjira.jira;
public class CreateIssue extends Activity {
JiraApp app;
private JiraConn conn;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.createissue);
app = JiraApp.get();
ArrayAdapter<String> adapter;
conn = app.getCurrentConnection();
ArrayList<String> list;
final ArrayList<String> projectIds = new ArrayList<String>();
final ArrayList<Integer> typeIds = new ArrayList<Integer>();
final ArrayList<Integer> prioIds = new ArrayList<Integer>();
final Spinner spProject = (Spinner) findViewById(R.id.project);
list = conn.getProjectsLabels(projectIds);
adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, list);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spProject.setAdapter(adapter);
spProject.setOnItemSelectedListener(new OnItemSelectedListener() {
public void onItemSelected(AdapterView< ? > arg0, View arg1, int arg2, long arg3) { | // Path: src/org/openjira/jira/model/JiraVersion.java
// public class JiraVersion {
// private String name;
// private String releaseDate;
// private int sequence;
// private boolean released;
// private int id;
// private boolean archived;
//
// public JiraVersion() {
// super();
// }
//
// public JiraVersion(int id, String name, String releaseDate, int sequence, boolean released, boolean archived) {
// super();
// this.name = name;
// this.releaseDate = releaseDate;
// this.sequence = sequence;
// this.released = released;
// this.id = id;
// this.archived = archived;
// }
//
// public static JiraVersion fromMap(HashMap<String, Object> map) {
// JiraVersion version = new JiraVersion();
// version.setId(Integer.parseInt((String) map.get("id")));
// version.setName((String) map.get("name"));
// version.setReleaseDate((String) map.get("releaseDate"));
// if (map.containsKey("sequence"))
// version.setSequence(Integer.parseInt((String) map.get("sequence")));
//
// version.setArchived(((String) map.get("archived")).equals("true") ? true : false);
// version.setReleased(((String) map.get("released")).equals("true") ? true : false);
// return version;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getReleaseDate() {
// return releaseDate;
// }
//
// public void setReleaseDate(String releaseDate) {
// this.releaseDate = releaseDate;
// }
//
// public int getSequence() {
// return sequence;
// }
//
// public void setSequence(int sequence) {
// this.sequence = sequence;
// }
//
// public boolean isReleased() {
// return released;
// }
//
// public void setReleased(boolean released) {
// this.released = released;
// }
//
// public int getId() {
// return id;
// }
//
// public void setId(int id) {
// this.id = id;
// }
//
// public boolean isArchived() {
// return archived;
// }
//
// public void setArchived(boolean archived) {
// this.archived = archived;
// }
//
// }
// Path: src/org/openjira/jira/CreateIssue.java
import android.widget.TextView;
import android.widget.Toast;
import java.util.ArrayList;
import org.openjira.jira.model.JiraVersion;
import org.xmlrpc.android.XMLRPCException;
import android.app.Activity;
import android.app.ProgressDialog;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.Spinner;
/*******************************************************************************
* Copyright 2012 Alexandre d'Alton
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/
package org.openjira.jira;
public class CreateIssue extends Activity {
JiraApp app;
private JiraConn conn;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.createissue);
app = JiraApp.get();
ArrayAdapter<String> adapter;
conn = app.getCurrentConnection();
ArrayList<String> list;
final ArrayList<String> projectIds = new ArrayList<String>();
final ArrayList<Integer> typeIds = new ArrayList<Integer>();
final ArrayList<Integer> prioIds = new ArrayList<Integer>();
final Spinner spProject = (Spinner) findViewById(R.id.project);
list = conn.getProjectsLabels(projectIds);
adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, list);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spProject.setAdapter(adapter);
spProject.setOnItemSelectedListener(new OnItemSelectedListener() {
public void onItemSelected(AdapterView< ? > arg0, View arg1, int arg2, long arg3) { | ArrayList<JiraVersion> versions = conn.getProject(projectIds.get(arg2)).getVersions(); |
frankjoshua/openjira | src/org/openjira/jira/JiraFilters.java | // Path: src/org/openjira/jira/JiraConn.java
// public class LocalBinder extends Binder {
// public JiraConn getInstance() {
// return JiraConn.this;
// }
// }
//
// Path: src/org/openjira/jira/JiraConn.java
// public interface LoginListener {
// public void onLoginComplete();
//
// public void onLoginError(Exception e);
//
// public void onSyncProgress(String message, int progress, int max);
// }
//
// Path: src/org/openjira/jira/model/JiraFilter.java
// public class JiraFilter {
// private String name;
// private String id;
//
// public JiraFilter() {
// }
//
// public JiraFilter(String id, String name) {
// this.name = name;
// this.id = id;
// }
//
// public static JiraFilter fromMap(Map<String, Object> map) {
// JiraFilter filter = new JiraFilter();
// filter.setName((String) map.get("name"));
// filter.setId((String) map.get("id"));
// return filter;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getId() {
// return id;
// }
//
// }
//
// Path: src/org/openjira/jira/model/JiraServer.java
// public class JiraServer {
//
// private int _id;
// private String name;
// private String url;
// private String user;
// private String password;
//
// public JiraServer(int _id, String name, String url, String user, String password) {
// super();
// this._id = _id;
// this.name = name;
// this.url = url;
// this.user = user;
// this.password = password;
// }
//
// public JiraServer(String name, String url, String user, String password) {
// super();
// this.name = name;
// this.url = url;
// this.user = user;
// this.password = password;
// }
//
// public int get_id() {
// return _id;
// }
//
// public void set_id(Integer id) {
// _id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getUrl() {
// return url;
// }
//
// public void setUrl(String url) {
// this.url = url;
// }
//
// public String getUser() {
// return user;
// }
//
// public void setUser(String user) {
// this.user = user;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// }
| import java.util.ArrayList;
import org.openjira.jira.JiraConn.LocalBinder;
import org.openjira.jira.JiraConn.LoginListener;
import org.openjira.jira.model.JiraFilter;
import org.openjira.jira.model.JiraServer;
import android.app.ProgressDialog;
import android.app.Service;
import android.content.ComponentName;
import android.content.Intent;
import android.content.ServiceConnection;
import android.net.Uri;
import android.os.Bundle;
import android.os.IBinder;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.Toast; | /*******************************************************************************
* Copyright 2012 Alexandre d'Alton
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/
package org.openjira.jira;
public class JiraFilters extends OJActivity implements OnItemClickListener, LoginListener {
JiraConn conn;
private final ServiceConnection connection = new ServiceConnection() {
@Override
public void onServiceDisconnected(final ComponentName name) {
// TODO Auto-generated method stub
}
@Override
public void onServiceConnected(final ComponentName name, final IBinder service) { | // Path: src/org/openjira/jira/JiraConn.java
// public class LocalBinder extends Binder {
// public JiraConn getInstance() {
// return JiraConn.this;
// }
// }
//
// Path: src/org/openjira/jira/JiraConn.java
// public interface LoginListener {
// public void onLoginComplete();
//
// public void onLoginError(Exception e);
//
// public void onSyncProgress(String message, int progress, int max);
// }
//
// Path: src/org/openjira/jira/model/JiraFilter.java
// public class JiraFilter {
// private String name;
// private String id;
//
// public JiraFilter() {
// }
//
// public JiraFilter(String id, String name) {
// this.name = name;
// this.id = id;
// }
//
// public static JiraFilter fromMap(Map<String, Object> map) {
// JiraFilter filter = new JiraFilter();
// filter.setName((String) map.get("name"));
// filter.setId((String) map.get("id"));
// return filter;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getId() {
// return id;
// }
//
// }
//
// Path: src/org/openjira/jira/model/JiraServer.java
// public class JiraServer {
//
// private int _id;
// private String name;
// private String url;
// private String user;
// private String password;
//
// public JiraServer(int _id, String name, String url, String user, String password) {
// super();
// this._id = _id;
// this.name = name;
// this.url = url;
// this.user = user;
// this.password = password;
// }
//
// public JiraServer(String name, String url, String user, String password) {
// super();
// this.name = name;
// this.url = url;
// this.user = user;
// this.password = password;
// }
//
// public int get_id() {
// return _id;
// }
//
// public void set_id(Integer id) {
// _id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getUrl() {
// return url;
// }
//
// public void setUrl(String url) {
// this.url = url;
// }
//
// public String getUser() {
// return user;
// }
//
// public void setUser(String user) {
// this.user = user;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// }
// Path: src/org/openjira/jira/JiraFilters.java
import java.util.ArrayList;
import org.openjira.jira.JiraConn.LocalBinder;
import org.openjira.jira.JiraConn.LoginListener;
import org.openjira.jira.model.JiraFilter;
import org.openjira.jira.model.JiraServer;
import android.app.ProgressDialog;
import android.app.Service;
import android.content.ComponentName;
import android.content.Intent;
import android.content.ServiceConnection;
import android.net.Uri;
import android.os.Bundle;
import android.os.IBinder;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.Toast;
/*******************************************************************************
* Copyright 2012 Alexandre d'Alton
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/
package org.openjira.jira;
public class JiraFilters extends OJActivity implements OnItemClickListener, LoginListener {
JiraConn conn;
private final ServiceConnection connection = new ServiceConnection() {
@Override
public void onServiceDisconnected(final ComponentName name) {
// TODO Auto-generated method stub
}
@Override
public void onServiceConnected(final ComponentName name, final IBinder service) { | final JiraConn jiraConn = ((LocalBinder) service).getInstance(); |
frankjoshua/openjira | src/org/openjira/jira/JiraFilters.java | // Path: src/org/openjira/jira/JiraConn.java
// public class LocalBinder extends Binder {
// public JiraConn getInstance() {
// return JiraConn.this;
// }
// }
//
// Path: src/org/openjira/jira/JiraConn.java
// public interface LoginListener {
// public void onLoginComplete();
//
// public void onLoginError(Exception e);
//
// public void onSyncProgress(String message, int progress, int max);
// }
//
// Path: src/org/openjira/jira/model/JiraFilter.java
// public class JiraFilter {
// private String name;
// private String id;
//
// public JiraFilter() {
// }
//
// public JiraFilter(String id, String name) {
// this.name = name;
// this.id = id;
// }
//
// public static JiraFilter fromMap(Map<String, Object> map) {
// JiraFilter filter = new JiraFilter();
// filter.setName((String) map.get("name"));
// filter.setId((String) map.get("id"));
// return filter;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getId() {
// return id;
// }
//
// }
//
// Path: src/org/openjira/jira/model/JiraServer.java
// public class JiraServer {
//
// private int _id;
// private String name;
// private String url;
// private String user;
// private String password;
//
// public JiraServer(int _id, String name, String url, String user, String password) {
// super();
// this._id = _id;
// this.name = name;
// this.url = url;
// this.user = user;
// this.password = password;
// }
//
// public JiraServer(String name, String url, String user, String password) {
// super();
// this.name = name;
// this.url = url;
// this.user = user;
// this.password = password;
// }
//
// public int get_id() {
// return _id;
// }
//
// public void set_id(Integer id) {
// _id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getUrl() {
// return url;
// }
//
// public void setUrl(String url) {
// this.url = url;
// }
//
// public String getUser() {
// return user;
// }
//
// public void setUser(String user) {
// this.user = user;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// }
| import java.util.ArrayList;
import org.openjira.jira.JiraConn.LocalBinder;
import org.openjira.jira.JiraConn.LoginListener;
import org.openjira.jira.model.JiraFilter;
import org.openjira.jira.model.JiraServer;
import android.app.ProgressDialog;
import android.app.Service;
import android.content.ComponentName;
import android.content.Intent;
import android.content.ServiceConnection;
import android.net.Uri;
import android.os.Bundle;
import android.os.IBinder;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.Toast; | /*******************************************************************************
* Copyright 2012 Alexandre d'Alton
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/
package org.openjira.jira;
public class JiraFilters extends OJActivity implements OnItemClickListener, LoginListener {
JiraConn conn;
private final ServiceConnection connection = new ServiceConnection() {
@Override
public void onServiceDisconnected(final ComponentName name) {
// TODO Auto-generated method stub
}
@Override
public void onServiceConnected(final ComponentName name, final IBinder service) {
final JiraConn jiraConn = ((LocalBinder) service).getInstance();
JiraFilters.this.conn = jiraConn;
final Uri data = getIntent().getData();
if (data != null) {
final JiraApp app = JiraApp.get(); | // Path: src/org/openjira/jira/JiraConn.java
// public class LocalBinder extends Binder {
// public JiraConn getInstance() {
// return JiraConn.this;
// }
// }
//
// Path: src/org/openjira/jira/JiraConn.java
// public interface LoginListener {
// public void onLoginComplete();
//
// public void onLoginError(Exception e);
//
// public void onSyncProgress(String message, int progress, int max);
// }
//
// Path: src/org/openjira/jira/model/JiraFilter.java
// public class JiraFilter {
// private String name;
// private String id;
//
// public JiraFilter() {
// }
//
// public JiraFilter(String id, String name) {
// this.name = name;
// this.id = id;
// }
//
// public static JiraFilter fromMap(Map<String, Object> map) {
// JiraFilter filter = new JiraFilter();
// filter.setName((String) map.get("name"));
// filter.setId((String) map.get("id"));
// return filter;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getId() {
// return id;
// }
//
// }
//
// Path: src/org/openjira/jira/model/JiraServer.java
// public class JiraServer {
//
// private int _id;
// private String name;
// private String url;
// private String user;
// private String password;
//
// public JiraServer(int _id, String name, String url, String user, String password) {
// super();
// this._id = _id;
// this.name = name;
// this.url = url;
// this.user = user;
// this.password = password;
// }
//
// public JiraServer(String name, String url, String user, String password) {
// super();
// this.name = name;
// this.url = url;
// this.user = user;
// this.password = password;
// }
//
// public int get_id() {
// return _id;
// }
//
// public void set_id(Integer id) {
// _id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getUrl() {
// return url;
// }
//
// public void setUrl(String url) {
// this.url = url;
// }
//
// public String getUser() {
// return user;
// }
//
// public void setUser(String user) {
// this.user = user;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// }
// Path: src/org/openjira/jira/JiraFilters.java
import java.util.ArrayList;
import org.openjira.jira.JiraConn.LocalBinder;
import org.openjira.jira.JiraConn.LoginListener;
import org.openjira.jira.model.JiraFilter;
import org.openjira.jira.model.JiraServer;
import android.app.ProgressDialog;
import android.app.Service;
import android.content.ComponentName;
import android.content.Intent;
import android.content.ServiceConnection;
import android.net.Uri;
import android.os.Bundle;
import android.os.IBinder;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.Toast;
/*******************************************************************************
* Copyright 2012 Alexandre d'Alton
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/
package org.openjira.jira;
public class JiraFilters extends OJActivity implements OnItemClickListener, LoginListener {
JiraConn conn;
private final ServiceConnection connection = new ServiceConnection() {
@Override
public void onServiceDisconnected(final ComponentName name) {
// TODO Auto-generated method stub
}
@Override
public void onServiceConnected(final ComponentName name, final IBinder service) {
final JiraConn jiraConn = ((LocalBinder) service).getInstance();
JiraFilters.this.conn = jiraConn;
final Uri data = getIntent().getData();
if (data != null) {
final JiraApp app = JiraApp.get(); | final JiraServer server = app.getServerFromName(data.getQueryParameter("server")); |
frankjoshua/openjira | src/org/openjira/jira/JiraFilters.java | // Path: src/org/openjira/jira/JiraConn.java
// public class LocalBinder extends Binder {
// public JiraConn getInstance() {
// return JiraConn.this;
// }
// }
//
// Path: src/org/openjira/jira/JiraConn.java
// public interface LoginListener {
// public void onLoginComplete();
//
// public void onLoginError(Exception e);
//
// public void onSyncProgress(String message, int progress, int max);
// }
//
// Path: src/org/openjira/jira/model/JiraFilter.java
// public class JiraFilter {
// private String name;
// private String id;
//
// public JiraFilter() {
// }
//
// public JiraFilter(String id, String name) {
// this.name = name;
// this.id = id;
// }
//
// public static JiraFilter fromMap(Map<String, Object> map) {
// JiraFilter filter = new JiraFilter();
// filter.setName((String) map.get("name"));
// filter.setId((String) map.get("id"));
// return filter;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getId() {
// return id;
// }
//
// }
//
// Path: src/org/openjira/jira/model/JiraServer.java
// public class JiraServer {
//
// private int _id;
// private String name;
// private String url;
// private String user;
// private String password;
//
// public JiraServer(int _id, String name, String url, String user, String password) {
// super();
// this._id = _id;
// this.name = name;
// this.url = url;
// this.user = user;
// this.password = password;
// }
//
// public JiraServer(String name, String url, String user, String password) {
// super();
// this.name = name;
// this.url = url;
// this.user = user;
// this.password = password;
// }
//
// public int get_id() {
// return _id;
// }
//
// public void set_id(Integer id) {
// _id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getUrl() {
// return url;
// }
//
// public void setUrl(String url) {
// this.url = url;
// }
//
// public String getUser() {
// return user;
// }
//
// public void setUser(String user) {
// this.user = user;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// }
| import java.util.ArrayList;
import org.openjira.jira.JiraConn.LocalBinder;
import org.openjira.jira.JiraConn.LoginListener;
import org.openjira.jira.model.JiraFilter;
import org.openjira.jira.model.JiraServer;
import android.app.ProgressDialog;
import android.app.Service;
import android.content.ComponentName;
import android.content.Intent;
import android.content.ServiceConnection;
import android.net.Uri;
import android.os.Bundle;
import android.os.IBinder;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.Toast; | }
});
}
@Override
protected void onStart() {
super.onStart();
final Intent service = new Intent(this, JiraConn.class);
bindService(service, this.connection, Service.BIND_AUTO_CREATE);
}
@Override
public void onStop() {
super.onStop();
try {
unbindService(this.connection);
} catch (final Exception e) {
// Service was not connected
}
}
// private int currentIssue;
// private int currentFilter;
// XMLRPCClient rpcClient;
// Object loginToken;
// ArrayList<JiraIssue> issueList;
public void getFavouriteFilters() {
final ArrayList<String> filterNames = new ArrayList<String>(); | // Path: src/org/openjira/jira/JiraConn.java
// public class LocalBinder extends Binder {
// public JiraConn getInstance() {
// return JiraConn.this;
// }
// }
//
// Path: src/org/openjira/jira/JiraConn.java
// public interface LoginListener {
// public void onLoginComplete();
//
// public void onLoginError(Exception e);
//
// public void onSyncProgress(String message, int progress, int max);
// }
//
// Path: src/org/openjira/jira/model/JiraFilter.java
// public class JiraFilter {
// private String name;
// private String id;
//
// public JiraFilter() {
// }
//
// public JiraFilter(String id, String name) {
// this.name = name;
// this.id = id;
// }
//
// public static JiraFilter fromMap(Map<String, Object> map) {
// JiraFilter filter = new JiraFilter();
// filter.setName((String) map.get("name"));
// filter.setId((String) map.get("id"));
// return filter;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getName() {
// return name;
// }
//
// public void setId(String id) {
// this.id = id;
// }
//
// public String getId() {
// return id;
// }
//
// }
//
// Path: src/org/openjira/jira/model/JiraServer.java
// public class JiraServer {
//
// private int _id;
// private String name;
// private String url;
// private String user;
// private String password;
//
// public JiraServer(int _id, String name, String url, String user, String password) {
// super();
// this._id = _id;
// this.name = name;
// this.url = url;
// this.user = user;
// this.password = password;
// }
//
// public JiraServer(String name, String url, String user, String password) {
// super();
// this.name = name;
// this.url = url;
// this.user = user;
// this.password = password;
// }
//
// public int get_id() {
// return _id;
// }
//
// public void set_id(Integer id) {
// _id = id;
// }
//
// public String getName() {
// return name;
// }
//
// public void setName(String name) {
// this.name = name;
// }
//
// public String getUrl() {
// return url;
// }
//
// public void setUrl(String url) {
// this.url = url;
// }
//
// public String getUser() {
// return user;
// }
//
// public void setUser(String user) {
// this.user = user;
// }
//
// public String getPassword() {
// return password;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// }
// Path: src/org/openjira/jira/JiraFilters.java
import java.util.ArrayList;
import org.openjira.jira.JiraConn.LocalBinder;
import org.openjira.jira.JiraConn.LoginListener;
import org.openjira.jira.model.JiraFilter;
import org.openjira.jira.model.JiraServer;
import android.app.ProgressDialog;
import android.app.Service;
import android.content.ComponentName;
import android.content.Intent;
import android.content.ServiceConnection;
import android.net.Uri;
import android.os.Bundle;
import android.os.IBinder;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.Toast;
}
});
}
@Override
protected void onStart() {
super.onStart();
final Intent service = new Intent(this, JiraConn.class);
bindService(service, this.connection, Service.BIND_AUTO_CREATE);
}
@Override
public void onStop() {
super.onStop();
try {
unbindService(this.connection);
} catch (final Exception e) {
// Service was not connected
}
}
// private int currentIssue;
// private int currentFilter;
// XMLRPCClient rpcClient;
// Object loginToken;
// ArrayList<JiraIssue> issueList;
public void getFavouriteFilters() {
final ArrayList<String> filterNames = new ArrayList<String>(); | final ArrayList<JiraFilter> filters = this.conn.getFilters(); |
frankjoshua/openjira | src/org/openjira/jira/EditServer.java | // Path: src/org/openjira/jira/JiraConn.java
// public interface LoginListener {
// public void onLoginComplete();
//
// public void onLoginError(Exception e);
//
// public void onSyncProgress(String message, int progress, int max);
// }
| import org.openjira.jira.JiraConn.LoginListener;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast; | // validate connection, on failure cancel next steps
// TODO: needs to be redesigned because connection test is
// asynchronous and we need to wait here for the real result...
if (testConnection(serverName, serverUrl, username, password)) {
// Build a return bundle
}
}
/**
* This function is testing a connection with the given URL and user
* credentials. For better usability it shows a ProgressDialog until
* the validation is on progress. (Dialog disabled currently!)
*
* @param name
* The name of the server connection
* @param url
* complete server url e.g. http://jira.atlassian.com
* @param user
* (optional) username for login attempts
* @param pass
* (optional) password for login attempts
* @return return true on success, false otherwise
*/
private boolean testConnection(final String name, final String url, final String user, final String pass) {
// final JiraConn conn = new JiraConn(url, user, pass);
final ProgressDialog dlg = new ProgressDialog(EditServer.this);
dlg.setMessage("Testing connection");
dlg.show();
| // Path: src/org/openjira/jira/JiraConn.java
// public interface LoginListener {
// public void onLoginComplete();
//
// public void onLoginError(Exception e);
//
// public void onSyncProgress(String message, int progress, int max);
// }
// Path: src/org/openjira/jira/EditServer.java
import org.openjira.jira.JiraConn.LoginListener;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
// validate connection, on failure cancel next steps
// TODO: needs to be redesigned because connection test is
// asynchronous and we need to wait here for the real result...
if (testConnection(serverName, serverUrl, username, password)) {
// Build a return bundle
}
}
/**
* This function is testing a connection with the given URL and user
* credentials. For better usability it shows a ProgressDialog until
* the validation is on progress. (Dialog disabled currently!)
*
* @param name
* The name of the server connection
* @param url
* complete server url e.g. http://jira.atlassian.com
* @param user
* (optional) username for login attempts
* @param pass
* (optional) password for login attempts
* @return return true on success, false otherwise
*/
private boolean testConnection(final String name, final String url, final String user, final String pass) {
// final JiraConn conn = new JiraConn(url, user, pass);
final ProgressDialog dlg = new ProgressDialog(EditServer.this);
dlg.setMessage("Testing connection");
dlg.show();
| JiraConn.testLogin(url, user, pass, new LoginListener() { |
jenkinsci/cloudtest-plugin | src/main/java/com/soasta/jenkins/cloud/build/StopGrid.java | // Path: src/main/java/com/soasta/jenkins/cloud/CloudStatus.java
// public enum CloudStatus
// {
// TERMINATED,
// READY,
// FAILED
// }
| import org.jenkinsci.Symbol;
import org.kohsuke.stapler.DataBoundConstructor;
import com.soasta.jenkins.cloud.CloudStatus;
import hudson.Extension; | /*
* Copyright (c) 2015, CloudBees, Inc., SOASTA, Inc.
* All Rights Reserved.
*/
package com.soasta.jenkins.cloud.build;
public class StopGrid extends CloudCommandBaseBuild
{
@DataBoundConstructor
public StopGrid(String url, String cloudTestServerID, String name)
{
super(url, cloudTestServerID, name);
}
@Extension
@Symbol("stopGrid")
public static class DescriptorImpl extends AbstractCloudCommandBuildDescriptor
{
@Override
public String getDisplayName()
{
return "Stop Grid";
}
}
@Override
public String getCommand()
{
return "terminate-grid";
}
@Override
public int getDefaultTimeout()
{
return 600;
}
@Override | // Path: src/main/java/com/soasta/jenkins/cloud/CloudStatus.java
// public enum CloudStatus
// {
// TERMINATED,
// READY,
// FAILED
// }
// Path: src/main/java/com/soasta/jenkins/cloud/build/StopGrid.java
import org.jenkinsci.Symbol;
import org.kohsuke.stapler.DataBoundConstructor;
import com.soasta.jenkins.cloud.CloudStatus;
import hudson.Extension;
/*
* Copyright (c) 2015, CloudBees, Inc., SOASTA, Inc.
* All Rights Reserved.
*/
package com.soasta.jenkins.cloud.build;
public class StopGrid extends CloudCommandBaseBuild
{
@DataBoundConstructor
public StopGrid(String url, String cloudTestServerID, String name)
{
super(url, cloudTestServerID, name);
}
@Extension
@Symbol("stopGrid")
public static class DescriptorImpl extends AbstractCloudCommandBuildDescriptor
{
@Override
public String getDisplayName()
{
return "Stop Grid";
}
}
@Override
public String getCommand()
{
return "terminate-grid";
}
@Override
public int getDefaultTimeout()
{
return 600;
}
@Override | public CloudStatus getSuccessStatus() |
jenkinsci/cloudtest-plugin | src/main/java/com/soasta/jenkins/cloud/postbuild/StartRSDB.java | // Path: src/main/java/com/soasta/jenkins/cloud/CloudStatus.java
// public enum CloudStatus
// {
// TERMINATED,
// READY,
// FAILED
// }
| import org.jenkinsci.Symbol;
import org.kohsuke.stapler.DataBoundConstructor;
import com.soasta.jenkins.cloud.CloudStatus;
import hudson.Extension; | /*
* Copyright (c) 2015, CloudBees, Inc., SOASTA, Inc.
* All Rights Reserved.
*/
package com.soasta.jenkins.cloud.postbuild;
public class StartRSDB extends CloudCommandBasePostBuild
{
@DataBoundConstructor
public StartRSDB(String url, String cloudTestServerID, String name, int timeOut)
{
super(url, cloudTestServerID, name, timeOut);
}
@Extension
@Symbol("startRSDB")
public static class DescriptorImpl extends AbstractCloudCommandPostBuildDescriptor
{
@Override
public String getDisplayName()
{
return "Start RSDB";
}
}
@Override
public String getCommand()
{
return "start-rsdb";
}
@Override
public int getDefaultTimeout()
{
return 1200;
}
@Override | // Path: src/main/java/com/soasta/jenkins/cloud/CloudStatus.java
// public enum CloudStatus
// {
// TERMINATED,
// READY,
// FAILED
// }
// Path: src/main/java/com/soasta/jenkins/cloud/postbuild/StartRSDB.java
import org.jenkinsci.Symbol;
import org.kohsuke.stapler.DataBoundConstructor;
import com.soasta.jenkins.cloud.CloudStatus;
import hudson.Extension;
/*
* Copyright (c) 2015, CloudBees, Inc., SOASTA, Inc.
* All Rights Reserved.
*/
package com.soasta.jenkins.cloud.postbuild;
public class StartRSDB extends CloudCommandBasePostBuild
{
@DataBoundConstructor
public StartRSDB(String url, String cloudTestServerID, String name, int timeOut)
{
super(url, cloudTestServerID, name, timeOut);
}
@Extension
@Symbol("startRSDB")
public static class DescriptorImpl extends AbstractCloudCommandPostBuildDescriptor
{
@Override
public String getDisplayName()
{
return "Start RSDB";
}
}
@Override
public String getCommand()
{
return "start-rsdb";
}
@Override
public int getDefaultTimeout()
{
return 1200;
}
@Override | public CloudStatus getSuccessStatus() |
jenkinsci/cloudtest-plugin | src/main/java/com/soasta/jenkins/httpclient/GenericSelfClosingHttpClient.java | // Path: src/main/java/com/soasta/jenkins/ProxyChecker.java
// public class ProxyChecker
// {
// public static boolean useProxy(String host, ProxyConfiguration proxyConfig)
// {
// // Check if the proxy applies for this destination host.
// // This code is more or less copied from ProxyConfiguration.createProxy() :-(.
// if (proxyConfig != null && proxyConfig.name != null)
// {
// for (Pattern p : proxyConfig.getNoProxyHostPatterns())
// {
// if (p.matcher(host).matches())
// {
// // It's a match.
// // Don't use the proxy.
// return false;
// }
// }
// // we have checked, and the proxy host pattern doesn't match our whitelist, So use the proxy.
// return true;
// }
// else
// {
// // jenkins is not configured to use a proxy.
// return false;
// }
// }
// }
| import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.security.cert.X509Certificate;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.net.ssl.KeyManager;
import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import org.apache.http.HttpHost;
import org.apache.http.HttpResponse;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.config.RegistryBuilder;
import org.apache.http.conn.socket.ConnectionSocketFactory;
import org.apache.http.conn.socket.PlainConnectionSocketFactory;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.conn.BasicHttpClientConnectionManager;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.apache.http.impl.conn.SystemDefaultDnsResolver;
import org.apache.http.util.EntityUtils;
import com.soasta.jenkins.ProxyChecker;
import hudson.ProxyConfiguration;
import jenkins.model.Jenkins; | new X509TrustManager()
{
public java.security.cert.X509Certificate[] getAcceptedIssuers()
{
return new X509Certificate[] {};
}
public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType)
{
}
public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType)
{
}
}
};
}
public static SSLConnectionSocketFactory getSSLFactory(KeyManager[] keyManager, TrustManager[] trustManagers) throws Exception
{
SSLContext sslContext = SSLContext.getInstance("TLS");
sslContext.init(keyManager, trustManagers, new java.security.SecureRandom());
SSLConnectionSocketFactory sslConnectionFactory = new SSLConnectionSocketFactory(sslContext, SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
return sslConnectionFactory;
}
private CredentialsProvider getProxyCreds(ProxyConfiguration proxyInfo, String host)
{
CredentialsProvider credentialsProvider = null;
// is the host on the no proxy list? | // Path: src/main/java/com/soasta/jenkins/ProxyChecker.java
// public class ProxyChecker
// {
// public static boolean useProxy(String host, ProxyConfiguration proxyConfig)
// {
// // Check if the proxy applies for this destination host.
// // This code is more or less copied from ProxyConfiguration.createProxy() :-(.
// if (proxyConfig != null && proxyConfig.name != null)
// {
// for (Pattern p : proxyConfig.getNoProxyHostPatterns())
// {
// if (p.matcher(host).matches())
// {
// // It's a match.
// // Don't use the proxy.
// return false;
// }
// }
// // we have checked, and the proxy host pattern doesn't match our whitelist, So use the proxy.
// return true;
// }
// else
// {
// // jenkins is not configured to use a proxy.
// return false;
// }
// }
// }
// Path: src/main/java/com/soasta/jenkins/httpclient/GenericSelfClosingHttpClient.java
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.security.cert.X509Certificate;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.net.ssl.KeyManager;
import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import org.apache.http.HttpHost;
import org.apache.http.HttpResponse;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.config.RegistryBuilder;
import org.apache.http.conn.socket.ConnectionSocketFactory;
import org.apache.http.conn.socket.PlainConnectionSocketFactory;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.conn.BasicHttpClientConnectionManager;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.apache.http.impl.conn.SystemDefaultDnsResolver;
import org.apache.http.util.EntityUtils;
import com.soasta.jenkins.ProxyChecker;
import hudson.ProxyConfiguration;
import jenkins.model.Jenkins;
new X509TrustManager()
{
public java.security.cert.X509Certificate[] getAcceptedIssuers()
{
return new X509Certificate[] {};
}
public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType)
{
}
public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType)
{
}
}
};
}
public static SSLConnectionSocketFactory getSSLFactory(KeyManager[] keyManager, TrustManager[] trustManagers) throws Exception
{
SSLContext sslContext = SSLContext.getInstance("TLS");
sslContext.init(keyManager, trustManagers, new java.security.SecureRandom());
SSLConnectionSocketFactory sslConnectionFactory = new SSLConnectionSocketFactory(sslContext, SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
return sslConnectionFactory;
}
private CredentialsProvider getProxyCreds(ProxyConfiguration proxyInfo, String host)
{
CredentialsProvider credentialsProvider = null;
// is the host on the no proxy list? | if (proxyInfo != null && proxyInfo.name != null && ProxyChecker.useProxy(host, proxyInfo)) |
jenkinsci/cloudtest-plugin | src/main/java/com/soasta/jenkins/cloud/build/StartGrid.java | // Path: src/main/java/com/soasta/jenkins/cloud/CloudStatus.java
// public enum CloudStatus
// {
// TERMINATED,
// READY,
// FAILED
// }
| import org.jenkinsci.Symbol;
import org.kohsuke.stapler.DataBoundConstructor;
import com.soasta.jenkins.cloud.CloudStatus;
import hudson.Extension; | /*
* Copyright (c) 2015, CloudBees, Inc., SOASTA, Inc.
* All Rights Reserved.
*/
package com.soasta.jenkins.cloud.build;
public class StartGrid extends CloudCommandBaseBuild
{
@DataBoundConstructor
public StartGrid(String url, String cloudTestServerID, String name, int timeOut)
{
super(url, cloudTestServerID, name, timeOut);
}
@Extension
@Symbol("startGrid")
public static class DescriptorImpl extends AbstractCloudCommandBuildDescriptor
{
@Override
public String getDisplayName()
{
return "Start Grid";
}
}
@Override
public String getCommand()
{
return "start-grid";
}
@Override
public int getDefaultTimeout()
{
return 600;
}
@Override | // Path: src/main/java/com/soasta/jenkins/cloud/CloudStatus.java
// public enum CloudStatus
// {
// TERMINATED,
// READY,
// FAILED
// }
// Path: src/main/java/com/soasta/jenkins/cloud/build/StartGrid.java
import org.jenkinsci.Symbol;
import org.kohsuke.stapler.DataBoundConstructor;
import com.soasta.jenkins.cloud.CloudStatus;
import hudson.Extension;
/*
* Copyright (c) 2015, CloudBees, Inc., SOASTA, Inc.
* All Rights Reserved.
*/
package com.soasta.jenkins.cloud.build;
public class StartGrid extends CloudCommandBaseBuild
{
@DataBoundConstructor
public StartGrid(String url, String cloudTestServerID, String name, int timeOut)
{
super(url, cloudTestServerID, name, timeOut);
}
@Extension
@Symbol("startGrid")
public static class DescriptorImpl extends AbstractCloudCommandBuildDescriptor
{
@Override
public String getDisplayName()
{
return "Start Grid";
}
}
@Override
public String getCommand()
{
return "start-grid";
}
@Override
public int getDefaultTimeout()
{
return 600;
}
@Override | public CloudStatus getSuccessStatus() |
jenkinsci/cloudtest-plugin | src/main/java/com/soasta/jenkins/cloud/build/CloudCommandBaseBuild.java | // Path: src/main/java/com/soasta/jenkins/cloud/CloudCommandBuilder.java
// public class CloudCommandBuilder {
// /**
// * URL of the server to use (deprecated).
// */
// private String url;
// /**
// * ID of the server to use.
// * @see CloudTestServer
// */
// private String cloudTestServerID;
// private TaskListener listener;
// private FilePath workspace;
//
// public CloudTestServer getServer() {
// return CloudTestServer.getByID(cloudTestServerID);
// }
//
// public CloudCommandBuilder setUrl(String url)
// {
// this.url = url;
// return this;
// }
//
// public String getUrl() {
// return url;
// }
//
// public CloudCommandBuilder setCloudTestServerID(String value)
// {
// this.cloudTestServerID = value;
// return this;
// }
//
// public String getCloudTestServerID() {
// return cloudTestServerID;
// }
//
// public CloudCommandBuilder setWorkspace(FilePath workspace)
// {
// this.workspace = workspace;
// return this;
// }
//
// public CloudCommandBuilder setListener(TaskListener listener)
// {
// this.listener = listener;
// return this;
// }
//
// public ArgumentListBuilder build() throws IOException, InterruptedException {
// CloudTestServer s = getServer();
// if (s == null)
// throw new AbortException("No TouchTest server is configured in the system configuration.");
//
// FilePath scommand = new SCommandInstaller(s).scommand(workspace.toComputer().getNode(), listener);
//
// ArgumentListBuilder args = new ArgumentListBuilder();
// args.add(scommand)
// .add("url=" + s.getUrl());
//
// if(!s.getApitoken().trim().isEmpty() && s.getUsername().trim().isEmpty() && s.getPassword() == null) {
// args.add("apitoken=" + s.getApitoken());
// }
// else if(!s.getApitoken().trim().isEmpty() && (!s.getUsername().trim().isEmpty() || s.getPassword() != null)) {
// throw new AbortException("Cannot set both Username or Password and API Token");
// }
// else if(s.getApitoken().trim().isEmpty() && !s.getUsername().trim().isEmpty()) {
// args.add("username="+s.getUsername());
// args.addMasked("password=" + s.getPassword());
// }
//
// ProxyConfiguration proxyConfig = Jenkins.getInstance().proxy;
//
// if (proxyConfig != null && proxyConfig.name != null) {
// // Jenkins is configured to use a proxy server.
//
// // Extract the destination CloudTest host.
// String host = new URL(s.getUrl()).getHost();
//
// if (ProxyChecker.useProxy(host, proxyConfig)) {
// // Add the SCommand proxy parameters.
// args.add("httpproxyhost=" + proxyConfig.name)
// .add("httpproxyport=" + proxyConfig.port);
//
// // If there are proxy credentials, add those too.
// if (proxyConfig.getUserName() != null) {
// args.add("httpproxyusername=" + proxyConfig.getUserName())
// .addMasked("httpproxypassword=" + proxyConfig.getPassword());
// }
// }
// }
//
// return args;
// }
// }
//
// Path: src/main/java/com/soasta/jenkins/cloud/CloudStatus.java
// public enum CloudStatus
// {
// TERMINATED,
// READY,
// FAILED
// }
| import java.io.File;
import java.io.IOException;
import hudson.FilePath;
import hudson.Launcher;
import hudson.model.AbstractBuild;
import hudson.model.BuildListener;
import hudson.model.Run;
import hudson.model.TaskListener;
import hudson.util.ArgumentListBuilder;
import jenkins.tasks.SimpleBuildStep;
import org.w3c.dom.*;
import org.xml.sax.InputSource;
import com.soasta.jenkins.cloud.CloudCommandBuilder;
import com.soasta.jenkins.cloud.CloudStatus;
import javax.xml.parsers.*;
import java.io.*;
import hudson.tasks.BuildStepMonitor;
import hudson.tasks.Builder; | return this.url;
}
public final String cloudTestServerID()
{
return this.cloudTestServerID;
}
public String getCloudTestServerID()
{
return cloudTestServerID;
}
public final String getName()
{
return name;
}
public final int getTimeOut()
{
return timeOut;
}
@Override
public void perform(Run<?, ?> run, FilePath workspace, Launcher launcher, TaskListener listener) throws InterruptedException, IOException {
String command = getCommand();
// Create a unique sub-directory to store all test results.
String resultsDir = "." + command;
// set the basic commands.
ArgumentListBuilder args = | // Path: src/main/java/com/soasta/jenkins/cloud/CloudCommandBuilder.java
// public class CloudCommandBuilder {
// /**
// * URL of the server to use (deprecated).
// */
// private String url;
// /**
// * ID of the server to use.
// * @see CloudTestServer
// */
// private String cloudTestServerID;
// private TaskListener listener;
// private FilePath workspace;
//
// public CloudTestServer getServer() {
// return CloudTestServer.getByID(cloudTestServerID);
// }
//
// public CloudCommandBuilder setUrl(String url)
// {
// this.url = url;
// return this;
// }
//
// public String getUrl() {
// return url;
// }
//
// public CloudCommandBuilder setCloudTestServerID(String value)
// {
// this.cloudTestServerID = value;
// return this;
// }
//
// public String getCloudTestServerID() {
// return cloudTestServerID;
// }
//
// public CloudCommandBuilder setWorkspace(FilePath workspace)
// {
// this.workspace = workspace;
// return this;
// }
//
// public CloudCommandBuilder setListener(TaskListener listener)
// {
// this.listener = listener;
// return this;
// }
//
// public ArgumentListBuilder build() throws IOException, InterruptedException {
// CloudTestServer s = getServer();
// if (s == null)
// throw new AbortException("No TouchTest server is configured in the system configuration.");
//
// FilePath scommand = new SCommandInstaller(s).scommand(workspace.toComputer().getNode(), listener);
//
// ArgumentListBuilder args = new ArgumentListBuilder();
// args.add(scommand)
// .add("url=" + s.getUrl());
//
// if(!s.getApitoken().trim().isEmpty() && s.getUsername().trim().isEmpty() && s.getPassword() == null) {
// args.add("apitoken=" + s.getApitoken());
// }
// else if(!s.getApitoken().trim().isEmpty() && (!s.getUsername().trim().isEmpty() || s.getPassword() != null)) {
// throw new AbortException("Cannot set both Username or Password and API Token");
// }
// else if(s.getApitoken().trim().isEmpty() && !s.getUsername().trim().isEmpty()) {
// args.add("username="+s.getUsername());
// args.addMasked("password=" + s.getPassword());
// }
//
// ProxyConfiguration proxyConfig = Jenkins.getInstance().proxy;
//
// if (proxyConfig != null && proxyConfig.name != null) {
// // Jenkins is configured to use a proxy server.
//
// // Extract the destination CloudTest host.
// String host = new URL(s.getUrl()).getHost();
//
// if (ProxyChecker.useProxy(host, proxyConfig)) {
// // Add the SCommand proxy parameters.
// args.add("httpproxyhost=" + proxyConfig.name)
// .add("httpproxyport=" + proxyConfig.port);
//
// // If there are proxy credentials, add those too.
// if (proxyConfig.getUserName() != null) {
// args.add("httpproxyusername=" + proxyConfig.getUserName())
// .addMasked("httpproxypassword=" + proxyConfig.getPassword());
// }
// }
// }
//
// return args;
// }
// }
//
// Path: src/main/java/com/soasta/jenkins/cloud/CloudStatus.java
// public enum CloudStatus
// {
// TERMINATED,
// READY,
// FAILED
// }
// Path: src/main/java/com/soasta/jenkins/cloud/build/CloudCommandBaseBuild.java
import java.io.File;
import java.io.IOException;
import hudson.FilePath;
import hudson.Launcher;
import hudson.model.AbstractBuild;
import hudson.model.BuildListener;
import hudson.model.Run;
import hudson.model.TaskListener;
import hudson.util.ArgumentListBuilder;
import jenkins.tasks.SimpleBuildStep;
import org.w3c.dom.*;
import org.xml.sax.InputSource;
import com.soasta.jenkins.cloud.CloudCommandBuilder;
import com.soasta.jenkins.cloud.CloudStatus;
import javax.xml.parsers.*;
import java.io.*;
import hudson.tasks.BuildStepMonitor;
import hudson.tasks.Builder;
return this.url;
}
public final String cloudTestServerID()
{
return this.cloudTestServerID;
}
public String getCloudTestServerID()
{
return cloudTestServerID;
}
public final String getName()
{
return name;
}
public final int getTimeOut()
{
return timeOut;
}
@Override
public void perform(Run<?, ?> run, FilePath workspace, Launcher launcher, TaskListener listener) throws InterruptedException, IOException {
String command = getCommand();
// Create a unique sub-directory to store all test results.
String resultsDir = "." + command;
// set the basic commands.
ArgumentListBuilder args = | new CloudCommandBuilder() |
jenkinsci/cloudtest-plugin | src/main/java/com/soasta/jenkins/cloud/build/CloudCommandBaseBuild.java | // Path: src/main/java/com/soasta/jenkins/cloud/CloudCommandBuilder.java
// public class CloudCommandBuilder {
// /**
// * URL of the server to use (deprecated).
// */
// private String url;
// /**
// * ID of the server to use.
// * @see CloudTestServer
// */
// private String cloudTestServerID;
// private TaskListener listener;
// private FilePath workspace;
//
// public CloudTestServer getServer() {
// return CloudTestServer.getByID(cloudTestServerID);
// }
//
// public CloudCommandBuilder setUrl(String url)
// {
// this.url = url;
// return this;
// }
//
// public String getUrl() {
// return url;
// }
//
// public CloudCommandBuilder setCloudTestServerID(String value)
// {
// this.cloudTestServerID = value;
// return this;
// }
//
// public String getCloudTestServerID() {
// return cloudTestServerID;
// }
//
// public CloudCommandBuilder setWorkspace(FilePath workspace)
// {
// this.workspace = workspace;
// return this;
// }
//
// public CloudCommandBuilder setListener(TaskListener listener)
// {
// this.listener = listener;
// return this;
// }
//
// public ArgumentListBuilder build() throws IOException, InterruptedException {
// CloudTestServer s = getServer();
// if (s == null)
// throw new AbortException("No TouchTest server is configured in the system configuration.");
//
// FilePath scommand = new SCommandInstaller(s).scommand(workspace.toComputer().getNode(), listener);
//
// ArgumentListBuilder args = new ArgumentListBuilder();
// args.add(scommand)
// .add("url=" + s.getUrl());
//
// if(!s.getApitoken().trim().isEmpty() && s.getUsername().trim().isEmpty() && s.getPassword() == null) {
// args.add("apitoken=" + s.getApitoken());
// }
// else if(!s.getApitoken().trim().isEmpty() && (!s.getUsername().trim().isEmpty() || s.getPassword() != null)) {
// throw new AbortException("Cannot set both Username or Password and API Token");
// }
// else if(s.getApitoken().trim().isEmpty() && !s.getUsername().trim().isEmpty()) {
// args.add("username="+s.getUsername());
// args.addMasked("password=" + s.getPassword());
// }
//
// ProxyConfiguration proxyConfig = Jenkins.getInstance().proxy;
//
// if (proxyConfig != null && proxyConfig.name != null) {
// // Jenkins is configured to use a proxy server.
//
// // Extract the destination CloudTest host.
// String host = new URL(s.getUrl()).getHost();
//
// if (ProxyChecker.useProxy(host, proxyConfig)) {
// // Add the SCommand proxy parameters.
// args.add("httpproxyhost=" + proxyConfig.name)
// .add("httpproxyport=" + proxyConfig.port);
//
// // If there are proxy credentials, add those too.
// if (proxyConfig.getUserName() != null) {
// args.add("httpproxyusername=" + proxyConfig.getUserName())
// .addMasked("httpproxypassword=" + proxyConfig.getPassword());
// }
// }
// }
//
// return args;
// }
// }
//
// Path: src/main/java/com/soasta/jenkins/cloud/CloudStatus.java
// public enum CloudStatus
// {
// TERMINATED,
// READY,
// FAILED
// }
| import java.io.File;
import java.io.IOException;
import hudson.FilePath;
import hudson.Launcher;
import hudson.model.AbstractBuild;
import hudson.model.BuildListener;
import hudson.model.Run;
import hudson.model.TaskListener;
import hudson.util.ArgumentListBuilder;
import jenkins.tasks.SimpleBuildStep;
import org.w3c.dom.*;
import org.xml.sax.InputSource;
import com.soasta.jenkins.cloud.CloudCommandBuilder;
import com.soasta.jenkins.cloud.CloudStatus;
import javax.xml.parsers.*;
import java.io.*;
import hudson.tasks.BuildStepMonitor;
import hudson.tasks.Builder; | isSucessful(xml.readToString());
}
catch (Exception e)
{
e.printStackTrace();
return;
}
}
@Override
public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
FilePath filePath = build.getWorkspace();
if(filePath == null) {
return false;
} else {
perform(build, filePath, launcher, listener);
return true;
}
}
/**
* Returns the specific cloud command. E.g 'start-grid', 'start-env', 'terminate-env'
* @return
*/
public abstract String getCommand();
/**
* Returns the expected str for a sucessful start / terminate.
* @return
*/ | // Path: src/main/java/com/soasta/jenkins/cloud/CloudCommandBuilder.java
// public class CloudCommandBuilder {
// /**
// * URL of the server to use (deprecated).
// */
// private String url;
// /**
// * ID of the server to use.
// * @see CloudTestServer
// */
// private String cloudTestServerID;
// private TaskListener listener;
// private FilePath workspace;
//
// public CloudTestServer getServer() {
// return CloudTestServer.getByID(cloudTestServerID);
// }
//
// public CloudCommandBuilder setUrl(String url)
// {
// this.url = url;
// return this;
// }
//
// public String getUrl() {
// return url;
// }
//
// public CloudCommandBuilder setCloudTestServerID(String value)
// {
// this.cloudTestServerID = value;
// return this;
// }
//
// public String getCloudTestServerID() {
// return cloudTestServerID;
// }
//
// public CloudCommandBuilder setWorkspace(FilePath workspace)
// {
// this.workspace = workspace;
// return this;
// }
//
// public CloudCommandBuilder setListener(TaskListener listener)
// {
// this.listener = listener;
// return this;
// }
//
// public ArgumentListBuilder build() throws IOException, InterruptedException {
// CloudTestServer s = getServer();
// if (s == null)
// throw new AbortException("No TouchTest server is configured in the system configuration.");
//
// FilePath scommand = new SCommandInstaller(s).scommand(workspace.toComputer().getNode(), listener);
//
// ArgumentListBuilder args = new ArgumentListBuilder();
// args.add(scommand)
// .add("url=" + s.getUrl());
//
// if(!s.getApitoken().trim().isEmpty() && s.getUsername().trim().isEmpty() && s.getPassword() == null) {
// args.add("apitoken=" + s.getApitoken());
// }
// else if(!s.getApitoken().trim().isEmpty() && (!s.getUsername().trim().isEmpty() || s.getPassword() != null)) {
// throw new AbortException("Cannot set both Username or Password and API Token");
// }
// else if(s.getApitoken().trim().isEmpty() && !s.getUsername().trim().isEmpty()) {
// args.add("username="+s.getUsername());
// args.addMasked("password=" + s.getPassword());
// }
//
// ProxyConfiguration proxyConfig = Jenkins.getInstance().proxy;
//
// if (proxyConfig != null && proxyConfig.name != null) {
// // Jenkins is configured to use a proxy server.
//
// // Extract the destination CloudTest host.
// String host = new URL(s.getUrl()).getHost();
//
// if (ProxyChecker.useProxy(host, proxyConfig)) {
// // Add the SCommand proxy parameters.
// args.add("httpproxyhost=" + proxyConfig.name)
// .add("httpproxyport=" + proxyConfig.port);
//
// // If there are proxy credentials, add those too.
// if (proxyConfig.getUserName() != null) {
// args.add("httpproxyusername=" + proxyConfig.getUserName())
// .addMasked("httpproxypassword=" + proxyConfig.getPassword());
// }
// }
// }
//
// return args;
// }
// }
//
// Path: src/main/java/com/soasta/jenkins/cloud/CloudStatus.java
// public enum CloudStatus
// {
// TERMINATED,
// READY,
// FAILED
// }
// Path: src/main/java/com/soasta/jenkins/cloud/build/CloudCommandBaseBuild.java
import java.io.File;
import java.io.IOException;
import hudson.FilePath;
import hudson.Launcher;
import hudson.model.AbstractBuild;
import hudson.model.BuildListener;
import hudson.model.Run;
import hudson.model.TaskListener;
import hudson.util.ArgumentListBuilder;
import jenkins.tasks.SimpleBuildStep;
import org.w3c.dom.*;
import org.xml.sax.InputSource;
import com.soasta.jenkins.cloud.CloudCommandBuilder;
import com.soasta.jenkins.cloud.CloudStatus;
import javax.xml.parsers.*;
import java.io.*;
import hudson.tasks.BuildStepMonitor;
import hudson.tasks.Builder;
isSucessful(xml.readToString());
}
catch (Exception e)
{
e.printStackTrace();
return;
}
}
@Override
public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
FilePath filePath = build.getWorkspace();
if(filePath == null) {
return false;
} else {
perform(build, filePath, launcher, listener);
return true;
}
}
/**
* Returns the specific cloud command. E.g 'start-grid', 'start-env', 'terminate-env'
* @return
*/
public abstract String getCommand();
/**
* Returns the expected str for a sucessful start / terminate.
* @return
*/ | public abstract CloudStatus getSuccessStatus(); |
jenkinsci/cloudtest-plugin | src/main/java/com/soasta/jenkins/cloud/build/StartTestEnvironment.java | // Path: src/main/java/com/soasta/jenkins/cloud/CloudStatus.java
// public enum CloudStatus
// {
// TERMINATED,
// READY,
// FAILED
// }
| import org.jenkinsci.Symbol;
import org.kohsuke.stapler.DataBoundConstructor;
import com.soasta.jenkins.cloud.CloudStatus;
import hudson.Extension; | /**
* Copyright (c) 2015, CloudBees, Inc., SOASTA, Inc.
* All Rights Reserved.
*/
package com.soasta.jenkins.cloud.build;
public class StartTestEnvironment extends CloudCommandBaseBuild
{
@DataBoundConstructor
public StartTestEnvironment(String url, String cloudTestServerID, String name, int timeOut)
{
super(url, cloudTestServerID, name, timeOut);
}
@Extension
@Symbol("startTestEnvironment")
public static class DescriptorImpl extends AbstractCloudCommandBuildDescriptor
{
@Override
public String getDisplayName()
{
return "Start Test Environment";
}
}
@Override
public String getCommand()
{
return "start-env";
}
@Override
public int getDefaultTimeout()
{
return 1200;
}
@Override | // Path: src/main/java/com/soasta/jenkins/cloud/CloudStatus.java
// public enum CloudStatus
// {
// TERMINATED,
// READY,
// FAILED
// }
// Path: src/main/java/com/soasta/jenkins/cloud/build/StartTestEnvironment.java
import org.jenkinsci.Symbol;
import org.kohsuke.stapler.DataBoundConstructor;
import com.soasta.jenkins.cloud.CloudStatus;
import hudson.Extension;
/**
* Copyright (c) 2015, CloudBees, Inc., SOASTA, Inc.
* All Rights Reserved.
*/
package com.soasta.jenkins.cloud.build;
public class StartTestEnvironment extends CloudCommandBaseBuild
{
@DataBoundConstructor
public StartTestEnvironment(String url, String cloudTestServerID, String name, int timeOut)
{
super(url, cloudTestServerID, name, timeOut);
}
@Extension
@Symbol("startTestEnvironment")
public static class DescriptorImpl extends AbstractCloudCommandBuildDescriptor
{
@Override
public String getDisplayName()
{
return "Start Test Environment";
}
}
@Override
public String getCommand()
{
return "start-env";
}
@Override
public int getDefaultTimeout()
{
return 1200;
}
@Override | public CloudStatus getSuccessStatus() |
jenkinsci/cloudtest-plugin | src/main/java/com/soasta/jenkins/cloud/postbuild/StopTestEnvironment.java | // Path: src/main/java/com/soasta/jenkins/cloud/CloudStatus.java
// public enum CloudStatus
// {
// TERMINATED,
// READY,
// FAILED
// }
| import org.jenkinsci.Symbol;
import org.kohsuke.stapler.DataBoundConstructor;
import com.soasta.jenkins.cloud.CloudStatus;
import hudson.Extension; | /**
* Copyright (c) 2015, CloudBees, Inc., SOASTA, Inc.
* All Rights Reserved.
*/
package com.soasta.jenkins.cloud.postbuild;
public class StopTestEnvironment extends CloudCommandBasePostBuild
{
@DataBoundConstructor
public StopTestEnvironment(String url, String cloudTestServerID, String name)
{
super(url, cloudTestServerID, name);
}
@Extension
@Symbol("stopTestEnvironment")
public static class DescriptorImpl extends AbstractCloudCommandPostBuildDescriptor
{
@Override
public String getDisplayName()
{
return "Stop Test Environment";
}
}
@Override
public String getCommand()
{
return "terminate-env";
}
@Override
public int getDefaultTimeout()
{
return 1200;
}
@Override | // Path: src/main/java/com/soasta/jenkins/cloud/CloudStatus.java
// public enum CloudStatus
// {
// TERMINATED,
// READY,
// FAILED
// }
// Path: src/main/java/com/soasta/jenkins/cloud/postbuild/StopTestEnvironment.java
import org.jenkinsci.Symbol;
import org.kohsuke.stapler.DataBoundConstructor;
import com.soasta.jenkins.cloud.CloudStatus;
import hudson.Extension;
/**
* Copyright (c) 2015, CloudBees, Inc., SOASTA, Inc.
* All Rights Reserved.
*/
package com.soasta.jenkins.cloud.postbuild;
public class StopTestEnvironment extends CloudCommandBasePostBuild
{
@DataBoundConstructor
public StopTestEnvironment(String url, String cloudTestServerID, String name)
{
super(url, cloudTestServerID, name);
}
@Extension
@Symbol("stopTestEnvironment")
public static class DescriptorImpl extends AbstractCloudCommandPostBuildDescriptor
{
@Override
public String getDisplayName()
{
return "Stop Test Environment";
}
}
@Override
public String getCommand()
{
return "terminate-env";
}
@Override
public int getDefaultTimeout()
{
return 1200;
}
@Override | public CloudStatus getSuccessStatus() |
jenkinsci/cloudtest-plugin | src/main/java/com/soasta/jenkins/cloud/postbuild/CloudCommandBasePostBuild.java | // Path: src/main/java/com/soasta/jenkins/cloud/CloudCommandBuilder.java
// public class CloudCommandBuilder {
// /**
// * URL of the server to use (deprecated).
// */
// private String url;
// /**
// * ID of the server to use.
// * @see CloudTestServer
// */
// private String cloudTestServerID;
// private TaskListener listener;
// private FilePath workspace;
//
// public CloudTestServer getServer() {
// return CloudTestServer.getByID(cloudTestServerID);
// }
//
// public CloudCommandBuilder setUrl(String url)
// {
// this.url = url;
// return this;
// }
//
// public String getUrl() {
// return url;
// }
//
// public CloudCommandBuilder setCloudTestServerID(String value)
// {
// this.cloudTestServerID = value;
// return this;
// }
//
// public String getCloudTestServerID() {
// return cloudTestServerID;
// }
//
// public CloudCommandBuilder setWorkspace(FilePath workspace)
// {
// this.workspace = workspace;
// return this;
// }
//
// public CloudCommandBuilder setListener(TaskListener listener)
// {
// this.listener = listener;
// return this;
// }
//
// public ArgumentListBuilder build() throws IOException, InterruptedException {
// CloudTestServer s = getServer();
// if (s == null)
// throw new AbortException("No TouchTest server is configured in the system configuration.");
//
// FilePath scommand = new SCommandInstaller(s).scommand(workspace.toComputer().getNode(), listener);
//
// ArgumentListBuilder args = new ArgumentListBuilder();
// args.add(scommand)
// .add("url=" + s.getUrl());
//
// if(!s.getApitoken().trim().isEmpty() && s.getUsername().trim().isEmpty() && s.getPassword() == null) {
// args.add("apitoken=" + s.getApitoken());
// }
// else if(!s.getApitoken().trim().isEmpty() && (!s.getUsername().trim().isEmpty() || s.getPassword() != null)) {
// throw new AbortException("Cannot set both Username or Password and API Token");
// }
// else if(s.getApitoken().trim().isEmpty() && !s.getUsername().trim().isEmpty()) {
// args.add("username="+s.getUsername());
// args.addMasked("password=" + s.getPassword());
// }
//
// ProxyConfiguration proxyConfig = Jenkins.getInstance().proxy;
//
// if (proxyConfig != null && proxyConfig.name != null) {
// // Jenkins is configured to use a proxy server.
//
// // Extract the destination CloudTest host.
// String host = new URL(s.getUrl()).getHost();
//
// if (ProxyChecker.useProxy(host, proxyConfig)) {
// // Add the SCommand proxy parameters.
// args.add("httpproxyhost=" + proxyConfig.name)
// .add("httpproxyport=" + proxyConfig.port);
//
// // If there are proxy credentials, add those too.
// if (proxyConfig.getUserName() != null) {
// args.add("httpproxyusername=" + proxyConfig.getUserName())
// .addMasked("httpproxypassword=" + proxyConfig.getPassword());
// }
// }
// }
//
// return args;
// }
// }
//
// Path: src/main/java/com/soasta/jenkins/cloud/CloudStatus.java
// public enum CloudStatus
// {
// TERMINATED,
// READY,
// FAILED
// }
| import java.io.File;
import java.io.IOException;
import hudson.FilePath;
import hudson.Launcher;
import hudson.model.AbstractBuild;
import hudson.model.BuildListener;
import hudson.model.Run;
import hudson.model.TaskListener;
import hudson.util.ArgumentListBuilder;
import jenkins.tasks.SimpleBuildStep;
import org.w3c.dom.*;
import org.xml.sax.InputSource;
import com.soasta.jenkins.cloud.CloudCommandBuilder;
import com.soasta.jenkins.cloud.CloudStatus;
import javax.xml.parsers.*;
import java.io.*;
import hudson.tasks.BuildStepMonitor;
import hudson.tasks.Recorder; | this.timeOut = getDefaultTimeout();
}
else
{
this.timeOut = timeOut;
}
}
public String getName()
{
return name;
}
public String getCloudTestServerID()
{
return cloudTestServerID;
}
public int getTimeOut()
{
return timeOut;
}
@Override
public void perform(Run<?, ?> run, FilePath workspace, Launcher launcher, TaskListener listener) throws InterruptedException, IOException {
String command = getCommand();
// Create a unique sub-directory to store all test results.
String resultsDir = "." + command;
// set the basic commands.
ArgumentListBuilder args = | // Path: src/main/java/com/soasta/jenkins/cloud/CloudCommandBuilder.java
// public class CloudCommandBuilder {
// /**
// * URL of the server to use (deprecated).
// */
// private String url;
// /**
// * ID of the server to use.
// * @see CloudTestServer
// */
// private String cloudTestServerID;
// private TaskListener listener;
// private FilePath workspace;
//
// public CloudTestServer getServer() {
// return CloudTestServer.getByID(cloudTestServerID);
// }
//
// public CloudCommandBuilder setUrl(String url)
// {
// this.url = url;
// return this;
// }
//
// public String getUrl() {
// return url;
// }
//
// public CloudCommandBuilder setCloudTestServerID(String value)
// {
// this.cloudTestServerID = value;
// return this;
// }
//
// public String getCloudTestServerID() {
// return cloudTestServerID;
// }
//
// public CloudCommandBuilder setWorkspace(FilePath workspace)
// {
// this.workspace = workspace;
// return this;
// }
//
// public CloudCommandBuilder setListener(TaskListener listener)
// {
// this.listener = listener;
// return this;
// }
//
// public ArgumentListBuilder build() throws IOException, InterruptedException {
// CloudTestServer s = getServer();
// if (s == null)
// throw new AbortException("No TouchTest server is configured in the system configuration.");
//
// FilePath scommand = new SCommandInstaller(s).scommand(workspace.toComputer().getNode(), listener);
//
// ArgumentListBuilder args = new ArgumentListBuilder();
// args.add(scommand)
// .add("url=" + s.getUrl());
//
// if(!s.getApitoken().trim().isEmpty() && s.getUsername().trim().isEmpty() && s.getPassword() == null) {
// args.add("apitoken=" + s.getApitoken());
// }
// else if(!s.getApitoken().trim().isEmpty() && (!s.getUsername().trim().isEmpty() || s.getPassword() != null)) {
// throw new AbortException("Cannot set both Username or Password and API Token");
// }
// else if(s.getApitoken().trim().isEmpty() && !s.getUsername().trim().isEmpty()) {
// args.add("username="+s.getUsername());
// args.addMasked("password=" + s.getPassword());
// }
//
// ProxyConfiguration proxyConfig = Jenkins.getInstance().proxy;
//
// if (proxyConfig != null && proxyConfig.name != null) {
// // Jenkins is configured to use a proxy server.
//
// // Extract the destination CloudTest host.
// String host = new URL(s.getUrl()).getHost();
//
// if (ProxyChecker.useProxy(host, proxyConfig)) {
// // Add the SCommand proxy parameters.
// args.add("httpproxyhost=" + proxyConfig.name)
// .add("httpproxyport=" + proxyConfig.port);
//
// // If there are proxy credentials, add those too.
// if (proxyConfig.getUserName() != null) {
// args.add("httpproxyusername=" + proxyConfig.getUserName())
// .addMasked("httpproxypassword=" + proxyConfig.getPassword());
// }
// }
// }
//
// return args;
// }
// }
//
// Path: src/main/java/com/soasta/jenkins/cloud/CloudStatus.java
// public enum CloudStatus
// {
// TERMINATED,
// READY,
// FAILED
// }
// Path: src/main/java/com/soasta/jenkins/cloud/postbuild/CloudCommandBasePostBuild.java
import java.io.File;
import java.io.IOException;
import hudson.FilePath;
import hudson.Launcher;
import hudson.model.AbstractBuild;
import hudson.model.BuildListener;
import hudson.model.Run;
import hudson.model.TaskListener;
import hudson.util.ArgumentListBuilder;
import jenkins.tasks.SimpleBuildStep;
import org.w3c.dom.*;
import org.xml.sax.InputSource;
import com.soasta.jenkins.cloud.CloudCommandBuilder;
import com.soasta.jenkins.cloud.CloudStatus;
import javax.xml.parsers.*;
import java.io.*;
import hudson.tasks.BuildStepMonitor;
import hudson.tasks.Recorder;
this.timeOut = getDefaultTimeout();
}
else
{
this.timeOut = timeOut;
}
}
public String getName()
{
return name;
}
public String getCloudTestServerID()
{
return cloudTestServerID;
}
public int getTimeOut()
{
return timeOut;
}
@Override
public void perform(Run<?, ?> run, FilePath workspace, Launcher launcher, TaskListener listener) throws InterruptedException, IOException {
String command = getCommand();
// Create a unique sub-directory to store all test results.
String resultsDir = "." + command;
// set the basic commands.
ArgumentListBuilder args = | new CloudCommandBuilder() |
jenkinsci/cloudtest-plugin | src/main/java/com/soasta/jenkins/cloud/postbuild/CloudCommandBasePostBuild.java | // Path: src/main/java/com/soasta/jenkins/cloud/CloudCommandBuilder.java
// public class CloudCommandBuilder {
// /**
// * URL of the server to use (deprecated).
// */
// private String url;
// /**
// * ID of the server to use.
// * @see CloudTestServer
// */
// private String cloudTestServerID;
// private TaskListener listener;
// private FilePath workspace;
//
// public CloudTestServer getServer() {
// return CloudTestServer.getByID(cloudTestServerID);
// }
//
// public CloudCommandBuilder setUrl(String url)
// {
// this.url = url;
// return this;
// }
//
// public String getUrl() {
// return url;
// }
//
// public CloudCommandBuilder setCloudTestServerID(String value)
// {
// this.cloudTestServerID = value;
// return this;
// }
//
// public String getCloudTestServerID() {
// return cloudTestServerID;
// }
//
// public CloudCommandBuilder setWorkspace(FilePath workspace)
// {
// this.workspace = workspace;
// return this;
// }
//
// public CloudCommandBuilder setListener(TaskListener listener)
// {
// this.listener = listener;
// return this;
// }
//
// public ArgumentListBuilder build() throws IOException, InterruptedException {
// CloudTestServer s = getServer();
// if (s == null)
// throw new AbortException("No TouchTest server is configured in the system configuration.");
//
// FilePath scommand = new SCommandInstaller(s).scommand(workspace.toComputer().getNode(), listener);
//
// ArgumentListBuilder args = new ArgumentListBuilder();
// args.add(scommand)
// .add("url=" + s.getUrl());
//
// if(!s.getApitoken().trim().isEmpty() && s.getUsername().trim().isEmpty() && s.getPassword() == null) {
// args.add("apitoken=" + s.getApitoken());
// }
// else if(!s.getApitoken().trim().isEmpty() && (!s.getUsername().trim().isEmpty() || s.getPassword() != null)) {
// throw new AbortException("Cannot set both Username or Password and API Token");
// }
// else if(s.getApitoken().trim().isEmpty() && !s.getUsername().trim().isEmpty()) {
// args.add("username="+s.getUsername());
// args.addMasked("password=" + s.getPassword());
// }
//
// ProxyConfiguration proxyConfig = Jenkins.getInstance().proxy;
//
// if (proxyConfig != null && proxyConfig.name != null) {
// // Jenkins is configured to use a proxy server.
//
// // Extract the destination CloudTest host.
// String host = new URL(s.getUrl()).getHost();
//
// if (ProxyChecker.useProxy(host, proxyConfig)) {
// // Add the SCommand proxy parameters.
// args.add("httpproxyhost=" + proxyConfig.name)
// .add("httpproxyport=" + proxyConfig.port);
//
// // If there are proxy credentials, add those too.
// if (proxyConfig.getUserName() != null) {
// args.add("httpproxyusername=" + proxyConfig.getUserName())
// .addMasked("httpproxypassword=" + proxyConfig.getPassword());
// }
// }
// }
//
// return args;
// }
// }
//
// Path: src/main/java/com/soasta/jenkins/cloud/CloudStatus.java
// public enum CloudStatus
// {
// TERMINATED,
// READY,
// FAILED
// }
| import java.io.File;
import java.io.IOException;
import hudson.FilePath;
import hudson.Launcher;
import hudson.model.AbstractBuild;
import hudson.model.BuildListener;
import hudson.model.Run;
import hudson.model.TaskListener;
import hudson.util.ArgumentListBuilder;
import jenkins.tasks.SimpleBuildStep;
import org.w3c.dom.*;
import org.xml.sax.InputSource;
import com.soasta.jenkins.cloud.CloudCommandBuilder;
import com.soasta.jenkins.cloud.CloudStatus;
import javax.xml.parsers.*;
import java.io.*;
import hudson.tasks.BuildStepMonitor;
import hudson.tasks.Recorder; | isSucessful(xml.readToString());
}
catch (Exception e)
{
e.printStackTrace();
return;
}
}
@Override
public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
FilePath filePath = build.getWorkspace();
if(filePath == null) {
return false;
} else {
perform(build, filePath, launcher, listener);
return true;
}
}
/**
* Returns the specific cloud command. E.g 'start-grid', 'start-env', 'terminate-env'
* @return
*/
public abstract String getCommand();
/**
* Returns the expected str for a sucessful start / terminate.
* @return
*/ | // Path: src/main/java/com/soasta/jenkins/cloud/CloudCommandBuilder.java
// public class CloudCommandBuilder {
// /**
// * URL of the server to use (deprecated).
// */
// private String url;
// /**
// * ID of the server to use.
// * @see CloudTestServer
// */
// private String cloudTestServerID;
// private TaskListener listener;
// private FilePath workspace;
//
// public CloudTestServer getServer() {
// return CloudTestServer.getByID(cloudTestServerID);
// }
//
// public CloudCommandBuilder setUrl(String url)
// {
// this.url = url;
// return this;
// }
//
// public String getUrl() {
// return url;
// }
//
// public CloudCommandBuilder setCloudTestServerID(String value)
// {
// this.cloudTestServerID = value;
// return this;
// }
//
// public String getCloudTestServerID() {
// return cloudTestServerID;
// }
//
// public CloudCommandBuilder setWorkspace(FilePath workspace)
// {
// this.workspace = workspace;
// return this;
// }
//
// public CloudCommandBuilder setListener(TaskListener listener)
// {
// this.listener = listener;
// return this;
// }
//
// public ArgumentListBuilder build() throws IOException, InterruptedException {
// CloudTestServer s = getServer();
// if (s == null)
// throw new AbortException("No TouchTest server is configured in the system configuration.");
//
// FilePath scommand = new SCommandInstaller(s).scommand(workspace.toComputer().getNode(), listener);
//
// ArgumentListBuilder args = new ArgumentListBuilder();
// args.add(scommand)
// .add("url=" + s.getUrl());
//
// if(!s.getApitoken().trim().isEmpty() && s.getUsername().trim().isEmpty() && s.getPassword() == null) {
// args.add("apitoken=" + s.getApitoken());
// }
// else if(!s.getApitoken().trim().isEmpty() && (!s.getUsername().trim().isEmpty() || s.getPassword() != null)) {
// throw new AbortException("Cannot set both Username or Password and API Token");
// }
// else if(s.getApitoken().trim().isEmpty() && !s.getUsername().trim().isEmpty()) {
// args.add("username="+s.getUsername());
// args.addMasked("password=" + s.getPassword());
// }
//
// ProxyConfiguration proxyConfig = Jenkins.getInstance().proxy;
//
// if (proxyConfig != null && proxyConfig.name != null) {
// // Jenkins is configured to use a proxy server.
//
// // Extract the destination CloudTest host.
// String host = new URL(s.getUrl()).getHost();
//
// if (ProxyChecker.useProxy(host, proxyConfig)) {
// // Add the SCommand proxy parameters.
// args.add("httpproxyhost=" + proxyConfig.name)
// .add("httpproxyport=" + proxyConfig.port);
//
// // If there are proxy credentials, add those too.
// if (proxyConfig.getUserName() != null) {
// args.add("httpproxyusername=" + proxyConfig.getUserName())
// .addMasked("httpproxypassword=" + proxyConfig.getPassword());
// }
// }
// }
//
// return args;
// }
// }
//
// Path: src/main/java/com/soasta/jenkins/cloud/CloudStatus.java
// public enum CloudStatus
// {
// TERMINATED,
// READY,
// FAILED
// }
// Path: src/main/java/com/soasta/jenkins/cloud/postbuild/CloudCommandBasePostBuild.java
import java.io.File;
import java.io.IOException;
import hudson.FilePath;
import hudson.Launcher;
import hudson.model.AbstractBuild;
import hudson.model.BuildListener;
import hudson.model.Run;
import hudson.model.TaskListener;
import hudson.util.ArgumentListBuilder;
import jenkins.tasks.SimpleBuildStep;
import org.w3c.dom.*;
import org.xml.sax.InputSource;
import com.soasta.jenkins.cloud.CloudCommandBuilder;
import com.soasta.jenkins.cloud.CloudStatus;
import javax.xml.parsers.*;
import java.io.*;
import hudson.tasks.BuildStepMonitor;
import hudson.tasks.Recorder;
isSucessful(xml.readToString());
}
catch (Exception e)
{
e.printStackTrace();
return;
}
}
@Override
public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
FilePath filePath = build.getWorkspace();
if(filePath == null) {
return false;
} else {
perform(build, filePath, launcher, listener);
return true;
}
}
/**
* Returns the specific cloud command. E.g 'start-grid', 'start-env', 'terminate-env'
* @return
*/
public abstract String getCommand();
/**
* Returns the expected str for a sucessful start / terminate.
* @return
*/ | public abstract CloudStatus getSuccessStatus(); |
jenkinsci/cloudtest-plugin | src/main/java/com/soasta/jenkins/cloud/postbuild/StopRSDB.java | // Path: src/main/java/com/soasta/jenkins/cloud/CloudStatus.java
// public enum CloudStatus
// {
// TERMINATED,
// READY,
// FAILED
// }
| import org.kohsuke.stapler.DataBoundConstructor;
import com.soasta.jenkins.cloud.CloudStatus;
import hudson.Extension;
import org.jenkinsci.Symbol; | /*
* Copyright (c) 2015, CloudBees, Inc., SOASTA, Inc.
* All Rights Reserved.
*/
package com.soasta.jenkins.cloud.postbuild;
public class StopRSDB extends CloudCommandBasePostBuild
{
@DataBoundConstructor
public StopRSDB(String url, String cloudTestServerID, String name)
{
super(url, cloudTestServerID, name);
}
@Extension
@Symbol("stopRSDB")
public static class DescriptorImpl extends AbstractCloudCommandPostBuildDescriptor
{
@Override
public String getDisplayName()
{
return "Stop RSDB";
}
}
@Override
public String getCommand()
{
return "terminate-rsdb";
}
@Override
public int getDefaultTimeout()
{
return 1200;
}
@Override | // Path: src/main/java/com/soasta/jenkins/cloud/CloudStatus.java
// public enum CloudStatus
// {
// TERMINATED,
// READY,
// FAILED
// }
// Path: src/main/java/com/soasta/jenkins/cloud/postbuild/StopRSDB.java
import org.kohsuke.stapler.DataBoundConstructor;
import com.soasta.jenkins.cloud.CloudStatus;
import hudson.Extension;
import org.jenkinsci.Symbol;
/*
* Copyright (c) 2015, CloudBees, Inc., SOASTA, Inc.
* All Rights Reserved.
*/
package com.soasta.jenkins.cloud.postbuild;
public class StopRSDB extends CloudCommandBasePostBuild
{
@DataBoundConstructor
public StopRSDB(String url, String cloudTestServerID, String name)
{
super(url, cloudTestServerID, name);
}
@Extension
@Symbol("stopRSDB")
public static class DescriptorImpl extends AbstractCloudCommandPostBuildDescriptor
{
@Override
public String getDisplayName()
{
return "Stop RSDB";
}
}
@Override
public String getCommand()
{
return "terminate-rsdb";
}
@Override
public int getDefaultTimeout()
{
return 1200;
}
@Override | public CloudStatus getSuccessStatus() |
jenkinsci/cloudtest-plugin | src/main/java/com/soasta/jenkins/cloud/build/StopTestEnvironment.java | // Path: src/main/java/com/soasta/jenkins/cloud/CloudStatus.java
// public enum CloudStatus
// {
// TERMINATED,
// READY,
// FAILED
// }
| import org.jenkinsci.Symbol;
import org.kohsuke.stapler.DataBoundConstructor;
import com.soasta.jenkins.cloud.CloudStatus;
import hudson.Extension; | /**
* Copyright (c) 2015, CloudBees, Inc., SOASTA, Inc.
* All Rights Reserved.
*/
package com.soasta.jenkins.cloud.build;
public class StopTestEnvironment extends CloudCommandBaseBuild
{
@DataBoundConstructor
public StopTestEnvironment(String url, String cloudTestServerID, String name)
{
super(url, cloudTestServerID, name);
}
@Extension
@Symbol("stopTestEnvironment")
public static class DescriptorImpl extends AbstractCloudCommandBuildDescriptor
{
@Override
public String getDisplayName()
{
return "Stop Test Environment";
}
}
@Override
public String getCommand()
{
return "terminate-env";
}
@Override
public int getDefaultTimeout()
{
return 1200;
}
@Override | // Path: src/main/java/com/soasta/jenkins/cloud/CloudStatus.java
// public enum CloudStatus
// {
// TERMINATED,
// READY,
// FAILED
// }
// Path: src/main/java/com/soasta/jenkins/cloud/build/StopTestEnvironment.java
import org.jenkinsci.Symbol;
import org.kohsuke.stapler.DataBoundConstructor;
import com.soasta.jenkins.cloud.CloudStatus;
import hudson.Extension;
/**
* Copyright (c) 2015, CloudBees, Inc., SOASTA, Inc.
* All Rights Reserved.
*/
package com.soasta.jenkins.cloud.build;
public class StopTestEnvironment extends CloudCommandBaseBuild
{
@DataBoundConstructor
public StopTestEnvironment(String url, String cloudTestServerID, String name)
{
super(url, cloudTestServerID, name);
}
@Extension
@Symbol("stopTestEnvironment")
public static class DescriptorImpl extends AbstractCloudCommandBuildDescriptor
{
@Override
public String getDisplayName()
{
return "Stop Test Environment";
}
}
@Override
public String getCommand()
{
return "terminate-env";
}
@Override
public int getDefaultTimeout()
{
return 1200;
}
@Override | public CloudStatus getSuccessStatus() |
jenkinsci/cloudtest-plugin | src/main/java/com/soasta/jenkins/cloud/build/StopRSDB.java | // Path: src/main/java/com/soasta/jenkins/cloud/CloudStatus.java
// public enum CloudStatus
// {
// TERMINATED,
// READY,
// FAILED
// }
| import org.jenkinsci.Symbol;
import org.kohsuke.stapler.DataBoundConstructor;
import com.soasta.jenkins.cloud.CloudStatus;
import hudson.Extension; | /*
* Copyright (c) 2015, CloudBees, Inc., SOASTA, Inc.
* All Rights Reserved.
*/
package com.soasta.jenkins.cloud.build;
public class StopRSDB extends CloudCommandBaseBuild
{
@DataBoundConstructor
public StopRSDB(String url, String cloudTestServerID, String name)
{
super(url, cloudTestServerID, name);
}
@Extension
@Symbol("stopRSDB")
public static class DescriptorImpl extends AbstractCloudCommandBuildDescriptor
{
@Override
public String getDisplayName()
{
return "Stop RSDB";
}
}
@Override
public String getCommand()
{
return "terminate-rsdb";
}
@Override
public int getDefaultTimeout()
{
return 1200;
}
@Override | // Path: src/main/java/com/soasta/jenkins/cloud/CloudStatus.java
// public enum CloudStatus
// {
// TERMINATED,
// READY,
// FAILED
// }
// Path: src/main/java/com/soasta/jenkins/cloud/build/StopRSDB.java
import org.jenkinsci.Symbol;
import org.kohsuke.stapler.DataBoundConstructor;
import com.soasta.jenkins.cloud.CloudStatus;
import hudson.Extension;
/*
* Copyright (c) 2015, CloudBees, Inc., SOASTA, Inc.
* All Rights Reserved.
*/
package com.soasta.jenkins.cloud.build;
public class StopRSDB extends CloudCommandBaseBuild
{
@DataBoundConstructor
public StopRSDB(String url, String cloudTestServerID, String name)
{
super(url, cloudTestServerID, name);
}
@Extension
@Symbol("stopRSDB")
public static class DescriptorImpl extends AbstractCloudCommandBuildDescriptor
{
@Override
public String getDisplayName()
{
return "Stop RSDB";
}
}
@Override
public String getCommand()
{
return "terminate-rsdb";
}
@Override
public int getDefaultTimeout()
{
return 1200;
}
@Override | public CloudStatus getSuccessStatus() |
jenkinsci/cloudtest-plugin | src/main/java/com/soasta/jenkins/cloud/postbuild/StartGrid.java | // Path: src/main/java/com/soasta/jenkins/cloud/CloudStatus.java
// public enum CloudStatus
// {
// TERMINATED,
// READY,
// FAILED
// }
//
// Path: src/main/java/com/soasta/jenkins/cloud/postbuild/AbstractCloudCommandPostBuildDescriptor.java
// public abstract class AbstractCloudCommandPostBuildDescriptor extends BuildStepDescriptor<Publisher> {
// @Inject
// CloudTestServer.DescriptorImpl serverDescriptor;
//
// @Override
// public boolean isApplicable(Class<? extends AbstractProject> jobType) {
// return true;
// }
//
// /**
// * Called automatically by Jenkins whenever the "Name"
// * field is modified by the user.
// */
// public FormValidation doCheckName(@QueryParameter String value)
// {
// if (value == null || value.trim().isEmpty())
// {
// return FormValidation.error("Name is Required");
// }
// else
// {
// return FormValidation.ok();
// }
// }
//
// public ListBoxModel doFillCloudTestServerIDItems() {
// ListBoxModel r = new ListBoxModel();
// for (CloudTestServer s : serverDescriptor.getServers()) {
// r.add(s.getName(), s.getId());
// }
// return r;
// }
//
// protected FormValidation validateFileMask(AbstractProject project, String value) throws IOException {
// if (value.contains("${")) {
// // if the value contains a variable reference, bail out from the check because we can end up
// // warning a file that actually resolves correctly at the runtime
// // the same change is made in FilePath.validateFileMask independently, and in the future
// // we can remove this check from here
// return FormValidation.ok();
// }
//
// // Make sure the file exists.
// return FilePath.validateFileMask(project.getSomeWorkspace(), value);
// }
// }
| import hudson.Extension;
import org.jenkinsci.Symbol;
import org.kohsuke.stapler.DataBoundConstructor;
import com.soasta.jenkins.cloud.CloudStatus;
import com.soasta.jenkins.cloud.postbuild.AbstractCloudCommandPostBuildDescriptor; | /*
* Copyright (c) 2015, CloudBees, Inc., SOASTA, Inc.
* All Rights Reserved.
*/
package com.soasta.jenkins.cloud.postbuild;
public class StartGrid extends CloudCommandBasePostBuild
{
@DataBoundConstructor
public StartGrid(String url, String cloudTestServerID, String name, int timeOut)
{
super(url, cloudTestServerID, name, timeOut);
}
@Extension
@Symbol("startGrid") | // Path: src/main/java/com/soasta/jenkins/cloud/CloudStatus.java
// public enum CloudStatus
// {
// TERMINATED,
// READY,
// FAILED
// }
//
// Path: src/main/java/com/soasta/jenkins/cloud/postbuild/AbstractCloudCommandPostBuildDescriptor.java
// public abstract class AbstractCloudCommandPostBuildDescriptor extends BuildStepDescriptor<Publisher> {
// @Inject
// CloudTestServer.DescriptorImpl serverDescriptor;
//
// @Override
// public boolean isApplicable(Class<? extends AbstractProject> jobType) {
// return true;
// }
//
// /**
// * Called automatically by Jenkins whenever the "Name"
// * field is modified by the user.
// */
// public FormValidation doCheckName(@QueryParameter String value)
// {
// if (value == null || value.trim().isEmpty())
// {
// return FormValidation.error("Name is Required");
// }
// else
// {
// return FormValidation.ok();
// }
// }
//
// public ListBoxModel doFillCloudTestServerIDItems() {
// ListBoxModel r = new ListBoxModel();
// for (CloudTestServer s : serverDescriptor.getServers()) {
// r.add(s.getName(), s.getId());
// }
// return r;
// }
//
// protected FormValidation validateFileMask(AbstractProject project, String value) throws IOException {
// if (value.contains("${")) {
// // if the value contains a variable reference, bail out from the check because we can end up
// // warning a file that actually resolves correctly at the runtime
// // the same change is made in FilePath.validateFileMask independently, and in the future
// // we can remove this check from here
// return FormValidation.ok();
// }
//
// // Make sure the file exists.
// return FilePath.validateFileMask(project.getSomeWorkspace(), value);
// }
// }
// Path: src/main/java/com/soasta/jenkins/cloud/postbuild/StartGrid.java
import hudson.Extension;
import org.jenkinsci.Symbol;
import org.kohsuke.stapler.DataBoundConstructor;
import com.soasta.jenkins.cloud.CloudStatus;
import com.soasta.jenkins.cloud.postbuild.AbstractCloudCommandPostBuildDescriptor;
/*
* Copyright (c) 2015, CloudBees, Inc., SOASTA, Inc.
* All Rights Reserved.
*/
package com.soasta.jenkins.cloud.postbuild;
public class StartGrid extends CloudCommandBasePostBuild
{
@DataBoundConstructor
public StartGrid(String url, String cloudTestServerID, String name, int timeOut)
{
super(url, cloudTestServerID, name, timeOut);
}
@Extension
@Symbol("startGrid") | public static class DescriptorImpl extends AbstractCloudCommandPostBuildDescriptor |
jenkinsci/cloudtest-plugin | src/main/java/com/soasta/jenkins/cloud/postbuild/StartGrid.java | // Path: src/main/java/com/soasta/jenkins/cloud/CloudStatus.java
// public enum CloudStatus
// {
// TERMINATED,
// READY,
// FAILED
// }
//
// Path: src/main/java/com/soasta/jenkins/cloud/postbuild/AbstractCloudCommandPostBuildDescriptor.java
// public abstract class AbstractCloudCommandPostBuildDescriptor extends BuildStepDescriptor<Publisher> {
// @Inject
// CloudTestServer.DescriptorImpl serverDescriptor;
//
// @Override
// public boolean isApplicable(Class<? extends AbstractProject> jobType) {
// return true;
// }
//
// /**
// * Called automatically by Jenkins whenever the "Name"
// * field is modified by the user.
// */
// public FormValidation doCheckName(@QueryParameter String value)
// {
// if (value == null || value.trim().isEmpty())
// {
// return FormValidation.error("Name is Required");
// }
// else
// {
// return FormValidation.ok();
// }
// }
//
// public ListBoxModel doFillCloudTestServerIDItems() {
// ListBoxModel r = new ListBoxModel();
// for (CloudTestServer s : serverDescriptor.getServers()) {
// r.add(s.getName(), s.getId());
// }
// return r;
// }
//
// protected FormValidation validateFileMask(AbstractProject project, String value) throws IOException {
// if (value.contains("${")) {
// // if the value contains a variable reference, bail out from the check because we can end up
// // warning a file that actually resolves correctly at the runtime
// // the same change is made in FilePath.validateFileMask independently, and in the future
// // we can remove this check from here
// return FormValidation.ok();
// }
//
// // Make sure the file exists.
// return FilePath.validateFileMask(project.getSomeWorkspace(), value);
// }
// }
| import hudson.Extension;
import org.jenkinsci.Symbol;
import org.kohsuke.stapler.DataBoundConstructor;
import com.soasta.jenkins.cloud.CloudStatus;
import com.soasta.jenkins.cloud.postbuild.AbstractCloudCommandPostBuildDescriptor; | /*
* Copyright (c) 2015, CloudBees, Inc., SOASTA, Inc.
* All Rights Reserved.
*/
package com.soasta.jenkins.cloud.postbuild;
public class StartGrid extends CloudCommandBasePostBuild
{
@DataBoundConstructor
public StartGrid(String url, String cloudTestServerID, String name, int timeOut)
{
super(url, cloudTestServerID, name, timeOut);
}
@Extension
@Symbol("startGrid")
public static class DescriptorImpl extends AbstractCloudCommandPostBuildDescriptor
{
@Override
public String getDisplayName()
{
return "Start Grid";
}
}
@Override
public String getCommand()
{
return "start-grid";
}
@Override
public int getDefaultTimeout()
{
return 600;
}
@Override | // Path: src/main/java/com/soasta/jenkins/cloud/CloudStatus.java
// public enum CloudStatus
// {
// TERMINATED,
// READY,
// FAILED
// }
//
// Path: src/main/java/com/soasta/jenkins/cloud/postbuild/AbstractCloudCommandPostBuildDescriptor.java
// public abstract class AbstractCloudCommandPostBuildDescriptor extends BuildStepDescriptor<Publisher> {
// @Inject
// CloudTestServer.DescriptorImpl serverDescriptor;
//
// @Override
// public boolean isApplicable(Class<? extends AbstractProject> jobType) {
// return true;
// }
//
// /**
// * Called automatically by Jenkins whenever the "Name"
// * field is modified by the user.
// */
// public FormValidation doCheckName(@QueryParameter String value)
// {
// if (value == null || value.trim().isEmpty())
// {
// return FormValidation.error("Name is Required");
// }
// else
// {
// return FormValidation.ok();
// }
// }
//
// public ListBoxModel doFillCloudTestServerIDItems() {
// ListBoxModel r = new ListBoxModel();
// for (CloudTestServer s : serverDescriptor.getServers()) {
// r.add(s.getName(), s.getId());
// }
// return r;
// }
//
// protected FormValidation validateFileMask(AbstractProject project, String value) throws IOException {
// if (value.contains("${")) {
// // if the value contains a variable reference, bail out from the check because we can end up
// // warning a file that actually resolves correctly at the runtime
// // the same change is made in FilePath.validateFileMask independently, and in the future
// // we can remove this check from here
// return FormValidation.ok();
// }
//
// // Make sure the file exists.
// return FilePath.validateFileMask(project.getSomeWorkspace(), value);
// }
// }
// Path: src/main/java/com/soasta/jenkins/cloud/postbuild/StartGrid.java
import hudson.Extension;
import org.jenkinsci.Symbol;
import org.kohsuke.stapler.DataBoundConstructor;
import com.soasta.jenkins.cloud.CloudStatus;
import com.soasta.jenkins.cloud.postbuild.AbstractCloudCommandPostBuildDescriptor;
/*
* Copyright (c) 2015, CloudBees, Inc., SOASTA, Inc.
* All Rights Reserved.
*/
package com.soasta.jenkins.cloud.postbuild;
public class StartGrid extends CloudCommandBasePostBuild
{
@DataBoundConstructor
public StartGrid(String url, String cloudTestServerID, String name, int timeOut)
{
super(url, cloudTestServerID, name, timeOut);
}
@Extension
@Symbol("startGrid")
public static class DescriptorImpl extends AbstractCloudCommandPostBuildDescriptor
{
@Override
public String getDisplayName()
{
return "Start Grid";
}
}
@Override
public String getCommand()
{
return "start-grid";
}
@Override
public int getDefaultTimeout()
{
return 600;
}
@Override | public CloudStatus getSuccessStatus() |
jenkinsci/cloudtest-plugin | src/main/java/com/soasta/jenkins/cloud/postbuild/StopGrid.java | // Path: src/main/java/com/soasta/jenkins/cloud/CloudStatus.java
// public enum CloudStatus
// {
// TERMINATED,
// READY,
// FAILED
// }
| import org.jenkinsci.Symbol;
import org.kohsuke.stapler.DataBoundConstructor;
import com.soasta.jenkins.cloud.CloudStatus;
import hudson.Extension; | /*
* Copyright (c) 2015, CloudBees, Inc., SOASTA, Inc.
* All Rights Reserved.
*/
package com.soasta.jenkins.cloud.postbuild;
public class StopGrid extends CloudCommandBasePostBuild
{
@DataBoundConstructor
public StopGrid(String url, String cloudTestServerID, String name)
{
super(url, cloudTestServerID, name);
}
@Extension
@Symbol("stopGrid")
public static class DescriptorImpl extends AbstractCloudCommandPostBuildDescriptor
{
@Override
public String getDisplayName()
{
return "Stop Grid";
}
}
@Override
public String getCommand()
{
return "terminate-grid";
}
@Override
public int getDefaultTimeout()
{
return 600;
}
@Override | // Path: src/main/java/com/soasta/jenkins/cloud/CloudStatus.java
// public enum CloudStatus
// {
// TERMINATED,
// READY,
// FAILED
// }
// Path: src/main/java/com/soasta/jenkins/cloud/postbuild/StopGrid.java
import org.jenkinsci.Symbol;
import org.kohsuke.stapler.DataBoundConstructor;
import com.soasta.jenkins.cloud.CloudStatus;
import hudson.Extension;
/*
* Copyright (c) 2015, CloudBees, Inc., SOASTA, Inc.
* All Rights Reserved.
*/
package com.soasta.jenkins.cloud.postbuild;
public class StopGrid extends CloudCommandBasePostBuild
{
@DataBoundConstructor
public StopGrid(String url, String cloudTestServerID, String name)
{
super(url, cloudTestServerID, name);
}
@Extension
@Symbol("stopGrid")
public static class DescriptorImpl extends AbstractCloudCommandPostBuildDescriptor
{
@Override
public String getDisplayName()
{
return "Stop Grid";
}
}
@Override
public String getCommand()
{
return "terminate-grid";
}
@Override
public int getDefaultTimeout()
{
return 600;
}
@Override | public CloudStatus getSuccessStatus() |
jenkinsci/cloudtest-plugin | src/main/java/com/soasta/jenkins/cloud/build/StartRSDB.java | // Path: src/main/java/com/soasta/jenkins/cloud/CloudStatus.java
// public enum CloudStatus
// {
// TERMINATED,
// READY,
// FAILED
// }
| import org.jenkinsci.Symbol;
import org.kohsuke.stapler.DataBoundConstructor;
import com.soasta.jenkins.cloud.CloudStatus;
import hudson.Extension; | /*
* Copyright (c) 2015, CloudBees, Inc., SOASTA, Inc.
* All Rights Reserved.
*/
package com.soasta.jenkins.cloud.build;
public class StartRSDB extends CloudCommandBaseBuild
{
@DataBoundConstructor
public StartRSDB(String url, String cloudTestServerID, String name, int timeOut)
{
super(url, cloudTestServerID, name, timeOut);
}
@Extension
@Symbol("startRSDB")
public static class DescriptorImpl extends AbstractCloudCommandBuildDescriptor
{
@Override
public String getDisplayName()
{
return "Start RSDB";
}
}
@Override
public String getCommand()
{
return "start-rsdb";
}
@Override
public int getDefaultTimeout()
{
return 1200;
}
@Override | // Path: src/main/java/com/soasta/jenkins/cloud/CloudStatus.java
// public enum CloudStatus
// {
// TERMINATED,
// READY,
// FAILED
// }
// Path: src/main/java/com/soasta/jenkins/cloud/build/StartRSDB.java
import org.jenkinsci.Symbol;
import org.kohsuke.stapler.DataBoundConstructor;
import com.soasta.jenkins.cloud.CloudStatus;
import hudson.Extension;
/*
* Copyright (c) 2015, CloudBees, Inc., SOASTA, Inc.
* All Rights Reserved.
*/
package com.soasta.jenkins.cloud.build;
public class StartRSDB extends CloudCommandBaseBuild
{
@DataBoundConstructor
public StartRSDB(String url, String cloudTestServerID, String name, int timeOut)
{
super(url, cloudTestServerID, name, timeOut);
}
@Extension
@Symbol("startRSDB")
public static class DescriptorImpl extends AbstractCloudCommandBuildDescriptor
{
@Override
public String getDisplayName()
{
return "Start RSDB";
}
}
@Override
public String getCommand()
{
return "start-rsdb";
}
@Override
public int getDefaultTimeout()
{
return 1200;
}
@Override | public CloudStatus getSuccessStatus() |
jenkinsci/cloudtest-plugin | src/main/java/com/soasta/jenkins/cloud/postbuild/StartTestEnvironment.java | // Path: src/main/java/com/soasta/jenkins/cloud/CloudStatus.java
// public enum CloudStatus
// {
// TERMINATED,
// READY,
// FAILED
// }
| import org.jenkinsci.Symbol;
import org.kohsuke.stapler.DataBoundConstructor;
import com.soasta.jenkins.cloud.CloudStatus;
import hudson.Extension; | /**
* Copyright (c) 2015, CloudBees, Inc., SOASTA, Inc.
* All Rights Reserved.
*/
package com.soasta.jenkins.cloud.postbuild;
public class StartTestEnvironment extends CloudCommandBasePostBuild
{
@DataBoundConstructor
public StartTestEnvironment(String url, String cloudTestServerID, String name, int timeOut)
{
super(url, cloudTestServerID, name, timeOut);
}
@Extension
@Symbol("startTestEnvironment")
public static class DescriptorImpl extends AbstractCloudCommandPostBuildDescriptor
{
@Override
public String getDisplayName()
{
return "Start Test Environment";
}
}
@Override
public String getCommand()
{
return "start-env";
}
@Override
public int getDefaultTimeout()
{
return 1200;
}
@Override | // Path: src/main/java/com/soasta/jenkins/cloud/CloudStatus.java
// public enum CloudStatus
// {
// TERMINATED,
// READY,
// FAILED
// }
// Path: src/main/java/com/soasta/jenkins/cloud/postbuild/StartTestEnvironment.java
import org.jenkinsci.Symbol;
import org.kohsuke.stapler.DataBoundConstructor;
import com.soasta.jenkins.cloud.CloudStatus;
import hudson.Extension;
/**
* Copyright (c) 2015, CloudBees, Inc., SOASTA, Inc.
* All Rights Reserved.
*/
package com.soasta.jenkins.cloud.postbuild;
public class StartTestEnvironment extends CloudCommandBasePostBuild
{
@DataBoundConstructor
public StartTestEnvironment(String url, String cloudTestServerID, String name, int timeOut)
{
super(url, cloudTestServerID, name, timeOut);
}
@Extension
@Symbol("startTestEnvironment")
public static class DescriptorImpl extends AbstractCloudCommandPostBuildDescriptor
{
@Override
public String getDisplayName()
{
return "Start Test Environment";
}
}
@Override
public String getCommand()
{
return "start-env";
}
@Override
public int getDefaultTimeout()
{
return 1200;
}
@Override | public CloudStatus getSuccessStatus() |
andforce/SmartZPN | app/src/main/java/org/zarroboogs/smartzpn/utils/TokenUtils.java | // Path: app/src/main/java/org/zarroboogs/smartzpn/SmartZpnApplication.java
// public class SmartZpnApplication extends Application {
// private static Context mContext;
//
// @Override
// public void onCreate() {
// super.onCreate();
// mContext = this.getApplicationContext();
// }
//
// public static Context getContext() {
// return mContext;
// }
// }
| import android.content.Context;
import android.content.SharedPreferences;
import org.zarroboogs.smartzpn.SmartZpnApplication; | package org.zarroboogs.smartzpn.utils;
/**
* Created by wangdiyuan on 15-8-13.
*/
public class TokenUtils {
private static final String TOKEN = "token";
private static final String SPEC = "spec";
| // Path: app/src/main/java/org/zarroboogs/smartzpn/SmartZpnApplication.java
// public class SmartZpnApplication extends Application {
// private static Context mContext;
//
// @Override
// public void onCreate() {
// super.onCreate();
// mContext = this.getApplicationContext();
// }
//
// public static Context getContext() {
// return mContext;
// }
// }
// Path: app/src/main/java/org/zarroboogs/smartzpn/utils/TokenUtils.java
import android.content.Context;
import android.content.SharedPreferences;
import org.zarroboogs.smartzpn.SmartZpnApplication;
package org.zarroboogs.smartzpn.utils;
/**
* Created by wangdiyuan on 15-8-13.
*/
public class TokenUtils {
private static final String TOKEN = "token";
private static final String SPEC = "spec";
| private static SharedPreferences mSharedPreferences = SmartZpnApplication.getContext().getSharedPreferences(SmartZpnApplication.getContext().getPackageName(), Context.MODE_PRIVATE); |
IHTSDO/snomed-boot | src/main/java/org/ihtsdo/otf/snomedboot/factory/LoadingProfile.java | // Path: src/main/java/org/ihtsdo/otf/snomedboot/domain/ConceptConstants.java
// public interface ConceptConstants {
// String ROOT_CONCEPT = "138875005";
// String isA = "116680003";
// String FSN = "900000000000003001";
// String REFSET_CONCEPT = "900000000000455006";
// String CORE_MODULE = "900000000000207008";
// String MODEL_MODULE = "900000000000012004";
// String MODEL_CONCEPT = "900000000000441003";
// String GB_EN_LANGUAGE_REFERENCE_SET = "900000000000508004";
// String US_EN_LANGUAGE_REFERENCE_SET = "900000000000509007";
// String STATED_RELATIONSHIP = "900000000000010007";
// String INFERRED_RELATIONSHIP = "900000000000011006";
// }
| import com.google.common.collect.ImmutableSet;
import org.ihtsdo.otf.snomedboot.domain.ConceptConstants;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set; | package org.ihtsdo.otf.snomedboot.factory;
public class LoadingProfile implements Cloneable {
public static final LoadingProfile light = new LoadingProfile();
public static final LoadingProfile complete = new LoadingProfile();
static {
light.inferredAttributeMapOnConcept = true;
light.descriptions = true; | // Path: src/main/java/org/ihtsdo/otf/snomedboot/domain/ConceptConstants.java
// public interface ConceptConstants {
// String ROOT_CONCEPT = "138875005";
// String isA = "116680003";
// String FSN = "900000000000003001";
// String REFSET_CONCEPT = "900000000000455006";
// String CORE_MODULE = "900000000000207008";
// String MODEL_MODULE = "900000000000012004";
// String MODEL_CONCEPT = "900000000000441003";
// String GB_EN_LANGUAGE_REFERENCE_SET = "900000000000508004";
// String US_EN_LANGUAGE_REFERENCE_SET = "900000000000509007";
// String STATED_RELATIONSHIP = "900000000000010007";
// String INFERRED_RELATIONSHIP = "900000000000011006";
// }
// Path: src/main/java/org/ihtsdo/otf/snomedboot/factory/LoadingProfile.java
import com.google.common.collect.ImmutableSet;
import org.ihtsdo.otf.snomedboot.domain.ConceptConstants;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
package org.ihtsdo.otf.snomedboot.factory;
public class LoadingProfile implements Cloneable {
public static final LoadingProfile light = new LoadingProfile();
public static final LoadingProfile complete = new LoadingProfile();
static {
light.inferredAttributeMapOnConcept = true;
light.descriptions = true; | light.refsetIds.add(ConceptConstants.GB_EN_LANGUAGE_REFERENCE_SET); |
IHTSDO/snomed-boot | src/main/java/org/ihtsdo/otf/snomedboot/factory/implementation/HighLevelComponentFactoryAdapterImpl.java | // Path: src/main/java/org/ihtsdo/otf/snomedboot/domain/ConceptConstants.java
// public interface ConceptConstants {
// String ROOT_CONCEPT = "138875005";
// String isA = "116680003";
// String FSN = "900000000000003001";
// String REFSET_CONCEPT = "900000000000455006";
// String CORE_MODULE = "900000000000207008";
// String MODEL_MODULE = "900000000000012004";
// String MODEL_CONCEPT = "900000000000441003";
// String GB_EN_LANGUAGE_REFERENCE_SET = "900000000000508004";
// String US_EN_LANGUAGE_REFERENCE_SET = "900000000000509007";
// String STATED_RELATIONSHIP = "900000000000010007";
// String INFERRED_RELATIONSHIP = "900000000000011006";
// }
| import org.ihtsdo.otf.snomedboot.domain.ConceptConstants;
import org.ihtsdo.otf.snomedboot.factory.*; | package org.ihtsdo.otf.snomedboot.factory.implementation;
public class HighLevelComponentFactoryAdapterImpl implements ComponentFactory {
private final LoadingProfile loadingProfile;
private final HighLevelComponentFactory highLevelFactory;
private final ComponentFactory delegateComponentFactory;
public HighLevelComponentFactoryAdapterImpl(final LoadingProfile loadingProfile, HighLevelComponentFactory highLevelComponentFactory, ComponentFactory delegateComponentFactory) {
this.loadingProfile = loadingProfile;
this.highLevelFactory = highLevelComponentFactory;
this.delegateComponentFactory = delegateComponentFactory;
}
@Override
public void preprocessingContent() {
delegateComponentFactory.preprocessingContent();
}
@Override
public void loadingComponentsStarting() {
delegateComponentFactory.loadingComponentsStarting();
}
@Override
public void loadingComponentsCompleted() {
delegateComponentFactory.loadingComponentsCompleted();
}
@Override
public void newConceptState(String conceptId, String effectiveTime, String active, String moduleId, String definitionStatusId) {
delegateComponentFactory.newConceptState(conceptId, effectiveTime, active, moduleId, definitionStatusId);
}
@Override
public void newDescriptionState(String id, String effectiveTime, String active, String moduleId, String conceptId, String languageCode, String typeId, String term, String caseSignificanceId) { | // Path: src/main/java/org/ihtsdo/otf/snomedboot/domain/ConceptConstants.java
// public interface ConceptConstants {
// String ROOT_CONCEPT = "138875005";
// String isA = "116680003";
// String FSN = "900000000000003001";
// String REFSET_CONCEPT = "900000000000455006";
// String CORE_MODULE = "900000000000207008";
// String MODEL_MODULE = "900000000000012004";
// String MODEL_CONCEPT = "900000000000441003";
// String GB_EN_LANGUAGE_REFERENCE_SET = "900000000000508004";
// String US_EN_LANGUAGE_REFERENCE_SET = "900000000000509007";
// String STATED_RELATIONSHIP = "900000000000010007";
// String INFERRED_RELATIONSHIP = "900000000000011006";
// }
// Path: src/main/java/org/ihtsdo/otf/snomedboot/factory/implementation/HighLevelComponentFactoryAdapterImpl.java
import org.ihtsdo.otf.snomedboot.domain.ConceptConstants;
import org.ihtsdo.otf.snomedboot.factory.*;
package org.ihtsdo.otf.snomedboot.factory.implementation;
public class HighLevelComponentFactoryAdapterImpl implements ComponentFactory {
private final LoadingProfile loadingProfile;
private final HighLevelComponentFactory highLevelFactory;
private final ComponentFactory delegateComponentFactory;
public HighLevelComponentFactoryAdapterImpl(final LoadingProfile loadingProfile, HighLevelComponentFactory highLevelComponentFactory, ComponentFactory delegateComponentFactory) {
this.loadingProfile = loadingProfile;
this.highLevelFactory = highLevelComponentFactory;
this.delegateComponentFactory = delegateComponentFactory;
}
@Override
public void preprocessingContent() {
delegateComponentFactory.preprocessingContent();
}
@Override
public void loadingComponentsStarting() {
delegateComponentFactory.loadingComponentsStarting();
}
@Override
public void loadingComponentsCompleted() {
delegateComponentFactory.loadingComponentsCompleted();
}
@Override
public void newConceptState(String conceptId, String effectiveTime, String active, String moduleId, String definitionStatusId) {
delegateComponentFactory.newConceptState(conceptId, effectiveTime, active, moduleId, definitionStatusId);
}
@Override
public void newDescriptionState(String id, String effectiveTime, String active, String moduleId, String conceptId, String languageCode, String typeId, String term, String caseSignificanceId) { | if (isActive(active) && ConceptConstants.FSN.equals(typeId)) { |
IHTSDO/snomed-boot | src/main/java/org/ihtsdo/otf/snomedboot/factory/implementation/standard/ConceptImpl.java | // Path: src/main/java/org/ihtsdo/otf/snomedboot/domain/Concept.java
// public interface Concept {
// Long getId();
//
// Set<Long> getMemberOfRefsetIds();
//
// Set<Long> getInferredAncestorIds() throws IllegalStateException;
//
// Set<Long> getStatedAncestorIds() throws IllegalStateException;
//
// boolean isActive();
//
// String getEffectiveTime();
//
// String getModuleId();
//
// String getDefinitionStatusId();
//
// String getFsn();
//
// Map<String, Set<String>> getInferredAttributes();
//
// Map<String, Set<String>> getInferredConcreteAttributes();
//
// Map<String, Set<String>> getStatedAttributes();
//
// List<Relationship> getRelationships();
//
// List<ConcreteRelationship> getConcreteRelationships();
//
// List<Description> getDescriptions();
//
// Set<Long> getInferredDescendantIds() throws IllegalStateException;
//
// Set<Long> getStatedDescendantIds() throws IllegalStateException;
// }
//
// Path: src/main/java/org/ihtsdo/otf/snomedboot/domain/ConcreteRelationship.java
// public interface ConcreteRelationship {
// String getId();
//
// String getEffectiveTime();
//
// String getActive();
//
// String getModuleId();
//
// String getSourceId();
//
// String getValue();
//
// String getRelationshipGroup();
//
// String getTypeId();
//
// String getCharacteristicTypeId();
//
// String getModifierId();
// }
//
// Path: src/main/java/org/ihtsdo/otf/snomedboot/domain/Description.java
// public interface Description {
// Long getId();
//
// boolean isActive();
//
// String getTerm();
//
// Long getConceptId();
// }
//
// Path: src/main/java/org/ihtsdo/otf/snomedboot/domain/Relationship.java
// public interface Relationship {
// String getId();
//
// String getEffectiveTime();
//
// String getActive();
//
// String getModuleId();
//
// String getSourceId();
//
// String getDestinationId();
//
// String getRelationshipGroup();
//
// String getTypeId();
//
// String getCharacteristicTypeId();
//
// String getModifierId();
// }
| import org.ihtsdo.otf.snomedboot.domain.Concept;
import org.ihtsdo.otf.snomedboot.domain.ConcreteRelationship;
import org.ihtsdo.otf.snomedboot.domain.Description;
import org.ihtsdo.otf.snomedboot.domain.Relationship;
import java.util.*; | package org.ihtsdo.otf.snomedboot.factory.implementation.standard;
public class ConceptImpl implements Concept {
private final Long id;
private String effectiveTime;
private boolean active;
private String moduleId;
private String definitionStatusId;
private String fsn;
private final Map<String, Set<String>> inferredAttributes;
private final Map<String, Set<String>> inferredConcreteAttributes;
private final Map<String, Set<String>> statedAttributes;
private final Set<Concept> inferredParents;
private final Set<Concept> statedParents;
private final Set<Concept> inferredChildren;
private final Set<Concept> statedChildren;
private final Set<Long> memberOfRefsetIds; | // Path: src/main/java/org/ihtsdo/otf/snomedboot/domain/Concept.java
// public interface Concept {
// Long getId();
//
// Set<Long> getMemberOfRefsetIds();
//
// Set<Long> getInferredAncestorIds() throws IllegalStateException;
//
// Set<Long> getStatedAncestorIds() throws IllegalStateException;
//
// boolean isActive();
//
// String getEffectiveTime();
//
// String getModuleId();
//
// String getDefinitionStatusId();
//
// String getFsn();
//
// Map<String, Set<String>> getInferredAttributes();
//
// Map<String, Set<String>> getInferredConcreteAttributes();
//
// Map<String, Set<String>> getStatedAttributes();
//
// List<Relationship> getRelationships();
//
// List<ConcreteRelationship> getConcreteRelationships();
//
// List<Description> getDescriptions();
//
// Set<Long> getInferredDescendantIds() throws IllegalStateException;
//
// Set<Long> getStatedDescendantIds() throws IllegalStateException;
// }
//
// Path: src/main/java/org/ihtsdo/otf/snomedboot/domain/ConcreteRelationship.java
// public interface ConcreteRelationship {
// String getId();
//
// String getEffectiveTime();
//
// String getActive();
//
// String getModuleId();
//
// String getSourceId();
//
// String getValue();
//
// String getRelationshipGroup();
//
// String getTypeId();
//
// String getCharacteristicTypeId();
//
// String getModifierId();
// }
//
// Path: src/main/java/org/ihtsdo/otf/snomedboot/domain/Description.java
// public interface Description {
// Long getId();
//
// boolean isActive();
//
// String getTerm();
//
// Long getConceptId();
// }
//
// Path: src/main/java/org/ihtsdo/otf/snomedboot/domain/Relationship.java
// public interface Relationship {
// String getId();
//
// String getEffectiveTime();
//
// String getActive();
//
// String getModuleId();
//
// String getSourceId();
//
// String getDestinationId();
//
// String getRelationshipGroup();
//
// String getTypeId();
//
// String getCharacteristicTypeId();
//
// String getModifierId();
// }
// Path: src/main/java/org/ihtsdo/otf/snomedboot/factory/implementation/standard/ConceptImpl.java
import org.ihtsdo.otf.snomedboot.domain.Concept;
import org.ihtsdo.otf.snomedboot.domain.ConcreteRelationship;
import org.ihtsdo.otf.snomedboot.domain.Description;
import org.ihtsdo.otf.snomedboot.domain.Relationship;
import java.util.*;
package org.ihtsdo.otf.snomedboot.factory.implementation.standard;
public class ConceptImpl implements Concept {
private final Long id;
private String effectiveTime;
private boolean active;
private String moduleId;
private String definitionStatusId;
private String fsn;
private final Map<String, Set<String>> inferredAttributes;
private final Map<String, Set<String>> inferredConcreteAttributes;
private final Map<String, Set<String>> statedAttributes;
private final Set<Concept> inferredParents;
private final Set<Concept> statedParents;
private final Set<Concept> inferredChildren;
private final Set<Concept> statedChildren;
private final Set<Long> memberOfRefsetIds; | private final List<Relationship> relationships; |
IHTSDO/snomed-boot | src/main/java/org/ihtsdo/otf/snomedboot/factory/implementation/standard/ConceptImpl.java | // Path: src/main/java/org/ihtsdo/otf/snomedboot/domain/Concept.java
// public interface Concept {
// Long getId();
//
// Set<Long> getMemberOfRefsetIds();
//
// Set<Long> getInferredAncestorIds() throws IllegalStateException;
//
// Set<Long> getStatedAncestorIds() throws IllegalStateException;
//
// boolean isActive();
//
// String getEffectiveTime();
//
// String getModuleId();
//
// String getDefinitionStatusId();
//
// String getFsn();
//
// Map<String, Set<String>> getInferredAttributes();
//
// Map<String, Set<String>> getInferredConcreteAttributes();
//
// Map<String, Set<String>> getStatedAttributes();
//
// List<Relationship> getRelationships();
//
// List<ConcreteRelationship> getConcreteRelationships();
//
// List<Description> getDescriptions();
//
// Set<Long> getInferredDescendantIds() throws IllegalStateException;
//
// Set<Long> getStatedDescendantIds() throws IllegalStateException;
// }
//
// Path: src/main/java/org/ihtsdo/otf/snomedboot/domain/ConcreteRelationship.java
// public interface ConcreteRelationship {
// String getId();
//
// String getEffectiveTime();
//
// String getActive();
//
// String getModuleId();
//
// String getSourceId();
//
// String getValue();
//
// String getRelationshipGroup();
//
// String getTypeId();
//
// String getCharacteristicTypeId();
//
// String getModifierId();
// }
//
// Path: src/main/java/org/ihtsdo/otf/snomedboot/domain/Description.java
// public interface Description {
// Long getId();
//
// boolean isActive();
//
// String getTerm();
//
// Long getConceptId();
// }
//
// Path: src/main/java/org/ihtsdo/otf/snomedboot/domain/Relationship.java
// public interface Relationship {
// String getId();
//
// String getEffectiveTime();
//
// String getActive();
//
// String getModuleId();
//
// String getSourceId();
//
// String getDestinationId();
//
// String getRelationshipGroup();
//
// String getTypeId();
//
// String getCharacteristicTypeId();
//
// String getModifierId();
// }
| import org.ihtsdo.otf.snomedboot.domain.Concept;
import org.ihtsdo.otf.snomedboot.domain.ConcreteRelationship;
import org.ihtsdo.otf.snomedboot.domain.Description;
import org.ihtsdo.otf.snomedboot.domain.Relationship;
import java.util.*; | package org.ihtsdo.otf.snomedboot.factory.implementation.standard;
public class ConceptImpl implements Concept {
private final Long id;
private String effectiveTime;
private boolean active;
private String moduleId;
private String definitionStatusId;
private String fsn;
private final Map<String, Set<String>> inferredAttributes;
private final Map<String, Set<String>> inferredConcreteAttributes;
private final Map<String, Set<String>> statedAttributes;
private final Set<Concept> inferredParents;
private final Set<Concept> statedParents;
private final Set<Concept> inferredChildren;
private final Set<Concept> statedChildren;
private final Set<Long> memberOfRefsetIds;
private final List<Relationship> relationships; | // Path: src/main/java/org/ihtsdo/otf/snomedboot/domain/Concept.java
// public interface Concept {
// Long getId();
//
// Set<Long> getMemberOfRefsetIds();
//
// Set<Long> getInferredAncestorIds() throws IllegalStateException;
//
// Set<Long> getStatedAncestorIds() throws IllegalStateException;
//
// boolean isActive();
//
// String getEffectiveTime();
//
// String getModuleId();
//
// String getDefinitionStatusId();
//
// String getFsn();
//
// Map<String, Set<String>> getInferredAttributes();
//
// Map<String, Set<String>> getInferredConcreteAttributes();
//
// Map<String, Set<String>> getStatedAttributes();
//
// List<Relationship> getRelationships();
//
// List<ConcreteRelationship> getConcreteRelationships();
//
// List<Description> getDescriptions();
//
// Set<Long> getInferredDescendantIds() throws IllegalStateException;
//
// Set<Long> getStatedDescendantIds() throws IllegalStateException;
// }
//
// Path: src/main/java/org/ihtsdo/otf/snomedboot/domain/ConcreteRelationship.java
// public interface ConcreteRelationship {
// String getId();
//
// String getEffectiveTime();
//
// String getActive();
//
// String getModuleId();
//
// String getSourceId();
//
// String getValue();
//
// String getRelationshipGroup();
//
// String getTypeId();
//
// String getCharacteristicTypeId();
//
// String getModifierId();
// }
//
// Path: src/main/java/org/ihtsdo/otf/snomedboot/domain/Description.java
// public interface Description {
// Long getId();
//
// boolean isActive();
//
// String getTerm();
//
// Long getConceptId();
// }
//
// Path: src/main/java/org/ihtsdo/otf/snomedboot/domain/Relationship.java
// public interface Relationship {
// String getId();
//
// String getEffectiveTime();
//
// String getActive();
//
// String getModuleId();
//
// String getSourceId();
//
// String getDestinationId();
//
// String getRelationshipGroup();
//
// String getTypeId();
//
// String getCharacteristicTypeId();
//
// String getModifierId();
// }
// Path: src/main/java/org/ihtsdo/otf/snomedboot/factory/implementation/standard/ConceptImpl.java
import org.ihtsdo.otf.snomedboot.domain.Concept;
import org.ihtsdo.otf.snomedboot.domain.ConcreteRelationship;
import org.ihtsdo.otf.snomedboot.domain.Description;
import org.ihtsdo.otf.snomedboot.domain.Relationship;
import java.util.*;
package org.ihtsdo.otf.snomedboot.factory.implementation.standard;
public class ConceptImpl implements Concept {
private final Long id;
private String effectiveTime;
private boolean active;
private String moduleId;
private String definitionStatusId;
private String fsn;
private final Map<String, Set<String>> inferredAttributes;
private final Map<String, Set<String>> inferredConcreteAttributes;
private final Map<String, Set<String>> statedAttributes;
private final Set<Concept> inferredParents;
private final Set<Concept> statedParents;
private final Set<Concept> inferredChildren;
private final Set<Concept> statedChildren;
private final Set<Long> memberOfRefsetIds;
private final List<Relationship> relationships; | private final List<ConcreteRelationship> concreteRelationships; |
IHTSDO/snomed-boot | src/main/java/org/ihtsdo/otf/snomedboot/factory/implementation/standard/ConceptImpl.java | // Path: src/main/java/org/ihtsdo/otf/snomedboot/domain/Concept.java
// public interface Concept {
// Long getId();
//
// Set<Long> getMemberOfRefsetIds();
//
// Set<Long> getInferredAncestorIds() throws IllegalStateException;
//
// Set<Long> getStatedAncestorIds() throws IllegalStateException;
//
// boolean isActive();
//
// String getEffectiveTime();
//
// String getModuleId();
//
// String getDefinitionStatusId();
//
// String getFsn();
//
// Map<String, Set<String>> getInferredAttributes();
//
// Map<String, Set<String>> getInferredConcreteAttributes();
//
// Map<String, Set<String>> getStatedAttributes();
//
// List<Relationship> getRelationships();
//
// List<ConcreteRelationship> getConcreteRelationships();
//
// List<Description> getDescriptions();
//
// Set<Long> getInferredDescendantIds() throws IllegalStateException;
//
// Set<Long> getStatedDescendantIds() throws IllegalStateException;
// }
//
// Path: src/main/java/org/ihtsdo/otf/snomedboot/domain/ConcreteRelationship.java
// public interface ConcreteRelationship {
// String getId();
//
// String getEffectiveTime();
//
// String getActive();
//
// String getModuleId();
//
// String getSourceId();
//
// String getValue();
//
// String getRelationshipGroup();
//
// String getTypeId();
//
// String getCharacteristicTypeId();
//
// String getModifierId();
// }
//
// Path: src/main/java/org/ihtsdo/otf/snomedboot/domain/Description.java
// public interface Description {
// Long getId();
//
// boolean isActive();
//
// String getTerm();
//
// Long getConceptId();
// }
//
// Path: src/main/java/org/ihtsdo/otf/snomedboot/domain/Relationship.java
// public interface Relationship {
// String getId();
//
// String getEffectiveTime();
//
// String getActive();
//
// String getModuleId();
//
// String getSourceId();
//
// String getDestinationId();
//
// String getRelationshipGroup();
//
// String getTypeId();
//
// String getCharacteristicTypeId();
//
// String getModifierId();
// }
| import org.ihtsdo.otf.snomedboot.domain.Concept;
import org.ihtsdo.otf.snomedboot.domain.ConcreteRelationship;
import org.ihtsdo.otf.snomedboot.domain.Description;
import org.ihtsdo.otf.snomedboot.domain.Relationship;
import java.util.*; | package org.ihtsdo.otf.snomedboot.factory.implementation.standard;
public class ConceptImpl implements Concept {
private final Long id;
private String effectiveTime;
private boolean active;
private String moduleId;
private String definitionStatusId;
private String fsn;
private final Map<String, Set<String>> inferredAttributes;
private final Map<String, Set<String>> inferredConcreteAttributes;
private final Map<String, Set<String>> statedAttributes;
private final Set<Concept> inferredParents;
private final Set<Concept> statedParents;
private final Set<Concept> inferredChildren;
private final Set<Concept> statedChildren;
private final Set<Long> memberOfRefsetIds;
private final List<Relationship> relationships;
private final List<ConcreteRelationship> concreteRelationships; | // Path: src/main/java/org/ihtsdo/otf/snomedboot/domain/Concept.java
// public interface Concept {
// Long getId();
//
// Set<Long> getMemberOfRefsetIds();
//
// Set<Long> getInferredAncestorIds() throws IllegalStateException;
//
// Set<Long> getStatedAncestorIds() throws IllegalStateException;
//
// boolean isActive();
//
// String getEffectiveTime();
//
// String getModuleId();
//
// String getDefinitionStatusId();
//
// String getFsn();
//
// Map<String, Set<String>> getInferredAttributes();
//
// Map<String, Set<String>> getInferredConcreteAttributes();
//
// Map<String, Set<String>> getStatedAttributes();
//
// List<Relationship> getRelationships();
//
// List<ConcreteRelationship> getConcreteRelationships();
//
// List<Description> getDescriptions();
//
// Set<Long> getInferredDescendantIds() throws IllegalStateException;
//
// Set<Long> getStatedDescendantIds() throws IllegalStateException;
// }
//
// Path: src/main/java/org/ihtsdo/otf/snomedboot/domain/ConcreteRelationship.java
// public interface ConcreteRelationship {
// String getId();
//
// String getEffectiveTime();
//
// String getActive();
//
// String getModuleId();
//
// String getSourceId();
//
// String getValue();
//
// String getRelationshipGroup();
//
// String getTypeId();
//
// String getCharacteristicTypeId();
//
// String getModifierId();
// }
//
// Path: src/main/java/org/ihtsdo/otf/snomedboot/domain/Description.java
// public interface Description {
// Long getId();
//
// boolean isActive();
//
// String getTerm();
//
// Long getConceptId();
// }
//
// Path: src/main/java/org/ihtsdo/otf/snomedboot/domain/Relationship.java
// public interface Relationship {
// String getId();
//
// String getEffectiveTime();
//
// String getActive();
//
// String getModuleId();
//
// String getSourceId();
//
// String getDestinationId();
//
// String getRelationshipGroup();
//
// String getTypeId();
//
// String getCharacteristicTypeId();
//
// String getModifierId();
// }
// Path: src/main/java/org/ihtsdo/otf/snomedboot/factory/implementation/standard/ConceptImpl.java
import org.ihtsdo.otf.snomedboot.domain.Concept;
import org.ihtsdo.otf.snomedboot.domain.ConcreteRelationship;
import org.ihtsdo.otf.snomedboot.domain.Description;
import org.ihtsdo.otf.snomedboot.domain.Relationship;
import java.util.*;
package org.ihtsdo.otf.snomedboot.factory.implementation.standard;
public class ConceptImpl implements Concept {
private final Long id;
private String effectiveTime;
private boolean active;
private String moduleId;
private String definitionStatusId;
private String fsn;
private final Map<String, Set<String>> inferredAttributes;
private final Map<String, Set<String>> inferredConcreteAttributes;
private final Map<String, Set<String>> statedAttributes;
private final Set<Concept> inferredParents;
private final Set<Concept> statedParents;
private final Set<Concept> inferredChildren;
private final Set<Concept> statedChildren;
private final Set<Long> memberOfRefsetIds;
private final List<Relationship> relationships;
private final List<ConcreteRelationship> concreteRelationships; | private final List<Description> descriptions; |
IHTSDO/snomed-boot | src/main/java/org/ihtsdo/otf/snomedboot/factory/implementation/standard/ComponentStoreComponentFactoryImpl.java | // Path: src/main/java/org/ihtsdo/otf/snomedboot/factory/FactoryUtils.java
// public class FactoryUtils {
//
// public static final String ACTIVE = "1";
//
// public static boolean parseActive(String active) {
// return ACTIVE.equals(active);
// }
//
// public static boolean isConceptId(String componentId) {
// if (componentId != null) {
// final int length = componentId.length();
// return length > 3 && componentId.charAt(length - 2) == '0';
// }
// return false;
// }
//
// public static boolean isDescriptionId(String componentId) {
// if (componentId != null) {
// final int length = componentId.length();
// return length > 3 && componentId.charAt(length - 2) == '1';
// }
// return false;
// }
// }
//
// Path: src/main/java/org/ihtsdo/otf/snomedboot/factory/HighLevelComponentFactory.java
// public interface HighLevelComponentFactory extends ComponentFactory {
//
// void addConceptFSN(String conceptId, String term);
//
// void addInferredConceptParent(String sourceId, String parentId);
//
// void addStatedConceptParent(String sourceId, String parentId);
//
// void removeInferredConceptParent(String sourceId, String destinationId);
//
// void removeStatedConceptParent(String sourceId, String destinationId);
//
// void addInferredConceptAttribute(String sourceId, String typeId, String valueId);
//
// void addInferredConceptConcreteAttribute(String sourceId, String typeId, String value);
//
// void addStatedConceptAttribute(String sourceId, String typeId, String valueId);
//
// void addConceptReferencedInRefsetId(String refsetId, String conceptId);
//
// void addInferredConceptChild(String sourceId, String destinationId);
//
// void addStatedConceptChild(String sourceId, String destinationId);
//
// void removeInferredConceptChild(String sourceId, String destinationId);
//
// void removeStatedConceptChild(String sourceId, String destinationId);
// }
//
// Path: src/main/java/org/ihtsdo/otf/snomedboot/factory/ImpotentComponentFactory.java
// public class ImpotentComponentFactory implements ComponentFactory {
//
// @Override
// public void preprocessingContent() {
//
// }
//
// @Override
// public void loadingComponentsStarting() {
//
// }
//
// @Override
// public void loadingComponentsCompleted() {
//
// }
//
// @Override
// public void newConceptState(String conceptId, String effectiveTime, String active, String moduleId, String definitionStatusId) {
//
// }
//
// @Override
// public void newDescriptionState(String id, String effectiveTime, String active, String moduleId, String conceptId, String languageCode, String typeId, String term, String caseSignificanceId) {
//
// }
//
// @Override
// public void newRelationshipState(String id, String effectiveTime, String active, String moduleId, String sourceId, String destinationId, String relationshipGroup, String typeId, String characteristicTypeId, String modifierId) {
//
// }
//
// @Override
// public void newConcreteRelationshipState(String id, String effectiveTime, String active, String moduleId, String sourceId, String value, String relationshipGroup, String typeId, String characteristicTypeId, String modifierId) {
//
// }
//
// @Override
// public void newReferenceSetMemberState(String[] fieldNames, String id, String effectiveTime, String active, String moduleId, String refsetId, String referencedComponentId, String... otherValues) {
//
// }
//
// }
| import org.ihtsdo.otf.snomedboot.factory.FactoryUtils;
import org.ihtsdo.otf.snomedboot.factory.HighLevelComponentFactory;
import org.ihtsdo.otf.snomedboot.factory.ImpotentComponentFactory; | package org.ihtsdo.otf.snomedboot.factory.implementation.standard;
public class ComponentStoreComponentFactoryImpl extends ImpotentComponentFactory implements HighLevelComponentFactory {
private final ComponentStore componentStore;
public ComponentStoreComponentFactoryImpl(ComponentStore componentStore) {
this.componentStore = componentStore;
}
@Override
public void newConceptState(String conceptId, String effectiveTime, String active, String moduleId, String definitionStatusId) { | // Path: src/main/java/org/ihtsdo/otf/snomedboot/factory/FactoryUtils.java
// public class FactoryUtils {
//
// public static final String ACTIVE = "1";
//
// public static boolean parseActive(String active) {
// return ACTIVE.equals(active);
// }
//
// public static boolean isConceptId(String componentId) {
// if (componentId != null) {
// final int length = componentId.length();
// return length > 3 && componentId.charAt(length - 2) == '0';
// }
// return false;
// }
//
// public static boolean isDescriptionId(String componentId) {
// if (componentId != null) {
// final int length = componentId.length();
// return length > 3 && componentId.charAt(length - 2) == '1';
// }
// return false;
// }
// }
//
// Path: src/main/java/org/ihtsdo/otf/snomedboot/factory/HighLevelComponentFactory.java
// public interface HighLevelComponentFactory extends ComponentFactory {
//
// void addConceptFSN(String conceptId, String term);
//
// void addInferredConceptParent(String sourceId, String parentId);
//
// void addStatedConceptParent(String sourceId, String parentId);
//
// void removeInferredConceptParent(String sourceId, String destinationId);
//
// void removeStatedConceptParent(String sourceId, String destinationId);
//
// void addInferredConceptAttribute(String sourceId, String typeId, String valueId);
//
// void addInferredConceptConcreteAttribute(String sourceId, String typeId, String value);
//
// void addStatedConceptAttribute(String sourceId, String typeId, String valueId);
//
// void addConceptReferencedInRefsetId(String refsetId, String conceptId);
//
// void addInferredConceptChild(String sourceId, String destinationId);
//
// void addStatedConceptChild(String sourceId, String destinationId);
//
// void removeInferredConceptChild(String sourceId, String destinationId);
//
// void removeStatedConceptChild(String sourceId, String destinationId);
// }
//
// Path: src/main/java/org/ihtsdo/otf/snomedboot/factory/ImpotentComponentFactory.java
// public class ImpotentComponentFactory implements ComponentFactory {
//
// @Override
// public void preprocessingContent() {
//
// }
//
// @Override
// public void loadingComponentsStarting() {
//
// }
//
// @Override
// public void loadingComponentsCompleted() {
//
// }
//
// @Override
// public void newConceptState(String conceptId, String effectiveTime, String active, String moduleId, String definitionStatusId) {
//
// }
//
// @Override
// public void newDescriptionState(String id, String effectiveTime, String active, String moduleId, String conceptId, String languageCode, String typeId, String term, String caseSignificanceId) {
//
// }
//
// @Override
// public void newRelationshipState(String id, String effectiveTime, String active, String moduleId, String sourceId, String destinationId, String relationshipGroup, String typeId, String characteristicTypeId, String modifierId) {
//
// }
//
// @Override
// public void newConcreteRelationshipState(String id, String effectiveTime, String active, String moduleId, String sourceId, String value, String relationshipGroup, String typeId, String characteristicTypeId, String modifierId) {
//
// }
//
// @Override
// public void newReferenceSetMemberState(String[] fieldNames, String id, String effectiveTime, String active, String moduleId, String refsetId, String referencedComponentId, String... otherValues) {
//
// }
//
// }
// Path: src/main/java/org/ihtsdo/otf/snomedboot/factory/implementation/standard/ComponentStoreComponentFactoryImpl.java
import org.ihtsdo.otf.snomedboot.factory.FactoryUtils;
import org.ihtsdo.otf.snomedboot.factory.HighLevelComponentFactory;
import org.ihtsdo.otf.snomedboot.factory.ImpotentComponentFactory;
package org.ihtsdo.otf.snomedboot.factory.implementation.standard;
public class ComponentStoreComponentFactoryImpl extends ImpotentComponentFactory implements HighLevelComponentFactory {
private final ComponentStore componentStore;
public ComponentStoreComponentFactoryImpl(ComponentStore componentStore) {
this.componentStore = componentStore;
}
@Override
public void newConceptState(String conceptId, String effectiveTime, String active, String moduleId, String definitionStatusId) { | componentStore.addConcept(new ConceptImpl(conceptId, effectiveTime, FactoryUtils.parseActive(active), moduleId, definitionStatusId)); |
cyberbeat/java-css | com/sun/stylesheet/types/StringConverter.java | // Path: com/sun/stylesheet/StylesheetException.java
// public class StylesheetException extends RuntimeException {
// /** Creates a new <code>StylesheetException</code>. */
// public StylesheetException() {
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified detail
// * message.
// *
// *@param msg the exception's detail message
// */
// public StylesheetException(String msg) {
// super(msg);
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified cause.
// *
// *@param initCause the exception's initCause
// */
// public StylesheetException(Throwable initCause) {
// super(initCause);
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified detail
// * message and cause.
// *
// *@param msg the exception's detail message
// *@param initCause the exception's initCause
// */
// public StylesheetException(String msg, Throwable initCause) {
// super(msg, initCause);
// }
// }
| import com.sun.stylesheet.StylesheetException; | /*
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/* Modified by Volker Härtel, 8 Dec 2011 */ package com.sun.stylesheet.types;
/**
* Converts quoted strings which may contain escape sequences by removing the
* quotes and expanding the escape sequences. Input strings must be surrounded
* by either single (') or double (") quotes and may contain valid Java string
* escape sequences such as \n.
*/
public class StringConverter implements TypeConverter<String> {
public String convertFromString(String string) {
String trimmed = string.trim();
if (trimmed.equals("null"))
return null;
if ((trimmed.startsWith("\"") && trimmed.endsWith("\"")) ||
(trimmed.startsWith("'") && trimmed.endsWith("'"))) {
trimmed = trimmed.substring(1, trimmed.length() - 1);
StringBuilder result = new StringBuilder(trimmed.length());
for (int i = 0; i < trimmed.length(); i++) {
char c = trimmed.charAt(i);
if (c == '\\') {
try {
char escape = trimmed.charAt(i + 1);
switch (escape) {
case '"': result.append('"'); break;
case '\'': result.append('\''); break;
case '\\': result.append('\\'); break;
case 'n': result.append('\n'); break;
case 'r': result.append('\r'); break;
case 't': result.append('\t'); break;
case 'b': result.append('\b'); break; | // Path: com/sun/stylesheet/StylesheetException.java
// public class StylesheetException extends RuntimeException {
// /** Creates a new <code>StylesheetException</code>. */
// public StylesheetException() {
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified detail
// * message.
// *
// *@param msg the exception's detail message
// */
// public StylesheetException(String msg) {
// super(msg);
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified cause.
// *
// *@param initCause the exception's initCause
// */
// public StylesheetException(Throwable initCause) {
// super(initCause);
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified detail
// * message and cause.
// *
// *@param msg the exception's detail message
// *@param initCause the exception's initCause
// */
// public StylesheetException(String msg, Throwable initCause) {
// super(msg, initCause);
// }
// }
// Path: com/sun/stylesheet/types/StringConverter.java
import com.sun.stylesheet.StylesheetException;
/*
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/* Modified by Volker Härtel, 8 Dec 2011 */ package com.sun.stylesheet.types;
/**
* Converts quoted strings which may contain escape sequences by removing the
* quotes and expanding the escape sequences. Input strings must be surrounded
* by either single (') or double (") quotes and may contain valid Java string
* escape sequences such as \n.
*/
public class StringConverter implements TypeConverter<String> {
public String convertFromString(String string) {
String trimmed = string.trim();
if (trimmed.equals("null"))
return null;
if ((trimmed.startsWith("\"") && trimmed.endsWith("\"")) ||
(trimmed.startsWith("'") && trimmed.endsWith("'"))) {
trimmed = trimmed.substring(1, trimmed.length() - 1);
StringBuilder result = new StringBuilder(trimmed.length());
for (int i = 0; i < trimmed.length(); i++) {
char c = trimmed.charAt(i);
if (c == '\\') {
try {
char escape = trimmed.charAt(i + 1);
switch (escape) {
case '"': result.append('"'); break;
case '\'': result.append('\''); break;
case '\\': result.append('\\'); break;
case 'n': result.append('\n'); break;
case 'r': result.append('\r'); break;
case 't': result.append('\t'); break;
case 'b': result.append('\b'); break; | default: throw new StylesheetException("invalid " + |
cyberbeat/java-css | com/sun/stylesheet/swing/FontWeightHandler.java | // Path: com/sun/stylesheet/StylesheetException.java
// public class StylesheetException extends RuntimeException {
// /** Creates a new <code>StylesheetException</code>. */
// public StylesheetException() {
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified detail
// * message.
// *
// *@param msg the exception's detail message
// */
// public StylesheetException(String msg) {
// super(msg);
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified cause.
// *
// *@param initCause the exception's initCause
// */
// public StylesheetException(Throwable initCause) {
// super(initCause);
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified detail
// * message and cause.
// *
// *@param msg the exception's detail message
// *@param initCause the exception's initCause
// */
// public StylesheetException(String msg, Throwable initCause) {
// super(msg, initCause);
// }
// }
//
// Path: com/sun/stylesheet/styleable/DefaultPropertyHandler.java
// public class DefaultPropertyHandler implements PropertyHandler {
// protected PropertyDescriptor descriptor;
//
// public DefaultPropertyHandler(PropertyDescriptor descriptor) {
// this.descriptor = descriptor;
// }
//
//
// public Class getPropertyType(Object object) {
// return descriptor.getPropertyType();
// }
//
//
// public Object getProperty(Object object) throws StylesheetException {
// if (descriptor.getReadMethod() != null) {
// try {
// return descriptor.getReadMethod().invoke(object);
// }
// catch (Exception e) {
// throw new StylesheetException(e);
// }
// }
// else
// throw new UnsupportedPropertyException("property " +
// descriptor.getName() + " cannot be read");
// }
//
//
// public void setProperty(Object object, Object value) throws StylesheetException {
// if (descriptor.getWriteMethod() != null) {
// try {
// descriptor.getWriteMethod().invoke(object, value);
// }
// catch (Exception e) {
// throw new StylesheetException(e);
// }
// }
// else
// throw new UnsupportedPropertyException("property " +
// descriptor.getName() + " cannot be written");
// }
// }
| import java.awt.Font;
import java.beans.PropertyDescriptor;
import com.sun.stylesheet.StylesheetException;
import com.sun.stylesheet.styleable.DefaultPropertyHandler; | /*
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/* Modified by Volker Härtel, 8 Dec 2011 */ package com.sun.stylesheet.swing;
/**
* Provides support for the font-weight synthetic property.
*
*@author Ethan Nicholas
*/
class FontWeightHandler extends DefaultPropertyHandler {
enum FontWeight { NORMAL, BOLD };
public FontWeightHandler(PropertyDescriptor descriptor) {
super(descriptor);
}
@Override
public Class getPropertyType(Object object) {
return FontWeight.class;
}
@Override | // Path: com/sun/stylesheet/StylesheetException.java
// public class StylesheetException extends RuntimeException {
// /** Creates a new <code>StylesheetException</code>. */
// public StylesheetException() {
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified detail
// * message.
// *
// *@param msg the exception's detail message
// */
// public StylesheetException(String msg) {
// super(msg);
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified cause.
// *
// *@param initCause the exception's initCause
// */
// public StylesheetException(Throwable initCause) {
// super(initCause);
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified detail
// * message and cause.
// *
// *@param msg the exception's detail message
// *@param initCause the exception's initCause
// */
// public StylesheetException(String msg, Throwable initCause) {
// super(msg, initCause);
// }
// }
//
// Path: com/sun/stylesheet/styleable/DefaultPropertyHandler.java
// public class DefaultPropertyHandler implements PropertyHandler {
// protected PropertyDescriptor descriptor;
//
// public DefaultPropertyHandler(PropertyDescriptor descriptor) {
// this.descriptor = descriptor;
// }
//
//
// public Class getPropertyType(Object object) {
// return descriptor.getPropertyType();
// }
//
//
// public Object getProperty(Object object) throws StylesheetException {
// if (descriptor.getReadMethod() != null) {
// try {
// return descriptor.getReadMethod().invoke(object);
// }
// catch (Exception e) {
// throw new StylesheetException(e);
// }
// }
// else
// throw new UnsupportedPropertyException("property " +
// descriptor.getName() + " cannot be read");
// }
//
//
// public void setProperty(Object object, Object value) throws StylesheetException {
// if (descriptor.getWriteMethod() != null) {
// try {
// descriptor.getWriteMethod().invoke(object, value);
// }
// catch (Exception e) {
// throw new StylesheetException(e);
// }
// }
// else
// throw new UnsupportedPropertyException("property " +
// descriptor.getName() + " cannot be written");
// }
// }
// Path: com/sun/stylesheet/swing/FontWeightHandler.java
import java.awt.Font;
import java.beans.PropertyDescriptor;
import com.sun.stylesheet.StylesheetException;
import com.sun.stylesheet.styleable.DefaultPropertyHandler;
/*
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/* Modified by Volker Härtel, 8 Dec 2011 */ package com.sun.stylesheet.swing;
/**
* Provides support for the font-weight synthetic property.
*
*@author Ethan Nicholas
*/
class FontWeightHandler extends DefaultPropertyHandler {
enum FontWeight { NORMAL, BOLD };
public FontWeightHandler(PropertyDescriptor descriptor) {
super(descriptor);
}
@Override
public Class getPropertyType(Object object) {
return FontWeight.class;
}
@Override | public Object getProperty(Object object) throws StylesheetException { |
cyberbeat/java-css | com/sun/stylesheet/types/PrimitiveConverter.java | // Path: com/sun/stylesheet/StylesheetException.java
// public class StylesheetException extends RuntimeException {
// /** Creates a new <code>StylesheetException</code>. */
// public StylesheetException() {
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified detail
// * message.
// *
// *@param msg the exception's detail message
// */
// public StylesheetException(String msg) {
// super(msg);
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified cause.
// *
// *@param initCause the exception's initCause
// */
// public StylesheetException(Throwable initCause) {
// super(initCause);
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified detail
// * message and cause.
// *
// *@param msg the exception's detail message
// *@param initCause the exception's initCause
// */
// public StylesheetException(String msg, Throwable initCause) {
// super(msg, initCause);
// }
// }
| import java.lang.reflect.Field;
import com.sun.stylesheet.StylesheetException;
| /*
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/* Modified by Volker Härtel, 8 Dec 2011 */ package com.sun.stylesheet.types;
/**
* Converts string representations of the various "simple" Java types, such as
* <code>int</code>, <code>float</code>, and <code>boolean</code>, into their
* correct types.
* <p>
* <code>short</code>, <code>long</code>, <code>float</code>, and
* <code>double</code> are simply parsed using their respective parse methods,
* such as <code>Float.parseFloat()</code>.
* <p>
* <code>int</code> supports all strings recognized by
* <code>Integer.parseInt()</code>, and
* additionally supports references to constant fields such as
* <code>Font.BOLD</code>. Classes in <code>java.awt</code>,
* <code>javax.swing</code>, and <code>javax.swing.border</code> can be
* referenced by their simple, unqualified names, while classes in other
* packages must be fully named.
* <p>
* <code>char</code> requires the input string to be exactly one character long,
* and will throw an exception otherwise.
* <p>
* <code>boolean</code> requires the input string to be either "true" or "false"
* (case insensitive).
*
*@author Ethan Nicholas
*/
public class PrimitiveConverter implements TypeConverter<Object> {
private Class type;
public PrimitiveConverter(Class type) {
this.type = type;
}
public Object convertFromString(String string) {
try {
if (type == int.class || type == Integer.class) {
try {
return Integer.valueOf(string);
}
catch (NumberFormatException e) {
return parseConstant(string);
}
}
else if (type == boolean.class || type == Boolean.class) {
if (string.toLowerCase().equals("true"))
return Boolean.TRUE;
else if (string.toLowerCase().equals("false"))
return Boolean.FALSE;
else
| // Path: com/sun/stylesheet/StylesheetException.java
// public class StylesheetException extends RuntimeException {
// /** Creates a new <code>StylesheetException</code>. */
// public StylesheetException() {
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified detail
// * message.
// *
// *@param msg the exception's detail message
// */
// public StylesheetException(String msg) {
// super(msg);
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified cause.
// *
// *@param initCause the exception's initCause
// */
// public StylesheetException(Throwable initCause) {
// super(initCause);
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified detail
// * message and cause.
// *
// *@param msg the exception's detail message
// *@param initCause the exception's initCause
// */
// public StylesheetException(String msg, Throwable initCause) {
// super(msg, initCause);
// }
// }
// Path: com/sun/stylesheet/types/PrimitiveConverter.java
import java.lang.reflect.Field;
import com.sun.stylesheet.StylesheetException;
/*
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/* Modified by Volker Härtel, 8 Dec 2011 */ package com.sun.stylesheet.types;
/**
* Converts string representations of the various "simple" Java types, such as
* <code>int</code>, <code>float</code>, and <code>boolean</code>, into their
* correct types.
* <p>
* <code>short</code>, <code>long</code>, <code>float</code>, and
* <code>double</code> are simply parsed using their respective parse methods,
* such as <code>Float.parseFloat()</code>.
* <p>
* <code>int</code> supports all strings recognized by
* <code>Integer.parseInt()</code>, and
* additionally supports references to constant fields such as
* <code>Font.BOLD</code>. Classes in <code>java.awt</code>,
* <code>javax.swing</code>, and <code>javax.swing.border</code> can be
* referenced by their simple, unqualified names, while classes in other
* packages must be fully named.
* <p>
* <code>char</code> requires the input string to be exactly one character long,
* and will throw an exception otherwise.
* <p>
* <code>boolean</code> requires the input string to be either "true" or "false"
* (case insensitive).
*
*@author Ethan Nicholas
*/
public class PrimitiveConverter implements TypeConverter<Object> {
private Class type;
public PrimitiveConverter(Class type) {
this.type = type;
}
public Object convertFromString(String string) {
try {
if (type == int.class || type == Integer.class) {
try {
return Integer.valueOf(string);
}
catch (NumberFormatException e) {
return parseConstant(string);
}
}
else if (type == boolean.class || type == Boolean.class) {
if (string.toLowerCase().equals("true"))
return Boolean.TRUE;
else if (string.toLowerCase().equals("false"))
return Boolean.FALSE;
else
| throw new StylesheetException("expected 'true' or 'false'" +
|
cyberbeat/java-css | com/sun/stylesheet/swing/FontFamilyHandler.java | // Path: com/sun/stylesheet/StylesheetException.java
// public class StylesheetException extends RuntimeException {
// /** Creates a new <code>StylesheetException</code>. */
// public StylesheetException() {
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified detail
// * message.
// *
// *@param msg the exception's detail message
// */
// public StylesheetException(String msg) {
// super(msg);
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified cause.
// *
// *@param initCause the exception's initCause
// */
// public StylesheetException(Throwable initCause) {
// super(initCause);
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified detail
// * message and cause.
// *
// *@param msg the exception's detail message
// *@param initCause the exception's initCause
// */
// public StylesheetException(String msg, Throwable initCause) {
// super(msg, initCause);
// }
// }
//
// Path: com/sun/stylesheet/styleable/DefaultPropertyHandler.java
// public class DefaultPropertyHandler implements PropertyHandler {
// protected PropertyDescriptor descriptor;
//
// public DefaultPropertyHandler(PropertyDescriptor descriptor) {
// this.descriptor = descriptor;
// }
//
//
// public Class getPropertyType(Object object) {
// return descriptor.getPropertyType();
// }
//
//
// public Object getProperty(Object object) throws StylesheetException {
// if (descriptor.getReadMethod() != null) {
// try {
// return descriptor.getReadMethod().invoke(object);
// }
// catch (Exception e) {
// throw new StylesheetException(e);
// }
// }
// else
// throw new UnsupportedPropertyException("property " +
// descriptor.getName() + " cannot be read");
// }
//
//
// public void setProperty(Object object, Object value) throws StylesheetException {
// if (descriptor.getWriteMethod() != null) {
// try {
// descriptor.getWriteMethod().invoke(object, value);
// }
// catch (Exception e) {
// throw new StylesheetException(e);
// }
// }
// else
// throw new UnsupportedPropertyException("property " +
// descriptor.getName() + " cannot be written");
// }
// }
| import java.awt.Font;
import java.beans.PropertyDescriptor;
import com.sun.stylesheet.StylesheetException;
import com.sun.stylesheet.styleable.DefaultPropertyHandler; | /*
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/* Modified by Volker Härtel, 8 Dec 2011 */ package com.sun.stylesheet.swing;
/**
* Provides support for the font-face synthetic property.
*
*@author Ethan Nicholas
*/
class FontFamilyHandler extends DefaultPropertyHandler {
public FontFamilyHandler(PropertyDescriptor descriptor) {
super(descriptor);
}
@Override
public Class getPropertyType(Object object) {
return String.class;
}
@Override | // Path: com/sun/stylesheet/StylesheetException.java
// public class StylesheetException extends RuntimeException {
// /** Creates a new <code>StylesheetException</code>. */
// public StylesheetException() {
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified detail
// * message.
// *
// *@param msg the exception's detail message
// */
// public StylesheetException(String msg) {
// super(msg);
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified cause.
// *
// *@param initCause the exception's initCause
// */
// public StylesheetException(Throwable initCause) {
// super(initCause);
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified detail
// * message and cause.
// *
// *@param msg the exception's detail message
// *@param initCause the exception's initCause
// */
// public StylesheetException(String msg, Throwable initCause) {
// super(msg, initCause);
// }
// }
//
// Path: com/sun/stylesheet/styleable/DefaultPropertyHandler.java
// public class DefaultPropertyHandler implements PropertyHandler {
// protected PropertyDescriptor descriptor;
//
// public DefaultPropertyHandler(PropertyDescriptor descriptor) {
// this.descriptor = descriptor;
// }
//
//
// public Class getPropertyType(Object object) {
// return descriptor.getPropertyType();
// }
//
//
// public Object getProperty(Object object) throws StylesheetException {
// if (descriptor.getReadMethod() != null) {
// try {
// return descriptor.getReadMethod().invoke(object);
// }
// catch (Exception e) {
// throw new StylesheetException(e);
// }
// }
// else
// throw new UnsupportedPropertyException("property " +
// descriptor.getName() + " cannot be read");
// }
//
//
// public void setProperty(Object object, Object value) throws StylesheetException {
// if (descriptor.getWriteMethod() != null) {
// try {
// descriptor.getWriteMethod().invoke(object, value);
// }
// catch (Exception e) {
// throw new StylesheetException(e);
// }
// }
// else
// throw new UnsupportedPropertyException("property " +
// descriptor.getName() + " cannot be written");
// }
// }
// Path: com/sun/stylesheet/swing/FontFamilyHandler.java
import java.awt.Font;
import java.beans.PropertyDescriptor;
import com.sun.stylesheet.StylesheetException;
import com.sun.stylesheet.styleable.DefaultPropertyHandler;
/*
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/* Modified by Volker Härtel, 8 Dec 2011 */ package com.sun.stylesheet.swing;
/**
* Provides support for the font-face synthetic property.
*
*@author Ethan Nicholas
*/
class FontFamilyHandler extends DefaultPropertyHandler {
public FontFamilyHandler(PropertyDescriptor descriptor) {
super(descriptor);
}
@Override
public Class getPropertyType(Object object) {
return String.class;
}
@Override | public Object getProperty(Object object) throws StylesheetException { |
cyberbeat/java-css | com/sun/stylesheet/types/EnumConverter.java | // Path: com/sun/stylesheet/StylesheetException.java
// public class StylesheetException extends RuntimeException {
// /** Creates a new <code>StylesheetException</code>. */
// public StylesheetException() {
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified detail
// * message.
// *
// *@param msg the exception's detail message
// */
// public StylesheetException(String msg) {
// super(msg);
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified cause.
// *
// *@param initCause the exception's initCause
// */
// public StylesheetException(Throwable initCause) {
// super(initCause);
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified detail
// * message and cause.
// *
// *@param msg the exception's detail message
// *@param initCause the exception's initCause
// */
// public StylesheetException(String msg, Throwable initCause) {
// super(msg, initCause);
// }
// }
| import com.sun.stylesheet.StylesheetException;
| /*
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/* Modified by Volker Härtel, 8 Dec 2011 */ package com.sun.stylesheet.types;
/**
* Converts strings representing enum constants into the actual values.
*
*@author Ethan Nicholas
*/
public class EnumConverter implements TypeConverter {
private Class enumClass;
public EnumConverter(Class enumClass) {
this.enumClass = enumClass;
}
public Object convertFromString(String string) {
try {
return Enum.valueOf(enumClass, string.toUpperCase());
}
catch (IllegalArgumentException e) {
try {
return Enum.valueOf(enumClass, string);
}
catch (IllegalArgumentException f) {
| // Path: com/sun/stylesheet/StylesheetException.java
// public class StylesheetException extends RuntimeException {
// /** Creates a new <code>StylesheetException</code>. */
// public StylesheetException() {
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified detail
// * message.
// *
// *@param msg the exception's detail message
// */
// public StylesheetException(String msg) {
// super(msg);
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified cause.
// *
// *@param initCause the exception's initCause
// */
// public StylesheetException(Throwable initCause) {
// super(initCause);
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified detail
// * message and cause.
// *
// *@param msg the exception's detail message
// *@param initCause the exception's initCause
// */
// public StylesheetException(String msg, Throwable initCause) {
// super(msg, initCause);
// }
// }
// Path: com/sun/stylesheet/types/EnumConverter.java
import com.sun.stylesheet.StylesheetException;
/*
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/* Modified by Volker Härtel, 8 Dec 2011 */ package com.sun.stylesheet.types;
/**
* Converts strings representing enum constants into the actual values.
*
*@author Ethan Nicholas
*/
public class EnumConverter implements TypeConverter {
private Class enumClass;
public EnumConverter(Class enumClass) {
this.enumClass = enumClass;
}
public Object convertFromString(String string) {
try {
return Enum.valueOf(enumClass, string.toUpperCase());
}
catch (IllegalArgumentException e) {
try {
return Enum.valueOf(enumClass, string);
}
catch (IllegalArgumentException f) {
| throw new StylesheetException('"' + string +
|
cyberbeat/java-css | com/sun/stylesheet/types/SizeConverter.java | // Path: com/sun/stylesheet/StylesheetException.java
// public class StylesheetException extends RuntimeException {
// /** Creates a new <code>StylesheetException</code>. */
// public StylesheetException() {
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified detail
// * message.
// *
// *@param msg the exception's detail message
// */
// public StylesheetException(String msg) {
// super(msg);
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified cause.
// *
// *@param initCause the exception's initCause
// */
// public StylesheetException(Throwable initCause) {
// super(initCause);
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified detail
// * message and cause.
// *
// *@param msg the exception's detail message
// *@param initCause the exception's initCause
// */
// public StylesheetException(String msg, Throwable initCause) {
// super(msg, initCause);
// }
// }
| import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.sun.stylesheet.StylesheetException; | /*
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/* Modified by Volker Härtel, 8 Dec 2011 */ package com.sun.stylesheet.types;
/**
* Converts strings representing CSS sizes (e.g. "12pt" or "0.2em") to
* {@link Size Sizes}.
*/
public class SizeConverter implements TypeConverter<Size> {
Pattern pattern = Pattern.compile("(\\d*(?:\\.\\d*)?)(%|in|cm|mm|" +
"pt|px|pc|em|ex)");
public Size convertFromString(String string) {
Matcher m = pattern.matcher(string);
if (m.matches()) {
float value = Float.parseFloat(m.group(1));
String unit = m.group(2);
if (unit.equals("%"))
unit = "percent";
return new Size(value, Size.Unit.valueOf(unit.toUpperCase()));
}
else | // Path: com/sun/stylesheet/StylesheetException.java
// public class StylesheetException extends RuntimeException {
// /** Creates a new <code>StylesheetException</code>. */
// public StylesheetException() {
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified detail
// * message.
// *
// *@param msg the exception's detail message
// */
// public StylesheetException(String msg) {
// super(msg);
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified cause.
// *
// *@param initCause the exception's initCause
// */
// public StylesheetException(Throwable initCause) {
// super(initCause);
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified detail
// * message and cause.
// *
// *@param msg the exception's detail message
// *@param initCause the exception's initCause
// */
// public StylesheetException(String msg, Throwable initCause) {
// super(msg, initCause);
// }
// }
// Path: com/sun/stylesheet/types/SizeConverter.java
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.sun.stylesheet.StylesheetException;
/*
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/* Modified by Volker Härtel, 8 Dec 2011 */ package com.sun.stylesheet.types;
/**
* Converts strings representing CSS sizes (e.g. "12pt" or "0.2em") to
* {@link Size Sizes}.
*/
public class SizeConverter implements TypeConverter<Size> {
Pattern pattern = Pattern.compile("(\\d*(?:\\.\\d*)?)(%|in|cm|mm|" +
"pt|px|pc|em|ex)");
public Size convertFromString(String string) {
Matcher m = pattern.matcher(string);
if (m.matches()) {
float value = Float.parseFloat(m.group(1));
String unit = m.group(2);
if (unit.equals("%"))
unit = "percent";
return new Size(value, Size.Unit.valueOf(unit.toUpperCase()));
}
else | throw new StylesheetException("Could not convert string '" + string + |
cyberbeat/java-css | com/sun/stylesheet/swing/TextHandler.java | // Path: com/sun/stylesheet/StylesheetException.java
// public class StylesheetException extends RuntimeException {
// /** Creates a new <code>StylesheetException</code>. */
// public StylesheetException() {
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified detail
// * message.
// *
// *@param msg the exception's detail message
// */
// public StylesheetException(String msg) {
// super(msg);
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified cause.
// *
// *@param initCause the exception's initCause
// */
// public StylesheetException(Throwable initCause) {
// super(initCause);
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified detail
// * message and cause.
// *
// *@param msg the exception's detail message
// *@param initCause the exception's initCause
// */
// public StylesheetException(String msg, Throwable initCause) {
// super(msg, initCause);
// }
// }
//
// Path: com/sun/stylesheet/styleable/DefaultPropertyHandler.java
// public class DefaultPropertyHandler implements PropertyHandler {
// protected PropertyDescriptor descriptor;
//
// public DefaultPropertyHandler(PropertyDescriptor descriptor) {
// this.descriptor = descriptor;
// }
//
//
// public Class getPropertyType(Object object) {
// return descriptor.getPropertyType();
// }
//
//
// public Object getProperty(Object object) throws StylesheetException {
// if (descriptor.getReadMethod() != null) {
// try {
// return descriptor.getReadMethod().invoke(object);
// }
// catch (Exception e) {
// throw new StylesheetException(e);
// }
// }
// else
// throw new UnsupportedPropertyException("property " +
// descriptor.getName() + " cannot be read");
// }
//
//
// public void setProperty(Object object, Object value) throws StylesheetException {
// if (descriptor.getWriteMethod() != null) {
// try {
// descriptor.getWriteMethod().invoke(object, value);
// }
// catch (Exception e) {
// throw new StylesheetException(e);
// }
// }
// else
// throw new UnsupportedPropertyException("property " +
// descriptor.getName() + " cannot be written");
// }
// }
//
// Path: com/sun/stylesheet/styleable/StyleSupport.java
// public interface StyleSupport {
// String getID(Object object);
//
// String getStyleClass(Object object);
//
// Class[] getObjectClasses(Object object);
//
// Styleable getStyleableParent(Object object);
//
// Styleable[] getStyleableChildren(Object object);
//
// Class getPropertyType(Object object, String propertyName);
//
// Object getProperty(Object object, String propertyName);
//
// void setProperty(Object object, String propertyName, Object value);
//
// void addPseudoclassListener(DefaultStyleable object, String pseudoclass,
// PseudoclassListener listener);
//
// void removePseudoclassListener(DefaultStyleable object, String pseudoclass,
// PseudoclassListener listener);
//
// Map<String, Object> splitCompoundProperty(Object object, String property,
// Object value);
//
// boolean isPropertyInherited(Object object, String propertyName);
//
// PropertyHandler getPropertyHandler(String property);
//
// void addHierarchyListener(DefaultStyleable object);
// }
| import java.beans.PropertyDescriptor;
import com.sun.stylesheet.StylesheetException;
import com.sun.stylesheet.styleable.DefaultPropertyHandler;
import com.sun.stylesheet.styleable.StyleSupport; | /*
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/* Modified by Volker Härtel, 8 Dec 2011 */ package com.sun.stylesheet.swing;
/**
* Provides support for the <code>text</code> property. While <code>text</code>
* would ordinarily work just fine with the default support, the presence of
* <code>text-decoration</code> means that <code>text</code> has to be smart
* enough to preserve the decorations when it is set.
*
*@author Ethan Nicholas
*/
class TextHandler extends DefaultPropertyHandler {
private TextDecorationHandler textDecorationHandler;
private StyleSupport styleSupport;
public TextHandler(StyleSupport styleSupport,
PropertyDescriptor descriptor) {
super(descriptor);
this.styleSupport = styleSupport;
}
TextDecorationHandler getTextDecorationHandler() {
if (textDecorationHandler == null)
textDecorationHandler = (TextDecorationHandler)
styleSupport.getPropertyHandler("text-decoration");
return textDecorationHandler;
}
// Note that getProperty() currently returns the decorated text, which may
// differ from the undecorated text applied by setProperty(). I don't think
// this creates any problems, but it's something to be aware of.
@Override | // Path: com/sun/stylesheet/StylesheetException.java
// public class StylesheetException extends RuntimeException {
// /** Creates a new <code>StylesheetException</code>. */
// public StylesheetException() {
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified detail
// * message.
// *
// *@param msg the exception's detail message
// */
// public StylesheetException(String msg) {
// super(msg);
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified cause.
// *
// *@param initCause the exception's initCause
// */
// public StylesheetException(Throwable initCause) {
// super(initCause);
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified detail
// * message and cause.
// *
// *@param msg the exception's detail message
// *@param initCause the exception's initCause
// */
// public StylesheetException(String msg, Throwable initCause) {
// super(msg, initCause);
// }
// }
//
// Path: com/sun/stylesheet/styleable/DefaultPropertyHandler.java
// public class DefaultPropertyHandler implements PropertyHandler {
// protected PropertyDescriptor descriptor;
//
// public DefaultPropertyHandler(PropertyDescriptor descriptor) {
// this.descriptor = descriptor;
// }
//
//
// public Class getPropertyType(Object object) {
// return descriptor.getPropertyType();
// }
//
//
// public Object getProperty(Object object) throws StylesheetException {
// if (descriptor.getReadMethod() != null) {
// try {
// return descriptor.getReadMethod().invoke(object);
// }
// catch (Exception e) {
// throw new StylesheetException(e);
// }
// }
// else
// throw new UnsupportedPropertyException("property " +
// descriptor.getName() + " cannot be read");
// }
//
//
// public void setProperty(Object object, Object value) throws StylesheetException {
// if (descriptor.getWriteMethod() != null) {
// try {
// descriptor.getWriteMethod().invoke(object, value);
// }
// catch (Exception e) {
// throw new StylesheetException(e);
// }
// }
// else
// throw new UnsupportedPropertyException("property " +
// descriptor.getName() + " cannot be written");
// }
// }
//
// Path: com/sun/stylesheet/styleable/StyleSupport.java
// public interface StyleSupport {
// String getID(Object object);
//
// String getStyleClass(Object object);
//
// Class[] getObjectClasses(Object object);
//
// Styleable getStyleableParent(Object object);
//
// Styleable[] getStyleableChildren(Object object);
//
// Class getPropertyType(Object object, String propertyName);
//
// Object getProperty(Object object, String propertyName);
//
// void setProperty(Object object, String propertyName, Object value);
//
// void addPseudoclassListener(DefaultStyleable object, String pseudoclass,
// PseudoclassListener listener);
//
// void removePseudoclassListener(DefaultStyleable object, String pseudoclass,
// PseudoclassListener listener);
//
// Map<String, Object> splitCompoundProperty(Object object, String property,
// Object value);
//
// boolean isPropertyInherited(Object object, String propertyName);
//
// PropertyHandler getPropertyHandler(String property);
//
// void addHierarchyListener(DefaultStyleable object);
// }
// Path: com/sun/stylesheet/swing/TextHandler.java
import java.beans.PropertyDescriptor;
import com.sun.stylesheet.StylesheetException;
import com.sun.stylesheet.styleable.DefaultPropertyHandler;
import com.sun.stylesheet.styleable.StyleSupport;
/*
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/* Modified by Volker Härtel, 8 Dec 2011 */ package com.sun.stylesheet.swing;
/**
* Provides support for the <code>text</code> property. While <code>text</code>
* would ordinarily work just fine with the default support, the presence of
* <code>text-decoration</code> means that <code>text</code> has to be smart
* enough to preserve the decorations when it is set.
*
*@author Ethan Nicholas
*/
class TextHandler extends DefaultPropertyHandler {
private TextDecorationHandler textDecorationHandler;
private StyleSupport styleSupport;
public TextHandler(StyleSupport styleSupport,
PropertyDescriptor descriptor) {
super(descriptor);
this.styleSupport = styleSupport;
}
TextDecorationHandler getTextDecorationHandler() {
if (textDecorationHandler == null)
textDecorationHandler = (TextDecorationHandler)
styleSupport.getPropertyHandler("text-decoration");
return textDecorationHandler;
}
// Note that getProperty() currently returns the decorated text, which may
// differ from the undecorated text applied by setProperty(). I don't think
// this creates any problems, but it's something to be aware of.
@Override | public void setProperty(Object object, Object value) throws StylesheetException { |
cyberbeat/java-css | com/sun/stylesheet/types/TimeConverter.java | // Path: com/sun/stylesheet/StylesheetException.java
// public class StylesheetException extends RuntimeException {
// /** Creates a new <code>StylesheetException</code>. */
// public StylesheetException() {
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified detail
// * message.
// *
// *@param msg the exception's detail message
// */
// public StylesheetException(String msg) {
// super(msg);
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified cause.
// *
// *@param initCause the exception's initCause
// */
// public StylesheetException(Throwable initCause) {
// super(initCause);
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified detail
// * message and cause.
// *
// *@param msg the exception's detail message
// *@param initCause the exception's initCause
// */
// public StylesheetException(String msg, Throwable initCause) {
// super(msg, initCause);
// }
// }
| import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.sun.stylesheet.StylesheetException; | /*
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/* Modified by Volker Härtel, 8 Dec 2011 */ package com.sun.stylesheet.types;
/**
* Converts strings representing times (e.g. "500ms" or "0.5s") to
* {@link Time Times}.
*/
public class TimeConverter implements TypeConverter<Time> {
Pattern pattern = Pattern.compile("(\\d*(?:\\.\\d*)?)(ms|s|m)");
public Time convertFromString(String string) {
Matcher m = pattern.matcher(string);
if (m.matches()) {
float value = Float.parseFloat(m.group(1));
String unit = m.group(2);
return new Time(value, Time.Unit.valueOf(unit.toUpperCase()));
}
else | // Path: com/sun/stylesheet/StylesheetException.java
// public class StylesheetException extends RuntimeException {
// /** Creates a new <code>StylesheetException</code>. */
// public StylesheetException() {
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified detail
// * message.
// *
// *@param msg the exception's detail message
// */
// public StylesheetException(String msg) {
// super(msg);
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified cause.
// *
// *@param initCause the exception's initCause
// */
// public StylesheetException(Throwable initCause) {
// super(initCause);
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified detail
// * message and cause.
// *
// *@param msg the exception's detail message
// *@param initCause the exception's initCause
// */
// public StylesheetException(String msg, Throwable initCause) {
// super(msg, initCause);
// }
// }
// Path: com/sun/stylesheet/types/TimeConverter.java
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.sun.stylesheet.StylesheetException;
/*
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/* Modified by Volker Härtel, 8 Dec 2011 */ package com.sun.stylesheet.types;
/**
* Converts strings representing times (e.g. "500ms" or "0.5s") to
* {@link Time Times}.
*/
public class TimeConverter implements TypeConverter<Time> {
Pattern pattern = Pattern.compile("(\\d*(?:\\.\\d*)?)(ms|s|m)");
public Time convertFromString(String string) {
Matcher m = pattern.matcher(string);
if (m.matches()) {
float value = Float.parseFloat(m.group(1));
String unit = m.group(2);
return new Time(value, Time.Unit.valueOf(unit.toUpperCase()));
}
else | throw new StylesheetException("Could not convert string '" + string + |
cyberbeat/java-css | com/sun/stylesheet/swing/FontStyleHandler.java | // Path: com/sun/stylesheet/StylesheetException.java
// public class StylesheetException extends RuntimeException {
// /** Creates a new <code>StylesheetException</code>. */
// public StylesheetException() {
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified detail
// * message.
// *
// *@param msg the exception's detail message
// */
// public StylesheetException(String msg) {
// super(msg);
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified cause.
// *
// *@param initCause the exception's initCause
// */
// public StylesheetException(Throwable initCause) {
// super(initCause);
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified detail
// * message and cause.
// *
// *@param msg the exception's detail message
// *@param initCause the exception's initCause
// */
// public StylesheetException(String msg, Throwable initCause) {
// super(msg, initCause);
// }
// }
//
// Path: com/sun/stylesheet/styleable/DefaultPropertyHandler.java
// public class DefaultPropertyHandler implements PropertyHandler {
// protected PropertyDescriptor descriptor;
//
// public DefaultPropertyHandler(PropertyDescriptor descriptor) {
// this.descriptor = descriptor;
// }
//
//
// public Class getPropertyType(Object object) {
// return descriptor.getPropertyType();
// }
//
//
// public Object getProperty(Object object) throws StylesheetException {
// if (descriptor.getReadMethod() != null) {
// try {
// return descriptor.getReadMethod().invoke(object);
// }
// catch (Exception e) {
// throw new StylesheetException(e);
// }
// }
// else
// throw new UnsupportedPropertyException("property " +
// descriptor.getName() + " cannot be read");
// }
//
//
// public void setProperty(Object object, Object value) throws StylesheetException {
// if (descriptor.getWriteMethod() != null) {
// try {
// descriptor.getWriteMethod().invoke(object, value);
// }
// catch (Exception e) {
// throw new StylesheetException(e);
// }
// }
// else
// throw new UnsupportedPropertyException("property " +
// descriptor.getName() + " cannot be written");
// }
// }
| import java.awt.Font;
import java.beans.PropertyDescriptor;
import com.sun.stylesheet.StylesheetException;
import com.sun.stylesheet.styleable.DefaultPropertyHandler; | /*
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/* Modified by Volker Härtel, 8 Dec 2011 */ package com.sun.stylesheet.swing;
/**
* Provides support for the font-style synthetic property.
*
*@author Ethan Nicholas
*/
class FontStyleHandler extends DefaultPropertyHandler {
enum FontStyle { PLAIN, ITALIC };
public FontStyleHandler(PropertyDescriptor descriptor) {
super(descriptor);
}
@Override
public Class getPropertyType(Object object) {
return FontStyle.class;
}
@Override | // Path: com/sun/stylesheet/StylesheetException.java
// public class StylesheetException extends RuntimeException {
// /** Creates a new <code>StylesheetException</code>. */
// public StylesheetException() {
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified detail
// * message.
// *
// *@param msg the exception's detail message
// */
// public StylesheetException(String msg) {
// super(msg);
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified cause.
// *
// *@param initCause the exception's initCause
// */
// public StylesheetException(Throwable initCause) {
// super(initCause);
// }
//
//
// /**
// * Creates a new <code>StylesheetException</code> with the specified detail
// * message and cause.
// *
// *@param msg the exception's detail message
// *@param initCause the exception's initCause
// */
// public StylesheetException(String msg, Throwable initCause) {
// super(msg, initCause);
// }
// }
//
// Path: com/sun/stylesheet/styleable/DefaultPropertyHandler.java
// public class DefaultPropertyHandler implements PropertyHandler {
// protected PropertyDescriptor descriptor;
//
// public DefaultPropertyHandler(PropertyDescriptor descriptor) {
// this.descriptor = descriptor;
// }
//
//
// public Class getPropertyType(Object object) {
// return descriptor.getPropertyType();
// }
//
//
// public Object getProperty(Object object) throws StylesheetException {
// if (descriptor.getReadMethod() != null) {
// try {
// return descriptor.getReadMethod().invoke(object);
// }
// catch (Exception e) {
// throw new StylesheetException(e);
// }
// }
// else
// throw new UnsupportedPropertyException("property " +
// descriptor.getName() + " cannot be read");
// }
//
//
// public void setProperty(Object object, Object value) throws StylesheetException {
// if (descriptor.getWriteMethod() != null) {
// try {
// descriptor.getWriteMethod().invoke(object, value);
// }
// catch (Exception e) {
// throw new StylesheetException(e);
// }
// }
// else
// throw new UnsupportedPropertyException("property " +
// descriptor.getName() + " cannot be written");
// }
// }
// Path: com/sun/stylesheet/swing/FontStyleHandler.java
import java.awt.Font;
import java.beans.PropertyDescriptor;
import com.sun.stylesheet.StylesheetException;
import com.sun.stylesheet.styleable.DefaultPropertyHandler;
/*
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/* Modified by Volker Härtel, 8 Dec 2011 */ package com.sun.stylesheet.swing;
/**
* Provides support for the font-style synthetic property.
*
*@author Ethan Nicholas
*/
class FontStyleHandler extends DefaultPropertyHandler {
enum FontStyle { PLAIN, ITALIC };
public FontStyleHandler(PropertyDescriptor descriptor) {
super(descriptor);
}
@Override
public Class getPropertyType(Object object) {
return FontStyle.class;
}
@Override | public Object getProperty(Object object) throws StylesheetException { |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.