Package com.netflix.hystrix.contrib.javanica.test.spring.domain

Examples of com.netflix.hystrix.contrib.javanica.test.spring.domain.User


    @Test
    public void testGetUser() throws NoSuchFieldException, IllegalAccessException {
        HystrixRequestContext context = HystrixRequestContext.initializeContext();
        try {
            User u1 = userService.getUser("1", "name: ");
            assertEquals("name: 1", u1.getName());
            assertEquals(1, HystrixRequestLog.getCurrentRequest().getAllExecutedCommands().size());
            com.netflix.hystrix.HystrixExecutableInfo<?> command = HystrixRequestLog.getCurrentRequest()
                    .getAllExecutedCommands().iterator().next();
            assertEquals("GetUserCommand", command.getCommandKey().name());
            assertEquals("UserGroupKey", command.getCommandGroup().name());
View Full Code Here


    @Test
    public void testGetUserDefaultPropertiesValues() {
        HystrixRequestContext context = HystrixRequestContext.initializeContext();
        try {
            User u1 = userService.getUserDefProperties("1", "name: ");
            assertEquals("name: 1", u1.getName());
            assertEquals(1, HystrixRequestLog.getCurrentRequest().getAllExecutedCommands().size());
            com.netflix.hystrix.HystrixExecutableInfo<?> command = HystrixRequestLog.getCurrentRequest()
                    .getAllExecutedCommands().iterator().next();
            assertEquals("getUserDefProperties", command.getCommandKey().name());
            assertEquals("UserService", command.getCommandGroup().name());
View Full Code Here

                        @HystrixProperty(name = "metrics.rollingStats.numBuckets", value = "12"),
                        @HystrixProperty(name = "queueSizeRejectionThreshold", value = "15"),
                        @HystrixProperty(name = "metrics.rollingStats.timeInMilliseconds", value = "1440")
                })
        public User getUser(String id, String name) {
            return new User(id, name + id); // it should be network call
        }
View Full Code Here

            return new User(id, name + id); // it should be network call
        }

        @HystrixCommand
        public User getUserDefProperties(String id, String name) {
            return new User(id, name + id); // it should be network call
        }
View Full Code Here

    @Test
    public void testCollapser() throws ExecutionException, InterruptedException {
        HystrixRequestContext context = HystrixRequestContext.initializeContext();
        try {
            User u1 = userService.getUser("1", "name: ");
            User u2 = userService.getUser("2", "name: ");
            User u3 = userService.getUser("3", "name: ");
            User u4 = userService.getUser("4", "name: ");

            assertEquals("name: 1", u1.getName());
            assertEquals("name: 2", u2.getName());
            assertEquals("name: 3", u3.getName());
            assertEquals("name: 4", u4.getName());

            com.netflix.hystrix.HystrixExecutableInfo<?> command = HystrixRequestLog.getCurrentRequest()
                    .getAllExecutedCommands().iterator().next();
            assertEquals("getUser", command.getCommandKey().name());
            //When a command is fronted by an HystrixCollapser then this marks how many requests are collapsed into the single command execution.
View Full Code Here

        @HystrixCollapser(collapserKey = "GetUserCollapser", collapserProperties = {
                @HystrixProperty(name = "maxRequestsInBatch", value = "1"),
                @HystrixProperty(name = "timerDelayInMilliseconds", value = "200")
        })
        public User getUser(String id, String name) {
            return new User(id, name + id);
        }
View Full Code Here

            return new User(id, name + id);
        }

        @HystrixCommand
        public User getUserDefProperties(String id, String name) {
            return new User(id, name + id);
        }
View Full Code Here

    @Test
    public void testGetUserWithFallback() {
        HystrixRequestContext context = HystrixRequestContext.initializeContext();
        try {
            final User exUser = new User("def", "def");

            // blocking
            assertEquals(exUser, userService.getUser(" ", "").toBlockingObservable().single());
            assertEquals(1, HystrixRequestLog.getCurrentRequest().getAllExecutedCommands().size());
            com.netflix.hystrix.HystrixCommand getUserCommand = getHystrixCommandByKey("getUser");
View Full Code Here

        public Observable<User> getUser(final String id, final String name) {
            return new ObservableResult<User>() {
                @Override
                public User invoke() {
                    validate(id, name);
                    return new User(id, name + id);
                }
            };
        }
View Full Code Here

                }
            };
        }

        private User staticFallback(String id, String name) {
            return new User("def", "def");
        }
View Full Code Here

TOP

Related Classes of com.netflix.hystrix.contrib.javanica.test.spring.domain.User

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.