Skip to content

Instantly share code, notes, and snippets.

View fasfsfgs's full-sized avatar

Thiago Almeida fasfsfgs

View GitHub Profile
public class Controller {
@Value("${property}") private String property;
public void property {
System.out.println(property);
}
}
class MyClassTest {
private MyClass myClass = new MyClass();
@Test
void testRightOrder() {
assertEquals(5, myClass.add(2, 3)); // Error: expected: <5> but was: <6>
}
@Test
public class MyClass {
public Integer add(Integer x, Integer y) {
return x + y + 1; // Yes. Let's add 1 to fail the intent of this method.
}
}
httpClient.get('https://example.com/', { context: new HttpContext().set(BYPASS_LOG, true) });
@fasfsfgs
fasfsfgs / my_log.interceptor.ts
Last active August 18, 2021 02:52
angular interceptor
export const BYPASS_LOG = new HttpContextToken(() => false);
export class MyLogInterceptor implements HttpInterceptor {
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
if (req.context.get(BYPASS_LOG) === true)
return next.handle(req);
console.log(`req to ${req.url}`);
return next.handle(req);
(function () {
angular
.module('common')
.directive('fileModel', fileModel);
fileModel.$inject = ['$parse'];
function fileModel($parse) {
var directive = {
restrict: 'A',
link: link